summaryrefslogtreecommitdiffhomepage
path: root/src/rcore.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2021-11-03 13:24:56 +0100
committerraysan5 <[email protected]>2021-11-03 13:24:56 +0100
commit7f4ae653f34edf3c62beb1dea24fe49ef9af1313 (patch)
tree8d029a60c86dd802f82b73e954777ef452928c14 /src/rcore.c
parent703df425869ddfb6537547929126cae18f370ca0 (diff)
downloadraylib-7f4ae653f34edf3c62beb1dea24fe49ef9af1313.tar.gz
raylib-7f4ae653f34edf3c62beb1dea24fe49ef9af1313.zip
Review display output order
Diffstat (limited to 'src/rcore.c')
-rw-r--r--src/rcore.c79
1 files changed, 47 insertions, 32 deletions
diff --git a/src/rcore.c b/src/rcore.c
index 88e45c4f..3b451552 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -3978,6 +3978,38 @@ static bool InitGraphicsDevice(int width, int height)
glfwSwapInterval(1);
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable VSYNC");
}
+
+ int fbWidth = CORE.Window.screen.width;
+ int fbHeight = CORE.Window.screen.height;
+
+#if defined(PLATFORM_DESKTOP)
+ if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0)
+ {
+ // NOTE: On APPLE platforms system should manage window/input scaling and also framebuffer scaling
+ // Framebuffer scaling should be activated with: glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
+ #if !defined(__APPLE__)
+ glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight);
+
+ // Screen scaling matrix is required in case desired screen area is different than display area
+ CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f);
+
+ // Mouse input scaling for the new screen size
+ SetMouseScale((float)CORE.Window.screen.width/fbWidth, (float)CORE.Window.screen.height/fbHeight);
+ #endif
+ }
+#endif
+
+ CORE.Window.render.width = fbWidth;
+ CORE.Window.render.height = fbHeight;
+ CORE.Window.currentFbo.width = fbWidth;
+ CORE.Window.currentFbo.height = fbHeight;
+
+ TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
+ TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
+ 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);
+
#endif // PLATFORM_DESKTOP || PLATFORM_WEB
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
@@ -4377,6 +4409,19 @@ static bool InitGraphicsDevice(int width, int height)
TRACELOG(LOG_WARNING, "DISPLAY: Failed to attach EGL rendering context to EGL surface");
return false;
}
+ else
+ {
+ CORE.Window.render.width = CORE.Window.screen.width;
+ CORE.Window.render.height = CORE.Window.screen.height;
+ CORE.Window.currentFbo.width = CORE.Window.render.width;
+ CORE.Window.currentFbo.height = CORE.Window.render.height;
+
+ TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
+ TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
+ 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);
+ }
#endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM
// Load OpenGL extensions
@@ -4387,43 +4432,13 @@ static bool InitGraphicsDevice(int width, int height)
rlLoadExtensions(eglGetProcAddress);
#endif
- int fbWidth = CORE.Window.screen.width;
- int fbHeight = CORE.Window.screen.height;
-
-#if defined(PLATFORM_DESKTOP)
- if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0)
- {
- // NOTE: On APPLE platforms system should manage window/input scaling and also framebuffer scaling
- // Framebuffer scaling should be activated with: glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
- #if !defined(__APPLE__)
- glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight);
-
- // Screen scaling matrix is required in case desired screen area is different than display area
- CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f);
-
- // Mouse input scaling for the new screen size
- SetMouseScale((float)CORE.Window.screen.width/fbWidth, (float)CORE.Window.screen.height/fbHeight);
- #endif
- }
-#endif
-
- CORE.Window.currentFbo.width = fbWidth;
- CORE.Window.currentFbo.height = fbHeight;
- CORE.Window.render.width = CORE.Window.currentFbo.width;
- CORE.Window.render.height = CORE.Window.currentFbo.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);
// Setup default viewport
- SetupViewport(fbWidth, fbHeight);
-
- TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
- TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
- 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);
+ // NOTE: It updated CORE.Window.render.width and CORE.Window.render.height
+ SetupViewport(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height);
ClearBackground(RAYWHITE); // Default background color for raylib games :P