I’m looking for a reliable way to make my OpenGL window full screen (that is, no window borders etc). The FAQ only mentions how to do it using GLUT, which I’m not using. I already have a full working program, so don’t really want to use GLUT just for this one feature, and would GLUT want the whole program to be structured differently anyway? I also heard GLUT doesn’t like multiple OpenGL contexts and sharing of textures etc, which would be a major drawback.
I’m on Windows, and have a couple of MFC apps where I would like to make the OpenGL CView go full screen (and back to windowed later).
What I’m doing currently almost works. In my class derived from CView, I have code something like below to go full screen. It detaches the view from its parent, makes it topMost, and resizes it to cover the screen.
WINDOWPLACEMENT wp; GetWindowPlacement(&wp); CRect desktopRect; ::GetWindowRect(::GetDesktopWindow(), desktopRect); ShowWindow(SW_HIDE); SetParent(NULL); ModifyStyle(0x0, WS_OVERLAPPED); ModifyStyleEx(WS_EX_CLIENTEDGE, 0x0); wp.showCmd = SW_RESTORE; wp.rcNormalPosition = desktopRect; CalcWindowRect(&wp.rcNormalPosition); SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); SetWindowPlacement(&wp);
Actually, it does work on my machine, but has some very strange behaviour reported on other machines. On one, there is a dashed line down the left side, a couple of pixels thick, where the expected geometry is not being drawn. In fact, it is rendering geometry from off the OTHER side of the screen (the right side). Similarly there is a few rows (not dashed) of pixels at the top that are showing what should be at the bottom. On another machine it sounds like the whole screen is flashing between old and current buffers.
On both machines it works fine in a window maximized in the usual way.
I read that the GLUT functions create a whole new OpenGL context to cover the screen, which would be slower. Is this necessary for some reason? Why not just use the context I already have?
I also read that they hide all other windows. Should I do that? Presumably I’d have to store their previous states and restore them too.
Any other advice?