temp stash, macos fixes for pixelratio
This commit is contained in:
parent
0671639faa
commit
2de4454e79
|
|
@ -764,10 +764,32 @@ void SetWindowMaxSize(int width, int height)
|
||||||
// Set window dimensions
|
// Set window dimensions
|
||||||
void SetWindowSize(int width, int height)
|
void SetWindowSize(int width, int height)
|
||||||
{
|
{
|
||||||
CORE.Window.screen.width = width;
|
printf("SetWindowSize 1\n");
|
||||||
CORE.Window.screen.height = height;
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = width;
|
||||||
|
CORE.Window.screen.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGFW_window_resize(platform.window, CORE.Window.screen.width, CORE.Window.screen.height);
|
||||||
|
// printf("SetWindowSize 3\n");
|
||||||
|
|
||||||
RGFW_window_resize(platform.window, width, height);
|
// if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)) {
|
||||||
|
// #if defined(__APPLE__)
|
||||||
|
// Vector2 scaleDpi = GetWindowScaleDPI();
|
||||||
|
// CORE.Window.screenScale = MatrixScale(2.0f, 2.0f, 1.0f);
|
||||||
|
|
||||||
|
// CORE.Window.render.width = CORE.Window.screen.width * 2;
|
||||||
|
// CORE.Window.render.height = CORE.Window.screen.height * 2;
|
||||||
|
// CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||||
|
// CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||||
|
// #endif
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||||
|
|
@ -901,7 +923,21 @@ Vector2 GetWindowScaleDPI(void)
|
||||||
if (platform.window) monitor = RGFW_window_getMonitor(platform.window);
|
if (platform.window) monitor = RGFW_window_getMonitor(platform.window);
|
||||||
else monitor = RGFW_getPrimaryMonitor();
|
else monitor = RGFW_getPrimaryMonitor();
|
||||||
|
|
||||||
return (Vector2){ monitor->scaleX, monitor->scaleX };
|
#if defined(__APPLE__)
|
||||||
|
return (Vector2){ 1.0f / monitor->scaleX, 1.0f / monitor->scaleX };
|
||||||
|
#else
|
||||||
|
return (Vector2){ monitor->scaleX, monitor->scaleX };
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetMonitorPixelRatio(void)
|
||||||
|
{
|
||||||
|
RGFW_monitor *monitor = NULL;
|
||||||
|
|
||||||
|
if (platform.window) monitor = RGFW_window_getMonitor(platform.window);
|
||||||
|
else monitor = RGFW_getPrimaryMonitor();
|
||||||
|
|
||||||
|
return monitor->pixelRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set clipboard text content
|
// Set clipboard text content
|
||||||
|
|
@ -1179,22 +1215,45 @@ void PollInputEvents(void)
|
||||||
// Window events are also polled (Minimized, maximized, close...)
|
// Window events are also polled (Minimized, maximized, close...)
|
||||||
case RGFW_windowResized:
|
case RGFW_windowResized:
|
||||||
{
|
{
|
||||||
SetupViewport(platform.window->w, platform.window->h);
|
#if defined(__APPLE__)
|
||||||
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
SetupViewport(platform.window->w * platform.monitor->pixelRatio, platform.window->h * platform.monitor->pixelRatio);
|
||||||
|
CORE.Window.screenScale = MatrixScale(platform.monitor->pixelRatio, platform.monitor->pixelRatio, 1.0f);
|
||||||
|
|
||||||
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
CORE.Window.screen.width = platform.window->w;
|
||||||
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
CORE.Window.screen.height = platform.window->h;
|
||||||
{
|
CORE.Window.render.width = CORE.Window.screen.width * platform.monitor->pixelRatio;
|
||||||
CORE.Window.screen.width = (int)(platform.window->w/GetWindowScaleDPI().x);
|
CORE.Window.render.height = CORE.Window.screen.height * platform.monitor->pixelRatio;
|
||||||
CORE.Window.screen.height = (int)(platform.window->h/GetWindowScaleDPI().y);
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
SetupViewport(platform.window->w, platform.window->h);
|
||||||
CORE.Window.screen.width = platform.window->w;
|
CORE.Window.screen.width = platform.window->w;
|
||||||
CORE.Window.screen.height = platform.window->h;
|
CORE.Window.screen.height = platform.window->h;
|
||||||
}
|
CORE.Window.render.width = CORE.Window.screen.width;
|
||||||
|
CORE.Window.render.height = CORE.Window.screen.height;
|
||||||
|
}
|
||||||
|
|
||||||
CORE.Window.currentFbo.width = platform.window->w;
|
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||||
CORE.Window.currentFbo.height = platform.window->h;
|
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||||
|
#else
|
||||||
|
SetupViewport(platform.window->w, platform.window->h);
|
||||||
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = (int)(platform.window->w/GetWindowScaleDPI().x);
|
||||||
|
CORE.Window.screen.height = (int)(platform.window->h/GetWindowScaleDPI().y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = platform.window->w;
|
||||||
|
CORE.Window.screen.height = platform.window->h;
|
||||||
|
}
|
||||||
|
|
||||||
|
CORE.Window.currentFbo.width = platform.window->w;
|
||||||
|
CORE.Window.currentFbo.height = platform.window->h;
|
||||||
|
#endif
|
||||||
CORE.Window.resizedLastFrame = true;
|
CORE.Window.resizedLastFrame = true;
|
||||||
} break;
|
} break;
|
||||||
case RGFW_windowMaximized:
|
case RGFW_windowMaximized:
|
||||||
|
|
@ -1460,8 +1519,15 @@ int InitPlatform(void)
|
||||||
|
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||||
{
|
{
|
||||||
CORE.Window.screen.width = CORE.Window.screen.width * GetWindowScaleDPI().x;
|
#if defined(__APPLE__)
|
||||||
CORE.Window.screen.height = CORE.Window.screen.height * GetWindowScaleDPI().y;
|
// // apple is 0.66, 0.5, etc
|
||||||
|
// CORE.Window.screen.width = CORE.Window.screen.width / GetWindowScaleDPI().x;
|
||||||
|
// CORE.Window.screen.height = CORE.Window.screen.height / GetWindowScaleDPI().y;
|
||||||
|
#else
|
||||||
|
// // other platforms are 1.5, 2.0, etc
|
||||||
|
CORE.Window.screen.width = CORE.Window.screen.width * GetWindowScaleDPI().x;
|
||||||
|
CORE.Window.screen.height = CORE.Window.screen.height * GetWindowScaleDPI().y;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RGFW_setGlobalHints_OpenGL(hints);
|
RGFW_setGlobalHints_OpenGL(hints);
|
||||||
|
|
@ -1500,6 +1566,7 @@ int InitPlatform(void)
|
||||||
// must be set to NULL to not interfere
|
// must be set to NULL to not interfere
|
||||||
RGFW_window_setExitKey(platform.window, RGFW_keyNULL);
|
RGFW_window_setExitKey(platform.window, RGFW_keyNULL);
|
||||||
RGFW_window_makeCurrentWindow_OpenGL(platform.window);
|
RGFW_window_makeCurrentWindow_OpenGL(platform.window);
|
||||||
|
platform.monitor = RGFW_window_getMonitor(platform.window);
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -1515,11 +1582,19 @@ int InitPlatform(void)
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)) {
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)) {
|
||||||
Vector2 scaleDpi = GetWindowScaleDPI();
|
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||||
|
|
||||||
SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
|
#if defined(__APPLE__)
|
||||||
|
CORE.Window.screenScale = MatrixScale(platform.monitor->pixelRatio, platform.monitor->pixelRatio, 1.0f);
|
||||||
|
|
||||||
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
|
CORE.Window.render.width = CORE.Window.screen.width * platform.monitor->pixelRatio;
|
||||||
CORE.Window.screen.width /= scaleDpi.x;
|
CORE.Window.render.height = CORE.Window.screen.height * platform.monitor->pixelRatio;
|
||||||
CORE.Window.screen.height /= scaleDpi.y;
|
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||||
|
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||||
|
#else
|
||||||
|
SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
|
||||||
|
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
|
||||||
|
CORE.Window.screen.width /= scaleDpi.x;
|
||||||
|
CORE.Window.screen.height /= scaleDpi.y;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
|
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user