Information Technology Knowledge Base

August 7, 2006

Switching to fullscreen in OpenGL (MS windows)

Filed under: OpenGL — Wim V @ 9:51 pm

Switching between windowed mode and fullscreen is usually done by creating a new window just to change the window style. There is however an easier way to change the style without creating a new window.

//Remove the window decoration.
LONG dwStyle = GetWindowLong(hWnd, GWL_STYLE) ^ WS_OVERLAPPEDWINDOW;

//Add back the window decoration.
LONG dwStyle = GetWindowLong(hWnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW;

//Set the selected style.
SetWindowLong(hWnd, GWL_STYLE, dwStyle);

//Redraw your window.
SetWindowPos(hWnd, HWND_TOP, x, y, width, height, SWP_FRAMECHANGED);

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress