Merge pull request #206 from joeld42/jbd_bugfix
Added SetupViewport so high-DPI fix applies to EndTextureMode
This commit is contained in:
commit
673ea62b27
2 changed files with 22 additions and 15 deletions
|
@ -193,6 +193,7 @@ features
|
||||||
* Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi**, **HTML5** and **Oculus Rift CV1**
|
* Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi**, **HTML5** and **Oculus Rift CV1**
|
||||||
* Custom color palette for fancy visuals on raywhite background
|
* Custom color palette for fancy visuals on raywhite background
|
||||||
* Minimal external dependencies (GLFW3, OpenGL, OpenAL)
|
* Minimal external dependencies (GLFW3, OpenGL, OpenAL)
|
||||||
|
* Complete binding to LUA
|
||||||
|
|
||||||
raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option by far I found for
|
raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option by far I found for
|
||||||
multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, ...).
|
multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, ...).
|
||||||
|
|
36
src/core.c
36
src/core.c
|
@ -264,6 +264,7 @@ static void SwapBuffers(void); // Copy back buffer to f
|
||||||
static void LogoAnimation(void); // Plays raylib logo appearing animation
|
static void LogoAnimation(void); // Plays raylib logo appearing animation
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||||
static void TakeScreenshot(void); // Takes a screenshot and saves it in the same folder as executable
|
static void TakeScreenshot(void); // Takes a screenshot and saves it in the same folder as executable
|
||||||
|
static void SetupViewport(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||||
|
@ -744,8 +745,7 @@ void EndTextureMode(void)
|
||||||
rlDisableRenderTexture(); // Disable render target
|
rlDisableRenderTexture(); // Disable render target
|
||||||
|
|
||||||
// Set viewport to default framebuffer size (screen size)
|
// Set viewport to default framebuffer size (screen size)
|
||||||
// TODO: consider possible viewport offsets
|
SetupViewport();
|
||||||
rlViewport(0, 0, GetScreenWidth(), GetScreenHeight());
|
|
||||||
|
|
||||||
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
|
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
|
||||||
rlLoadIdentity(); // Reset current matrix (PROJECTION)
|
rlLoadIdentity(); // Reset current matrix (PROJECTION)
|
||||||
|
@ -1776,19 +1776,8 @@ static void InitGraphicsDevice(int width, int height)
|
||||||
// NOTE: screenWidth and screenHeight not used, just stored as globals
|
// NOTE: screenWidth and screenHeight not used, just stored as globals
|
||||||
rlglInit(screenWidth, screenHeight);
|
rlglInit(screenWidth, screenHeight);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
// Setup default viewport
|
||||||
// Get framebuffer size of current window
|
SetupViewport();
|
||||||
// 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
|
// Initialize internal projection and modelview matrices
|
||||||
// NOTE: Default to orthographic projection mode with top-left corner at (0,0)
|
// NOTE: Default to orthographic projection mode with top-left corner at (0,0)
|
||||||
|
@ -1805,6 +1794,23 @@ static void InitGraphicsDevice(int width, int height)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetupViewport(void)
|
||||||
|
{
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
|
||||||
// Compute framebuffer size relative to screen size and display size
|
// Compute framebuffer size relative to screen size and display size
|
||||||
// NOTE: Global variables renderWidth/renderHeight and renderOffsetX/renderOffsetY can be modified
|
// NOTE: Global variables renderWidth/renderHeight and renderOffsetX/renderOffsetY can be modified
|
||||||
static void SetupFramebufferSize(int displayWidth, int displayHeight)
|
static void SetupFramebufferSize(int displayWidth, int displayHeight)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue