Jump to content
  • Advertisement
Sign in to follow this  
__SKYe

Win32/OpenGL Fullscreen

This topic is 2440 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, i have this little program showing a simple window in Win32 / OpenGL.

It only shows a triangle, and can go fullscreen by pressing ALT+TAB.
I have the following code for going (and returning from) fullscreen (it's identical to nehe's code, i think...)

void Window::ToggleFullscreen()
{
fullscreen = !fullscreen;

if(fullscreen == true) // Going fullscreen
{

RECT rect;

GetWindowRect(windowInst, &rect);
posX = rect.left;
posY = rect.top;

SetWindowLong(windowInst, GWL_EXSTYLE, 0);
SetWindowLong(windowInst, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
SetWindowPos(windowInst, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);

SetWindowPos(windowInst, HWND_TOPMOST, 0, 0, fsWidth, fsHeight, SWP_SHOWWINDOW);

ShowCursor(false);

DEVMODE dm;

dm.dmSize = sizeof(DEVMODE);
dm.dmPelsWidth = fsWidth;
dm.dmPelsHeight = fsHeight;
dm.dmBitsPerPel = bpp;
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;

ChangeDisplaySettings(&dm, 0);
}
else //Going to Window
{
DWORD EX_STYLE = WS_EX_OVERLAPPEDWINDOW;
DWORD STYLE = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

ChangeDisplaySettings(0, 0);

SetWindowLong(windowInst, GWL_EXSTYLE, EX_STYLE);
SetWindowLong(windowInst, GWL_STYLE, STYLE);
SetWindowPos(windowInst, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);

SetWindowPos(windowInst, HWND_NOTOPMOST, posX, posY, width, height, SWP_SHOWWINDOW);

ShowCursor(true);
}
}



note:
The width and height vars, are obviously the window width and height, the fsWidth and fsHeight, are the size of the window when in fullscreen (if you want 2 different resolution for window and fullscreen

The problem is that if i have a 300x300 window and a fullscreen resolution of my desktop resolution (eg. 1280x800), and press ALT+TAB, the screen does indeed change resolution (and shows the triangle, and everything is fine), but if that triangle is the size of the window (300x300), when in fulscreen it will continue to be as big as the screen (even tough the fullscreen resolution is much higher, and the triangle should appear small in a corner).

I hope you can understand the problem, and sorry for the maybe-not-very-clear question.

Also, if you need more code, i'm certainly capable of providing it...

Thanks in advance

EDIT: So sorry for wating your time...

The problem is that while the onResize gl function worked properly, the glOrtho and gluPerspective on the onDraw function were using the windowed resolution.

Once again sorry, and if someone feels the need to delete this thread, please do so.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!