I have a handler in the main window callback for switching to "fake" fullscreen whenever I release the left mouse button (it doesn't do much else other than forward all other events to DefWindowProc). The fullscreen function looks like this (all the error checking has been removed to make it easier to read):
Code:
bool set_fullscreen(HWND window_handle)
{
DWORD current_window_style = GetWindowLongPtr(window_handle, GWL_STYLE);
DWORD current_extended_window_style = GetWindowLongPtr(window_handle, GWL_EXSTYLE);
HMONITOR monitor = MonitorFromWindow(window_handle, MONITOR_DEFAULTTONEAREST);
MONITORINFO monitor_info;
monitor_info.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(monitor, &monitor_info)
DWORD new_window_style = current_window_style & ~WS_OVERLAPPEDWINDOW;
SetWindowLongPtr(window_handle, GWL_STYLE, new_window_style);
DWORD new_extended_window_style = current_extended_window_style & ~(WS_EX_DLGMODALFRAME | WS_EX_OVERLAPPEDWINDOW | WS_EX_STATICEDGE);
SetWindowLongPtr(window_handle, GWL_EXSTYLE, new_extended_window_style);
SetWindowPos(window_handle,
HWND_TOP,
monitor_info.rcMonitor.left,
monitor_info.rcMonitor.top,
monitor_info.rcMonitor.right - monitor_info.rcMonitor.left,
monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
return true;
}
The window gets resized without errors but all the OpenGL calls end up getting ignored until I change the window size again. Even doing something as simple as clearing the background and then calling SwapBuffers doesn't do anything.
This is the simple draw function I'm using to test things with and it just sets the background to a certain color:
Code:
void draw(HDC device_context_handle){
if (!device_context_handle)
{
puts("Invalid argument: device_context_handle");
return;
}
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
SwapBuffers(device_context_handle);
}
I'm normally doing extensive error checking so it's not a problem with errors being ignored. Am I supposed to do something with the device context/OpenGL context after resizing the window? The strange thing is that the draw command works whenever I change the window size back to its original size.
I've had this exact same issue with both SDL and GLFW so I'm not sure if it's a problem with my computer or I just have the wrong assumptions about how things work.