REVIEWED: ToggleFullscreen()
This commit is contained in:
parent
015a71fc40
commit
47d768c3d6
1 changed files with 12 additions and 12 deletions
20
src/rcore.c
20
src/rcore.c
|
@ -1175,39 +1175,39 @@ bool IsWindowState(unsigned int flag)
|
||||||
void ToggleFullscreen(void)
|
void ToggleFullscreen(void)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
// NOTE: glfwSetWindowMonitor() doesn't work properly (bugs)
|
// TODO: glfwSetWindowMonitor() doesn't work properly (bugs)
|
||||||
if (!CORE.Window.fullscreen)
|
if (!CORE.Window.fullscreen)
|
||||||
{
|
{
|
||||||
// Store previous window position (in case we exit fullscreen)
|
// Store previous window position (in case we exit fullscreen)
|
||||||
glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y);
|
glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y);
|
||||||
|
|
||||||
int monitorCount = 0;
|
int monitorCount = 0;
|
||||||
|
int monitorIndex = GetCurrentMonitor();
|
||||||
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
||||||
|
|
||||||
int monitorIndex = GetCurrentMonitor();
|
|
||||||
|
|
||||||
// Use current monitor, so we correctly get the display the window is on
|
// Use current monitor, so we correctly get the display the window is on
|
||||||
GLFWmonitor* monitor = monitorIndex < monitorCount ? monitors[monitorIndex] : NULL;
|
GLFWmonitor *monitor = (monitorIndex < monitorCount)? monitors[monitorIndex] : NULL;
|
||||||
|
|
||||||
if (!monitor)
|
if (monitor == NULL)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor");
|
TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor");
|
||||||
|
|
||||||
CORE.Window.fullscreen = false; // Toggle fullscreen flag
|
CORE.Window.fullscreen = false;
|
||||||
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
|
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
|
||||||
|
|
||||||
glfwSetWindowMonitor(CORE.Window.handle, NULL, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
|
glfwSetWindowMonitor(CORE.Window.handle, NULL, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
CORE.Window.fullscreen = true; // Toggle fullscreen flag
|
{
|
||||||
|
CORE.Window.fullscreen = true;
|
||||||
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
|
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
|
||||||
|
|
||||||
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
|
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CORE.Window.fullscreen = false; // Toggle fullscreen flag
|
CORE.Window.fullscreen = false;
|
||||||
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
|
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
|
||||||
|
|
||||||
glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
|
glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue