From 63a4eb8a6256c8716ead09ffa0013b2d9333298a Mon Sep 17 00:00:00 2001 From: IoIxD Date: Thu, 29 Aug 2024 23:47:49 -0700 Subject: [PATCH] the j --- examples/CMakeLists.txt | 4 +++- examples/core/core_ascii_rendering.c | 16 +++++++++++++--- src/platforms/rcore_android.c | 5 ----- src/platforms/rcore_desktop_glfw.c | 5 ----- src/platforms/rcore_desktop_rgfw.c | 5 ----- src/platforms/rcore_desktop_sdl.c | 5 ----- src/platforms/rcore_drm.c | 5 ----- src/platforms/rcore_none.c | 11 ++++++++++- src/platforms/rcore_none.h | 10 ++++++++++ src/platforms/rcore_template.c | 5 ----- src/platforms/rcore_web.c | 5 ----- 11 files changed, 36 insertions(+), 40 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 64b6d7604..d36ccc2ee 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -118,7 +118,9 @@ elseif (NOT SUPPORT_GESTURES_SYSTEM) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_basic_screen_manager.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_input_gestures_web.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_input_gestures.c) - +elseif ("${PLATFORM}" STREQUAL "None" OR "${PLATFORM}" STREQUAL "Offscreen") + # for some reason i get an error when trying to compile this one from any platform? oh well we'll just stick it here + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c) endif () # The rlgl_standalone example only targets desktop, without shared libraries. diff --git a/examples/core/core_ascii_rendering.c b/examples/core/core_ascii_rendering.c index e2017ec3d..ca6f2fe30 100644 --- a/examples/core/core_ascii_rendering.c +++ b/examples/core/core_ascii_rendering.c @@ -25,7 +25,13 @@ const int screenWidth = 800; const int screenHeight = 450; GLFWwindow *window; - + + + +bool CustomWindowShouldClose(void) { + return glfwWindowShouldClose(window); +} + int CustomInitPlatform(void) { if (!glfwInit()) { @@ -89,10 +95,14 @@ void CustomClosePlatform(void) { int main(void) { union OverridableFunctionPointer funcs; + funcs.InitPlatform = CustomInitPlatform; + funcs.ClosePlatform = CustomClosePlatform; + funcs.WindowShouldClose = CustomWindowShouldClose; CustomInitPlatform(); - OverrideInternalFunction("InitPlatform",&funcs); + //OverrideInternalFunction("InitPlatform",&funcs); OverrideInternalFunction("ClosePlatform",&funcs); + OverrideInternalFunction("WindowShouldClose",&funcs); RenderTexture2D fb = LoadRenderTexture(80,24); @@ -114,6 +124,6 @@ int main(void) glfwPollEvents(); } - CustomClosePlatform(); + //CustomClosePlatform(); return 0; } diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 3f5ac6c87..de90f98b1 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -251,7 +251,6 @@ static const KeyboardKey mapKeycode[KEYCODE_MAP_SIZE] = { //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) void ClosePlatform(void); // Close platform -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); static void AndroidCommandCallback(struct android_app *app, int32_t cmd); // Process Android activity lifecycle commands static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event); // Process Android inputs @@ -1337,9 +1336,5 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) return 0; } -// Override an internal platform function with your own (PLATFORM_OFFSCREEN and PLATFORM_NONE only) -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); { - TraceLog(LOG_WARNING, "OverrideInternalFunction called on unsupported platform"); -}; // EOF diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 968611851..bede39e0a 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -103,7 +103,6 @@ static PlatformData platform = { 0 }; // Platform specific data //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) void ClosePlatform(void); // Close platform -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); // Error callback event static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error @@ -1899,9 +1898,5 @@ static void JoystickCallback(int jid, int event) } } -// Override an internal platform function with your own (PLATFORM_OFFSCREEN and PLATFORM_NONE only) -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); { - TraceLog(LOG_WARNING, "OverrideInternalFunction called on unsupported platform"); -}; // EOF diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 8fec55198..01270b3eb 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -220,7 +220,6 @@ static const unsigned short keyMappingRGFW[] = { //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) bool InitGraphicsDevice(void); // Initialize graphics device -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); //---------------------------------------------------------------------------------- // Module Functions Declaration @@ -1355,8 +1354,4 @@ static KeyboardKey ConvertScancodeToKey(u32 keycode) return keyMappingRGFW[keycode]; } -// Override an internal platform function with your own (PLATFORM_OFFSCREEN and PLATFORM_NONE only) -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); { - TraceLog(LOG_WARNING, "OverrideInternalFunction called on unsupported platform"); -}; diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 67b6a7dfa..3a5976135 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -225,7 +225,6 @@ static const int CursorsLUT[] = { //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) void ClosePlatform(void); // Close platform -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); static KeyboardKey ConvertScancodeToKey(SDL_Scancode sdlScancode); // Help convert SDL scancodes to raylib key @@ -1620,9 +1619,5 @@ static KeyboardKey ConvertScancodeToKey(SDL_Scancode sdlScancode) } -// Override an internal platform function with your own (PLATFORM_OFFSCREEN and PLATFORM_NONE only) -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); { - TraceLog(LOG_WARNING, "OverrideInternalFunction called on unsupported platform"); -}; // EOF diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index 9b7b7b3c5..56e0095c0 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -219,7 +219,6 @@ static const short linuxToRaylibMap[KEYMAP_SIZE] = { //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) void ClosePlatform(void); // Close platform -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); #if defined(SUPPORT_SSH_KEYBOARD_RPI) static void InitKeyboard(void); // Initialize raw keyboard system @@ -1939,9 +1938,5 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt return nearestIndex; } -// Override an internal platform function with your own (PLATFORM_OFFSCREEN and PLATFORM_NONE only) -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); { - TraceLog(LOG_WARNING, "OverrideInternalFunction called on unsupported platform"); -}; // EOF diff --git a/src/platforms/rcore_none.c b/src/platforms/rcore_none.c index f86c5bcb7..660957ab4 100644 --- a/src/platforms/rcore_none.c +++ b/src/platforms/rcore_none.c @@ -91,6 +91,16 @@ GEN_CALLBACK_BODY_VOID(OpenURL, (const char *url), (url)) // Note that there is no responsibility here for the Raylib maintainers to keep a stable API for core functions void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func) { GEN_CASE(InitPlatform) + GEN_CASE(WindowShouldClose) + GEN_CASE(GetMonitorCount) + GEN_CASE(GetCurrentMonitor) + GEN_CASE(ShowCursor) + GEN_CASE(HideCursor) + GEN_CASE(SetWindowState) + GEN_CASE(ClearWindowState) + GEN_CASE(SetWindowMinSize) + GEN_CASE(SetWindowMaxSize) + GEN_CASE(SetWindowSize) GEN_CASE(ClosePlatform) GEN_CASE(ToggleFullscreen) GEN_CASE(ToggleBorderlessWindowed) @@ -139,7 +149,6 @@ CoreData * GetCore() { int InitPlatform(void) { CHECK_AND_CALL(InitPlatform, ()); CORE.Window.ready = true; - TRACELOG(LOG_WARNING, "InitPlatform was called but not overriden by the user"); return 0; } diff --git a/src/platforms/rcore_none.h b/src/platforms/rcore_none.h index 5e15f57b9..de9c9b5ef 100644 --- a/src/platforms/rcore_none.h +++ b/src/platforms/rcore_none.h @@ -144,6 +144,16 @@ GEN_CALLBACK_HEAD_VOID(SetWindowSize, (int width, int height), (width,height)) // The fields are only accessible when compiling with PLATFORM_NONE or PLATFORM_OFFSCREEN union OverridableFunctionPointer { GEN_FIELD(InitPlatform) + GEN_FIELD(WindowShouldClose) + GEN_FIELD(GetMonitorCount) + GEN_FIELD(GetCurrentMonitor) + GEN_FIELD(ShowCursor) + GEN_FIELD(HideCursor) + GEN_FIELD(SetWindowState) + GEN_FIELD(ClearWindowState) + GEN_FIELD(SetWindowMinSize) + GEN_FIELD(SetWindowMaxSize) + GEN_FIELD(SetWindowSize) GEN_FIELD(ClosePlatform) GEN_FIELD(ToggleFullscreen) GEN_FIELD(ToggleBorderlessWindowed) diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 15ef04a48..ff5d6c76f 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -73,7 +73,6 @@ static PlatformData platform = { 0 }; // Platform specific data //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) bool InitGraphicsDevice(void); // Initialize graphics device -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); //---------------------------------------------------------------------------------- // Module Functions Declaration @@ -596,9 +595,5 @@ void ClosePlatform(void) // TODO: De-initialize graphics, inputs and more } -// Override an internal platform function with your own (PLATFORM_OFFSCREEN and PLATFORM_NONE only) -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); { - TraceLog(LOG_WARNING, "OverrideInternalFunction called on unsupported platform"); -}; // EOF diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 41ee4e573..6d8a3de8e 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -107,7 +107,6 @@ Vector2 lockedMousePos = { 0 }; //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) void ClosePlatform(void); // Close platform -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); // Error callback event static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error @@ -1730,9 +1729,5 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent return 1; // The event was consumed by the callback handler } -// Override an internal platform function with your own (PLATFORM_OFFSCREEN and PLATFORM_NONE only) -void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func); { - TraceLog(LOG_WARNING, "OverrideInternalFunction called on unsupported platform"); -}; // EOF