Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submodules #3311

Merged
merged 31 commits into from
Sep 19, 2023
Merged

Submodules #3311

merged 31 commits into from
Sep 19, 2023

Conversation

michaelfiber
Copy link
Sponsor Contributor

@michaelfiber michaelfiber commented Sep 13, 2023

This is an experiment into the feasibility of moving rcore functions to platform specific submodules:

  • rcore_desktop.c
  • rcore_drm.c
  • rcore_web.c
  • rcore_android.c

This is accomplished by moving appropriate function definitions to a new rcore.h that rcore.c and all the submodules include. There are also changes to the Makefile to conditionally include only the appropriate submodule when compiling.

The goal is to figure out what decisions have to be made to actually divide rcore.c into submodules. I'll start issues for discussion when this process exposes interesting choices that must be made to make this change.

@raysan5
Copy link
Owner

raysan5 commented Sep 14, 2023

@michaelfiber Wow! This is a BIG change of raylib and I see it still requires lot of work but it seems it's going in the right direction! Thank you very much for starting working on it!

Input polling should be defined per platform and maybe some other part...

EDIT: Copying the info from wishlist for reference:

  • REDESIGN: Module subdivision. This module has grown a lot with every new supported platform (~7000 loc), at some point it could be divided into separate modules. Two possible approaches:
    • Divide by platform:
      • rcore_desktop.c - PLATFORM_DESKTOP (Windows, Linux, macOS)
      • rcore_android.c - PLATFORM_ANDROID
      • rcore_native.c - PLATFORM_DRM/PLATFORM_RPI
      • rcore_web.c - PLATFORM_WEB
    • Divide by technology
      • rcore_glfw.c - GLFW library based
      • rcore_sdl.c - SDL library based
      • rcore_native.c - Native implementation

This is not an easy task, still deciding the proper approach for it. There are 45 functions depending on ~100 GLFW functions, those 45 functions should be reproduced separately for the different platforms/technologies and exposed through the same common API.

@michaelfiber
Copy link
Sponsor Contributor Author

@michaelfiber Wow! This is a BIG change of raylib and I see it still requires lot of work but it seems it's going in the right direction! Thank you very much for starting working on it!

Input polling should be defined per platform and maybe some other part...

Yes there is a lot more work to do on it and draft PR showing up here was actually a mistake on my part, I meant to keep it in my fork until I had more work done! Right now I am focusing on having a good way to check if I am breaking anything on a platform that I don't have access to at the moment and Github actions are great for that.

@michaelfiber michaelfiber changed the base branch from master to rcore_platform_split September 19, 2023 20:40
@michaelfiber michaelfiber marked this pull request as ready for review September 19, 2023 20:40
@michaelfiber
Copy link
Sponsor Contributor Author

All of the functions from rcore that were listed as depeneding on glfw have moved to submodules. A few other functions that were mostly platform specific code moved as well. There may still be more functions in rcore that it would make sense to move to submodules.

I think from where it is right now it may be possible for people to grab a specific submodule and start debugging further to get this closer to ready for release.

@raysan5 raysan5 merged commit f27454c into raysan5:rcore_platform_split Sep 19, 2023
6 of 10 checks passed
@raysan5
Copy link
Owner

raysan5 commented Sep 19, 2023

@michaelfiber Thanks!

raysan5 added a commit that referenced this pull request Oct 8, 2023
* Submodules (#3311)

* Check in current state

* Add submodules to Makefile and clean up some imports

* Start moving InitGraphicsDeivce

* Move android_main and CloseWindow() out of rcore

* Move WindowShouldClose out of rcore

* Move IsWindowHidden out of rcore

* Move IsWindowMinimized out of rcore

* Move IsWindowMaximized, IsWindowFocused and IsWindowResized out of rcore

* Move ToggleFullscreen out of rcore

* Move MaximizeWindow, MinimizeWindow and RestoreWindow out of rcore

* Move 13 functions out of rcore:
ToggleBorderlessWindowed
SetWindowState
ClearWindowState
SetWindowIcon
SetWindowIcons
SetWindowTitle
SetWindowPosition
SetWindowMonitor
SetWindowMinSize
SetWindowMaxSize
SetWindowSize
SetWindowOpacity
SetWindowFocused

* Minor clean up, revert makefile change, include submodules directly in rcore

* Fix makefile comment

* Remove rcore.h from Makefile

* Remove debug include

* Move 18 functions from rcore to submodules
GetWindowHandle
GetMonitorCount
GetCurrentMonitor
GetMonitorPosition
GetMonitorWidth
GetMonitorHeight
GetMonitorPhysicalHeight
GetMonitorRefreshRate
GetWindowPosition
GetWindowScaleDPI
GetMonitorName
SetClipboardText
GetClipboardText
ShowCursor
HideCursor
EnableCursor
DisableCursor
GetTime

* Move TakeScreenshot, OpenURL, GetGamepadName out of rcore into submodules

* remove debugging #defines

* Move GetMonitorPhysicalWidth from rcore to submodule

* Move GetGamepadAxisCount from rcore

* Move SetGamepadMappings out of rcore

* Move GetMouseX, GetMouseY, GetMousePosition out of rcore

* Move SetMousePosition out of rcore

* Move GetMouseWheelMove out of rcore

* Move the last functions out of rcore

* Move shared function defs and some global var to rcore.h

* Clean up rcore.c and rcore.h a little more

* Remove unnecessary #define

---------

Co-authored-by: MichaelFiber <michael@cubeofb.org>

* REVIEWED: `PLATFORM_DESKTOP` Windows building

* Revert "REVIEWED: `PLATFORM_DESKTOP` Windows building"

This reverts commit 71a1217.

* Reviewed Windows building

* [split] Fix compilation for web (and desktop) (#3329)

* Fix compilation for web

* Remove EM_ASM_INT from core_input_gestures_web example

* Fix raymath undefined symbols for desktop and web

* Remove raylib_opengl_interop from examples Makefile

* Revert previous commit (8651c78)

* Fix TraceLog for web and desktop

* [split] `rcore`, `rcore_web` and `rcore_desktop` changes (batch 2) (#3334)

* Fix formatting

* Reapply commit 9d230d7 (#3305) that was missing

* Reapplies commits 719365f (#3309) and 8a1779b (#3312) that were missing

* Reapply commit 5c9cc3f (#3323) that was missing

* Reapply commit a2b3b1e that was missing

* Revert commit cef25c6 to fix macro redefined warning

* Move rcore.h #include to after config.h to fix macro redefinitions warnings

* [split] `rcore`, `web`, `desktop`, `android` changes (batch 3) (#3338)

* First pass to remove unneeded platform macros for web

* Second pass to remove unneeded platform macros for web

* Move GetTouchX, GetTouchY, GetTouchPosition from rcore to web, desktop, android

* Move SetMouseCursor from rcore to android, desktop, web

* [split] `rcore`, `web`, `desktop`, `android` changes (batch 4) (#3343)

* Fix ToggleBorderlessWindowed duplicated glfwSetWindowSize calls

* First pass to remove unneeded platform macros for android

* Second pass to remove unneeded platform macros for android

* Remove unneeded platform macros for desktop

* Relocate GetGamepadName and update SetGamepadMappings on android, desktop, web

* Add missing comment to web

* [split] `rcore`, `web`, `desktop`, `android` changes (batch 5) (#3345)

* Move SetExitKey from core to android, desktop, web

* Move some callbacks from core to desktop and web

* Relocate emscripten callbacks on web

* Relocate android callbacks on android

* Revert "Relocate android callbacks on android"

This reverts commit bbdbecc.

* Updates UnloadVrStereoConfig on rcore

* Update SetClipboardText on android

* Fix screenMin/Max default values for android

* [split] `rcore`, `drm` changes (#3347)

* Tweak makefiles for PLATFORM_DRM and move rcore_drm's dependencies to rcore.h

* Move drm functions to rcore_drm.c

* Fix a typo in rcore.c

* Add SetExitKey to rcore_drm.c

---------

Co-authored-by: MichaelFiber <michael@cubeofb.org>

* Fix compilation for android (#3360)

* Fix android include (#3364)

* Reviewed platform split #3313

 - Added file headers info
 - Added TRACELOG message for unimplemented functions
 - Reviewed code formatting and organization
 - Several code tweaks

* REVIEWED: `GetDirectoryPath()`

---------

Co-authored-by: MichaelFiber <42419558+michaelfiber@users.noreply.github.com>
Co-authored-by: MichaelFiber <michael@cubeofb.org>
Co-authored-by: ubkp <118854183+ubkp@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants