Moved some platforms functions to generic rcore #3313

Reviewed `InitWindow()` to clearly note platform specific code
This commit is contained in:
Ray 2023-10-13 14:14:16 +02:00
commit 2e65bc675c
6 changed files with 142 additions and 236 deletions

View file

@ -215,6 +215,9 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
CORE.Window.eventWaiting = false;
// Platform specific init window
//--------------------------------------------------------------
// Initialize graphics device (display device and OpenGL context)
// NOTE: returns true if window and graphic device has been initialized successfully
CORE.Window.ready = InitGraphicsDevice(width, height);
@ -223,15 +226,28 @@ void InitWindow(int width, int height, const char *title)
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return; }
else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor()) / 2 - CORE.Window.screen.width / 2, GetMonitorHeight(GetCurrentMonitor()) / 2 - CORE.Window.screen.height / 2);
// Set some default window flags
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // false
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED); // false
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED); // true
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED); // false
// Initialize hi-res timer
InitTimer();
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
// Initialize raw input system
InitEvdevInput(); // Evdev inputs initialization
InitGamepad(); // Gamepad init
InitKeyboard(); // Keyboard init (stdin)
//--------------------------------------------------------------
// Initialize random seed
SetRandomSeed((unsigned int)time(NULL));
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
// Load default font
// WARNING: External function: Module required: rtext
@ -274,14 +290,6 @@ void InitWindow(int width, int height, const char *title)
CORE.Time.frameCounter = 0;
#endif
// Platform specific init window
//--------------------------------------------------------------
// Initialize raw input system
InitEvdevInput(); // Evdev inputs initialization
InitGamepad(); // Gamepad init
InitKeyboard(); // Keyboard init (stdin)
//--------------------------------------------------------------
TRACELOG(LOG_INFO, "PLATFORM: DRM: Application initialized successfully");
}
@ -412,36 +420,6 @@ bool WindowShouldClose(void)
else return true;
}
// Check if window is currently hidden
bool IsWindowHidden(void)
{
return false;
}
// Check if window has been minimized
bool IsWindowMinimized(void)
{
return false;
}
// Check if window has been maximized
bool IsWindowMaximized(void)
{
return false;
}
// Check if window has the focus
bool IsWindowFocused(void)
{
return true;
}
// Check if window has been resizedLastFrame
bool IsWindowResized(void)
{
return false;
}
// Toggle fullscreen mode
void ToggleFullscreen(void)
{