Skip to content

Commit

Permalink
Remove the rcore.h include from drm, web, template (#3420)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubkp authored Oct 14, 2023
1 parent 6d7112f commit 781f717
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
22 changes: 10 additions & 12 deletions src/rcore_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
*
**********************************************************************************************/

#include "rcore.h"

#include <fcntl.h> // POSIX file control definitions - open(), creat(), fcntl()
#include <unistd.h> // POSIX standard function definitions - read(), close(), STDIN_FILENO
#include <termios.h> // POSIX terminal control definitions - tcgetattr(), tcsetattr()
Expand Down Expand Up @@ -218,12 +216,12 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN;

// Initialize platform
//--------------------------------------------------------------
//--------------------------------------------------------------
InitPlatform();
//--------------------------------------------------------------

// Initialize rlgl default data (buffers and shaders)
// NOTE: CORE.Window.currentFbo.width and CORE.Window.currentFbo.height not used, just stored as globals in rlgl
rlglInit(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height);
Expand Down Expand Up @@ -272,10 +270,10 @@ void InitWindow(int width, int height, const char *title)
events = (AutomationEvent *)RL_CALLOC(MAX_CODE_AUTOMATION_EVENTS, sizeof(AutomationEvent));
CORE.Time.frameCounter = 0;
#endif

// Initialize random seed
SetRandomSeed((unsigned int)time(NULL));

TRACELOG(LOG_INFO, "PLATFORM: DRM: Application initialized successfully");
}

Expand All @@ -302,7 +300,7 @@ void CloseWindow(void)
#endif

// De-initialize platform
//--------------------------------------------------------------
//--------------------------------------------------------------
ClosePlatform();
//--------------------------------------------------------------

Expand Down Expand Up @@ -721,7 +719,7 @@ static int InitPlatform(void)
platform.gbmSurface = NULL;
platform.prevBO = NULL;
platform.prevFB = 0;

CORE.Window.fullscreen = true;
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;

Expand Down Expand Up @@ -1034,9 +1032,9 @@ static int InitPlatform(void)
rlLoadExtensions(eglGetProcAddress);

if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) MinimizeWindow();

CORE.Window.ready = true; // TODO: Proper validation on windows/context creation

// If graphic device is no properly initialized, we end program
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor()) / 2 - CORE.Window.screen.width / 2, GetMonitorHeight(GetCurrentMonitor()) / 2 - CORE.Window.screen.height / 2);
Expand All @@ -1057,7 +1055,7 @@ static int InitPlatform(void)
InitEvdevInput(); // Evdev inputs initialization
InitGamepad(); // Gamepad init
InitKeyboard(); // Keyboard init (stdin)

return 0;
}

Expand Down
12 changes: 5 additions & 7 deletions src/rcore_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
*
**********************************************************************************************/

#include "rcore.h"

// TODO: Include the platform specific libraries

//----------------------------------------------------------------------------------
Expand Down Expand Up @@ -130,8 +128,8 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
CORE.Window.eventWaiting = false;


// TODO: Platform specific init window
//--------------------------------------------------------------
CORE.Window.screen.width = width;
Expand All @@ -144,7 +142,7 @@ void InitWindow(int width, int height, const char *title)
CORE.Window.ready = InitGraphicsDevice(width, height);



// Initialize OpenGL context (states and resources)
// NOTE: CORE.Window.currentFbo.width and CORE.Window.currentFbo.height not used, just stored as globals in rlgl
rlglInit(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height);
Expand Down Expand Up @@ -711,13 +709,13 @@ static int InitPlatform(void)
rlLoadExtensions(eglGetProcAddress);

CORE.Window.ready = true;

// If graphic device is no properly initialized, we end program
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }

// Initialize hi-res timer
InitTimer();

// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();

Expand Down
18 changes: 8 additions & 10 deletions src/rcore_web.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
*
**********************************************************************************************/

#include "rcore.h"

#define GLFW_INCLUDE_ES2 // GLFW3: Enable OpenGL ES 2.0 (translated to WebGL)
// #define GLFW_INCLUDE_ES3 // GLFW3: Enable OpenGL ES 3.0 (transalted to WebGL2?)
#include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management
Expand Down Expand Up @@ -177,7 +175,7 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN;

// Initialize platform
//--------------------------------------------------------------
//--------------------------------------------------------------
InitPlatform();
//--------------------------------------------------------------

Expand Down Expand Up @@ -256,7 +254,7 @@ void CloseWindow(void)
rlglClose(); // De-init rlgl

// De-initialize platform
//--------------------------------------------------------------
//--------------------------------------------------------------
ClosePlatform();
//--------------------------------------------------------------

Expand Down Expand Up @@ -1005,7 +1003,7 @@ static int InitPlatform(void)
glfwSetCursorEnterCallback(platform.handle, CursorEnterCallback);

glfwMakeContextCurrent(platform.handle);

// Load OpenGL extensions
// NOTE: GL procedures address loader is required to load extensions
rlLoadExtensions(glfwGetProcAddress);
Expand All @@ -1029,19 +1027,19 @@ static int InitPlatform(void)
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);

CORE.Window.ready = true; // TODO: Proper validation on windows/context creation

// If graphic device is no properly initialized, we end program
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor())/2 - CORE.Window.screen.width/2, GetMonitorHeight(GetCurrentMonitor())/2 - CORE.Window.screen.height/2);

// Initialize hi-res timer
InitTimer();

// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();

// Setup callback functions for the DOM events
emscripten_set_fullscreenchange_callback("#canvas", NULL, 1, EmscriptenFullscreenChangeCallback);

Expand Down Expand Up @@ -1070,7 +1068,7 @@ static int InitPlatform(void)
// Support gamepad events (not provided by GLFW3 on emscripten)
emscripten_set_gamepadconnected_callback(NULL, 1, EmscriptenGamepadCallback);
emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenGamepadCallback);

return 0;
}

Expand Down

0 comments on commit 781f717

Please sign in to comment.