This commit is contained in:
IoIxD 2024-08-29 23:47:49 -07:00
parent 00084ddb11
commit 63a4eb8a62
11 changed files with 36 additions and 40 deletions

View File

@ -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_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_web.c)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_input_gestures.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 () endif ()
# The rlgl_standalone example only targets desktop, without shared libraries. # The rlgl_standalone example only targets desktop, without shared libraries.

View File

@ -25,7 +25,13 @@
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
GLFWwindow *window; GLFWwindow *window;
bool CustomWindowShouldClose(void) {
return glfwWindowShouldClose(window);
}
int CustomInitPlatform(void) { int CustomInitPlatform(void) {
if (!glfwInit()) if (!glfwInit())
{ {
@ -89,10 +95,14 @@ void CustomClosePlatform(void) {
int main(void) int main(void)
{ {
union OverridableFunctionPointer funcs; union OverridableFunctionPointer funcs;
funcs.InitPlatform = CustomInitPlatform;
funcs.ClosePlatform = CustomClosePlatform;
funcs.WindowShouldClose = CustomWindowShouldClose;
CustomInitPlatform(); CustomInitPlatform();
OverrideInternalFunction("InitPlatform",&funcs); //OverrideInternalFunction("InitPlatform",&funcs);
OverrideInternalFunction("ClosePlatform",&funcs); OverrideInternalFunction("ClosePlatform",&funcs);
OverrideInternalFunction("WindowShouldClose",&funcs);
RenderTexture2D fb = LoadRenderTexture(80,24); RenderTexture2D fb = LoadRenderTexture(80,24);
@ -114,6 +124,6 @@ int main(void)
glfwPollEvents(); glfwPollEvents();
} }
CustomClosePlatform(); //CustomClosePlatform();
return 0; return 0;
} }

View File

@ -251,7 +251,6 @@ static const KeyboardKey mapKeycode[KEYCODE_MAP_SIZE] = {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
void ClosePlatform(void); // Close platform 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 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 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; 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 // EOF

View File

@ -103,7 +103,6 @@ static PlatformData platform = { 0 }; // Platform specific data
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
void ClosePlatform(void); // Close platform void ClosePlatform(void); // Close platform
void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func);
// Error callback event // Error callback event
static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error 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 // EOF

View File

@ -220,7 +220,6 @@ static const unsigned short keyMappingRGFW[] = {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
bool InitGraphicsDevice(void); // Initialize graphics device bool InitGraphicsDevice(void); // Initialize graphics device
void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
@ -1355,8 +1354,4 @@ static KeyboardKey ConvertScancodeToKey(u32 keycode)
return keyMappingRGFW[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");
};

View File

@ -225,7 +225,6 @@ static const int CursorsLUT[] = {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
void ClosePlatform(void); // Close platform 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 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 // EOF

View File

@ -219,7 +219,6 @@ static const short linuxToRaylibMap[KEYMAP_SIZE] = {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
void ClosePlatform(void); // Close platform void ClosePlatform(void); // Close platform
void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func);
#if defined(SUPPORT_SSH_KEYBOARD_RPI) #if defined(SUPPORT_SSH_KEYBOARD_RPI)
static void InitKeyboard(void); // Initialize raw keyboard system static void InitKeyboard(void); // Initialize raw keyboard system
@ -1939,9 +1938,5 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt
return nearestIndex; 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 // EOF

View File

@ -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 // 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) { void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func) {
GEN_CASE(InitPlatform) 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(ClosePlatform)
GEN_CASE(ToggleFullscreen) GEN_CASE(ToggleFullscreen)
GEN_CASE(ToggleBorderlessWindowed) GEN_CASE(ToggleBorderlessWindowed)
@ -139,7 +149,6 @@ CoreData * GetCore() {
int InitPlatform(void) { int InitPlatform(void) {
CHECK_AND_CALL(InitPlatform, ()); CHECK_AND_CALL(InitPlatform, ());
CORE.Window.ready = true; CORE.Window.ready = true;
TRACELOG(LOG_WARNING, "InitPlatform was called but not overriden by the user");
return 0; return 0;
} }

View File

@ -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 // The fields are only accessible when compiling with PLATFORM_NONE or PLATFORM_OFFSCREEN
union OverridableFunctionPointer { union OverridableFunctionPointer {
GEN_FIELD(InitPlatform) 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(ClosePlatform)
GEN_FIELD(ToggleFullscreen) GEN_FIELD(ToggleFullscreen)
GEN_FIELD(ToggleBorderlessWindowed) GEN_FIELD(ToggleBorderlessWindowed)

View File

@ -73,7 +73,6 @@ static PlatformData platform = { 0 }; // Platform specific data
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
bool InitGraphicsDevice(void); // Initialize graphics device bool InitGraphicsDevice(void); // Initialize graphics device
void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
@ -596,9 +595,5 @@ void ClosePlatform(void)
// TODO: De-initialize graphics, inputs and more // 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 // EOF

View File

@ -107,7 +107,6 @@ Vector2 lockedMousePos = { 0 };
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
void ClosePlatform(void); // Close platform void ClosePlatform(void); // Close platform
void OverrideInternalFunction(const char * funcName, union OverridableFunctionPointer * func);
// Error callback event // Error callback event
static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error 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 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 // EOF