Corrected issue on OSX with High DPI display

Many thanks to Marcelo Paez (paezao)
This commit is contained in:
raysan5 2016-07-26 16:55:46 +02:00
parent 07a375e2d6
commit a422e39492
2 changed files with 12 additions and 10 deletions

View File

@ -249,6 +249,7 @@ contributing (in some way or another) to make raylib project better. Huge thanks
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
- Marcelo Paez (paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo!
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"

View File

@ -1613,15 +1613,6 @@ static void InitGraphicsDevice(int width, int height)
glfwSwapInterval(1);
TraceLog(INFO, "Trying to enable VSYNC");
}
#ifdef __APPLE__
// Get framebuffer size of current window
// NOTE: Required to handle HighDPI display correctly
// TODO: Probably should be added for other systems too or managed
// internally by GLFW3 callback: glfwSetFramebufferSizeCallback()
glfwGetFramebufferSize(window, &renderWidth, &renderHeight);
#endif
#endif // defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
@ -1775,9 +1766,19 @@ static void InitGraphicsDevice(int width, int height)
// NOTE: screenWidth and screenHeight not used, just stored as globals
rlglInit(screenWidth, screenHeight);
#ifdef __APPLE__
// Get framebuffer size of current window
// NOTE: Required to handle HighDPI display correctly on OSX because framebuffer
// is automatically reasized to adapt to new DPI.
// When OS does that, it can be detected using GLFW3 callback: glfwSetFramebufferSizeCallback()
int fbWidth, fbHeight;
glfwGetFramebufferSize(window, &fbWidth, &fbHeight);
rlViewport(renderOffsetX/2, renderOffsetY/2, fbWidth - renderOffsetX, fbHeight - renderOffsetY);
#else
// Initialize screen viewport (area of the screen that you will actually draw to)
// NOTE: Viewport must be recalculated if screen is resized
rlViewport(renderOffsetX/2, renderOffsetY/2, renderWidth - renderOffsetX, renderHeight - renderOffsetY);
#endif
// Initialize internal projection and modelview matrices
// NOTE: Default to orthographic projection mode with top-left corner at (0,0)