1 Reply Latest reply on May 19, 2014 8:18 AM by chm

    Problem switching Windows OpenGL app to full-screen mode

    Myrmecophagavir

      I have an OpenGL app which currently starts in windowed mode. The window style is initially WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS. From what I understand, the way to switch to full-screen mode in OpenGL apps on Windows is to call ChangeDisplaySettings, change the window style to remove the border etc. and move it the window to cover (0,0) - (width, height). However, when I do this all GL rendering stops. I've tried rearranging the order of calls, and noted that the docs mention you need to call SetWindowPos after changing window style for it to take effect. In fact, everything works OK unless I reposition the window to cover the screen. Calling SetWindowPos with SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED works fine, except the window isn't covering the screen; calling it without SWP_NOMOVE and SWP_NOSIZE, and specifying the screen area to cover, breaks things. The app keeps working, but nothing further renders. What am I doing wrong here?

        • Re: Problem switching Windows OpenGL app to full-screen mode
          chm

          I think you can swicth to full screen without calling ChangeDisplaySettings. Can you try something like this:


                  MONITORINFO mi = { sizeof(mi) };
                  if (GetMonitorInfo(MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY), &mi))
                  {
                      SetWindowLong(hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
                      SetWindowPos(hWnd, HWND_TOP,
                          mi.rcMonitor.left, mi.rcMonitor.top,
                          mi.rcMonitor.right - mi.rcMonitor.left,
                          mi.rcMonitor.bottom - mi.rcMonitor.top,
                          SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
                  }

           

          Chris