summaryrefslogtreecommitdiffhomepage
path: root/src/platforms/rcore_drm.c
diff options
context:
space:
mode:
authorRay <[email protected]>2023-10-23 19:15:40 +0200
committerRay <[email protected]>2023-10-23 19:15:40 +0200
commita0f00343523a8898dfed46ee21afaa99d0c15f66 (patch)
tree7097c237852e6b7b7f2538002b9fd040eb8711c1 /src/platforms/rcore_drm.c
parent3ff60269174d0f264c152875be4d1808b7fe0195 (diff)
downloadraylib-a0f00343523a8898dfed46ee21afaa99d0c15f66.tar.gz
raylib-a0f00343523a8898dfed46ee21afaa99d0c15f66.zip
REVIEWED: `InitPlatform()` organization and code-gardening
Diffstat (limited to 'src/platforms/rcore_drm.c')
-rw-r--r--src/platforms/rcore_drm.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c
index 2ecfc2a3..9609c50d 100644
--- a/src/platforms/rcore_drm.c
+++ b/src/platforms/rcore_drm.c
@@ -576,6 +576,8 @@ int InitPlatform(void)
platform.prevBO = NULL;
platform.prevFB = 0;
+ // Initialize graphic device: display/window and graphic context
+ //----------------------------------------------------------------------------
CORE.Window.fullscreen = true;
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
@@ -846,7 +848,6 @@ int InitPlatform(void)
}
// Create an EGL window surface
- //---------------------------------------------------------------------------------
platform.surface = eglCreateWindowSurface(platform.device, platform.config, (EGLNativeWindowType)platform.gbmSurface, NULL);
if (EGL_NO_SURFACE == platform.surface)
{
@@ -863,14 +864,14 @@ int InitPlatform(void)
// There must be at least one frame displayed before the buffers are swapped
//eglSwapInterval(platform.device, 1);
+
+ EGLBoolean result = eglMakeCurrent(platform.device, platform.surface, platform.surface, platform.context);
- if (eglMakeCurrent(platform.device, platform.surface, platform.surface, platform.context) == EGL_FALSE)
- {
- TRACELOG(LOG_WARNING, "DISPLAY: Failed to attach EGL rendering context to EGL surface");
- return -1;
- }
- else
+ // Check surface and context activation
+ if (result != EGL_FALSE)
{
+ CORE.Window.ready = true;
+
CORE.Window.render.width = CORE.Window.screen.width;
CORE.Window.render.height = CORE.Window.screen.height;
CORE.Window.currentFbo.width = CORE.Window.render.width;
@@ -882,16 +883,15 @@ int InitPlatform(void)
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);
}
-
- // Load OpenGL extensions
- // NOTE: GL procedures address loader is required to load extensions
- rlLoadExtensions(eglGetProcAddress);
+ else
+ {
+ TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphics device");
+ return -1;
+ }
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 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);
@@ -901,16 +901,29 @@ int InitPlatform(void)
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; // true
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED; // false
- // Initialize hi-res timer
+ // Load OpenGL extensions
+ // NOTE: GL procedures address loader is required to load extensions
+ rlLoadExtensions(eglGetProcAddress);
+ //----------------------------------------------------------------------------
+
+ // Initialize input events system
+ //----------------------------------------------------------------------------
+ InitEvdevInput(); // Evdev inputs initialization
+ InitGamepad(); // Gamepad init
+ InitKeyboard(); // Keyboard init (stdin)
+ //----------------------------------------------------------------------------
+
+ // Initialize timming system
+ //----------------------------------------------------------------------------
InitTimer();
+ //----------------------------------------------------------------------------
- // Initialize base path for storage
+ // Initialize storage system
+ //----------------------------------------------------------------------------
CORE.Storage.basePath = GetWorkingDirectory();
-
- // Initialize raw input system
- InitEvdevInput(); // Evdev inputs initialization
- InitGamepad(); // Gamepad init
- InitKeyboard(); // Keyboard init (stdin)
+ //----------------------------------------------------------------------------
+
+ TRACELOG(LOG_INFO, "PLATFORM: DRM: Initialized successfully");
return 0;
}
@@ -1005,7 +1018,6 @@ void ClosePlatform(void)
if (platform.gamepadThreadId) pthread_join(platform.gamepadThreadId, NULL);
}
-
// Initialize Keyboard system (using standard input)
static void InitKeyboard(void)
{