Set window high DPI flag in InitWindow. Fix rlScissor call, for Scissor mode, for high DPI screens.
This commit is contained in:
parent
6342cf103a
commit
e274d8614d
13
src/rcore.c
13
src/rcore.c
|
|
@ -601,6 +601,8 @@ static bool InitGraphicsDevice(int width, int height); // Initialize graphics d
|
|||
static void SetupFramebuffer(int width, int height); // Setup main framebuffer
|
||||
static void SetupViewport(int width, int height); // Set viewport for a provided width and height
|
||||
|
||||
static void SetHighDPIFromWindowScale(void); // Helper function to set window high DPI flag from window scale
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error
|
||||
// Window callbacks events
|
||||
|
|
@ -805,6 +807,7 @@ void InitWindow(int width, int height, const char *title)
|
|||
SetShapesTexture(texture, (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f });
|
||||
#endif
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
SetHighDPIFromWindowScale();
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0)
|
||||
{
|
||||
// Set default font texture filter for HighDPI (blurry)
|
||||
|
|
@ -1454,6 +1457,13 @@ void ClearWindowState(unsigned int flags)
|
|||
#endif
|
||||
}
|
||||
|
||||
// Helper function to set window high DPI flag from window scale
|
||||
void SetHighDPIFromWindowScale()
|
||||
{
|
||||
Vector2 scale = GetWindowScaleDPI();
|
||||
if (scale.x > 1 || scale.y > 1) SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||
}
|
||||
|
||||
// Set icon for window (only PLATFORM_DESKTOP)
|
||||
// NOTE: Image must be in RGBA format, 8bit per channel
|
||||
void SetWindowIcon(Image image)
|
||||
|
|
@ -2188,7 +2198,8 @@ void BeginScissorMode(int x, int y, int width, int height)
|
|||
{
|
||||
Vector2 scale = GetWindowScaleDPI();
|
||||
|
||||
rlScissor((int)(x*scale.x), (int)(CORE.Window.currentFbo.height - (y + height)*scale.y), (int)(width*scale.x), (int)(height*scale.y));
|
||||
rlScissor((int)(x*scale.x), (int)(CORE.Window.currentFbo.height - y*scale.y - height/scale.y),
|
||||
(int)(width*scale.x), (int)(height*scale.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user