use raylib standard indentation...
This commit is contained in:
parent
e014ce32c1
commit
ad2e032a25
|
|
@ -977,45 +977,46 @@ static void ErrorCallback(int error, const char *description)
|
||||||
// AdjustWindowSize
|
// AdjustWindowSize
|
||||||
static void AdjustWindowSize(int width, int height, int fbWidth, int fbHeight)
|
static void AdjustWindowSize(int width, int height, int fbWidth, int fbHeight)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_INFO, "AdjustWindowSize: %dx%d | %dx%d", width, height, fbWidth, fbHeight);
|
TRACELOG(LOG_INFO, "AdjustWindowSize: %dx%d | %dx%d", width, height, fbWidth, fbHeight);
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
|
|
||||||
AdjustFrameBufferSize(width, height);
|
AdjustFrameBufferSize(width, height);
|
||||||
|
|
||||||
emscripten_set_element_css_size("#canvas", width, height);
|
emscripten_set_element_css_size("#canvas", width, height);
|
||||||
|
|
||||||
EM_ASM({
|
EM_ASM({
|
||||||
GLFW.active.width = $0;
|
GLFW.active.width = $0;
|
||||||
GLFW.active.height = $1;
|
GLFW.active.height = $1;
|
||||||
},
|
},
|
||||||
width, height
|
width, height
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdjustFrameBufferSize
|
// AdjustFrameBufferSize
|
||||||
static void AdjustFrameBufferSize(int fbWidth, int fbHeight)
|
static void AdjustFrameBufferSize(int fbWidth, int fbHeight)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_INFO, "AdjustFrameBufferSize: %dx%d", fbWidth, fbHeight);
|
TRACELOG(LOG_INFO, "AdjustFrameBufferSize: %dx%d", fbWidth, fbHeight);
|
||||||
|
|
||||||
float scale = GetDevicePixelRatio();
|
float scale = GetDevicePixelRatio();
|
||||||
fbWidth = (int) ((float) fbWidth * scale);
|
fbWidth = (int) ((float) fbWidth * scale);
|
||||||
fbHeight = (int) ((float) fbHeight * scale);
|
fbHeight = (int) ((float) fbHeight * scale);
|
||||||
|
|
||||||
// Screen scaling matrix is required in case desired screen area is different from display area
|
// Screen scaling matrix is required in case desired screen area is different from display area
|
||||||
CORE.Window.screenScale = MatrixScale((float)fbWidth/(float)CORE.Window.screen.width, (float)fbHeight/(float)CORE.Window.screen.height, 1.0f);
|
CORE.Window.screenScale = MatrixScale((float) fbWidth / (float) CORE.Window.screen.width,
|
||||||
|
(float) fbHeight / (float) CORE.Window.screen.height, 1.0f);
|
||||||
|
|
||||||
SetMouseScale(1.0f / scale, 1.0f / scale);
|
SetMouseScale(1.0f / scale, 1.0f / scale);
|
||||||
|
|
||||||
CORE.Window.render.width = fbWidth;
|
CORE.Window.render.width = fbWidth;
|
||||||
CORE.Window.render.height = fbHeight;
|
CORE.Window.render.height = fbHeight;
|
||||||
CORE.Window.currentFbo.width = fbWidth;
|
CORE.Window.currentFbo.width = fbWidth;
|
||||||
CORE.Window.currentFbo.height = fbHeight;
|
CORE.Window.currentFbo.height = fbHeight;
|
||||||
CORE.Window.resizedLastFrame = true;
|
CORE.Window.resizedLastFrame = true;
|
||||||
|
|
||||||
emscripten_set_canvas_element_size("#canvas", fbWidth, fbHeight);
|
emscripten_set_canvas_element_size("#canvas", fbWidth, fbHeight);
|
||||||
|
|
||||||
SetupViewport(fbWidth, fbHeight);
|
SetupViewport(fbWidth, fbHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLFW3 WindowSize Callback, runs when window is resizedLastFrame
|
// GLFW3 WindowSize Callback, runs when window is resizedLastFrame
|
||||||
|
|
@ -1351,65 +1352,68 @@ void InstallModuleJSAPI()
|
||||||
// FullscreenCallback
|
// FullscreenCallback
|
||||||
void FullscreenCallback(bool isFullscreen)
|
void FullscreenCallback(bool isFullscreen)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_INFO, "FullscreenCallback(%s)", isFullscreen ? "true" : "false");
|
TRACELOG(LOG_INFO, "FullscreenCallback(%s)", isFullscreen ? "true" : "false");
|
||||||
if (isFullscreen)
|
if(isFullscreen)
|
||||||
{
|
|
||||||
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0)
|
|
||||||
{
|
{
|
||||||
if(IsHighDPIAware())
|
if((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0)
|
||||||
{
|
{
|
||||||
int screenWidth, screenHeight;
|
if(IsHighDPIAware())
|
||||||
emscripten_get_screen_size(&screenWidth, &screenHeight);
|
{
|
||||||
AdjustFrameBufferSize(screenWidth, screenWidth);
|
int screenWidth, screenHeight;
|
||||||
}
|
emscripten_get_screen_size(&screenWidth, &screenHeight);
|
||||||
|
AdjustFrameBufferSize(screenWidth, screenWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int screenWidth, screenHeight;
|
||||||
|
emscripten_get_screen_size(&screenWidth, &screenHeight);
|
||||||
|
TRACELOG(LOG_INFO, "fullscreen resizable %dx%d", screenWidth, screenHeight);
|
||||||
|
SetWindowSize(screenWidth, screenHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int screenWidth, screenHeight;
|
SetWindowSize(EM_ASM_INT(return Module.raylib.screenWidth;), EM_ASM_INT(return Module.raylib.screenHeight;));
|
||||||
emscripten_get_screen_size(&screenWidth, &screenHeight);
|
|
||||||
TRACELOG(LOG_INFO, "fullscreen resizable %dx%d", screenWidth, screenHeight);
|
|
||||||
SetWindowSize(screenWidth, screenHeight);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetWindowSize(EM_ASM_INT(return Module.raylib.screenWidth;), EM_ASM_INT(return Module.raylib.screenHeight;));
|
|
||||||
}
|
|
||||||
|
|
||||||
CORE.Window.fullscreen = isFullscreen;
|
CORE.Window.fullscreen = isFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHighDPIAware
|
// SetHighDPIAware
|
||||||
void SetHighDPIAware(bool flag)
|
void SetHighDPIAware(bool flag)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_INFO, "SetHighDPIAware(%s)", flag ? "true" : "false");
|
TRACELOG(LOG_INFO, "SetHighDPIAware(%s)", flag ? "true" : "false");
|
||||||
if (platform.isHighDPIAware != flag)
|
if(platform.isHighDPIAware != flag)
|
||||||
{
|
|
||||||
platform.isHighDPIAware = flag;
|
|
||||||
if(CORE.Window.fullscreen)
|
|
||||||
{
|
{
|
||||||
int screenWidth, screenHeight;
|
platform.isHighDPIAware = flag;
|
||||||
emscripten_get_screen_size(&screenWidth, &screenHeight);
|
if(CORE.Window.fullscreen)
|
||||||
AdjustFrameBufferSize(screenWidth, screenWidth);
|
{
|
||||||
|
int screenWidth, screenHeight;
|
||||||
|
emscripten_get_screen_size(&screenWidth, &screenHeight);
|
||||||
|
AdjustFrameBufferSize(screenWidth, screenWidth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SetWindowSize(GetScreenWidth(), GetScreenHeight());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
SetWindowSize(GetScreenWidth(), GetScreenHeight());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHighDPIAware
|
// IsHighDPIAware
|
||||||
static bool IsHighDPIAware()
|
static bool IsHighDPIAware()
|
||||||
{
|
{
|
||||||
return platform.isHighDPIAware;
|
return platform.isHighDPIAware;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDevicePixelRatio
|
// GetDevicePixelRatio
|
||||||
static float GetDevicePixelRatio()
|
static float GetDevicePixelRatio()
|
||||||
{
|
{
|
||||||
if (IsHighDPIAware())
|
if(IsHighDPIAware())
|
||||||
return (float) EM_ASM_DOUBLE({ console.log("dpr: " + devicePixelRatio); return (typeof devicePixelRatio == 'number' && devicePixelRatio) || 1.0; });
|
return (float) EM_ASM_DOUBLE({
|
||||||
else
|
console.log("dpr: " + devicePixelRatio);
|
||||||
return 1.0f;
|
return (typeof devicePixelRatio == 'number' && devicePixelRatio) || 1.0;
|
||||||
|
});
|
||||||
|
else
|
||||||
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user