开发者

Modal dialogs opened by a fullscreen OpenGL window on Windows 7 are not showing

开发者 https://www.devze.com 2022-12-21 18:43 出处:网络
It seems that my problem may be the same as an unanswered related question (OpenGL with GLUT on windows 7, fullscreen mode not showing the message box).

It seems that my problem may be the same as an unanswered related question (OpenGL with GLUT on windows 7, fullscreen mode not showing the message box).

Since I switched to Win7 as a development environment, and a p开发者_如何学Pythonossible target platform for my applications, I noticed a regression in their behaviour.

Whenever I have a fullscreen window containing a fullscreen OpenGL context, the applications have problems displaying modal dialog boxes (such as message boxes, file open dialog, etc.)

The window is just created with WS_POPUP style. The GL context is nothing fancy. And everything is fine with Windows XP.

The problem under Windows 7 is that the modal dialog boxes are invisible at their opening (maybe their appear behind the full screen window). You have to Alt-Tab the application to have the dialogs appear.

This is a major problem as the application appears to be frozen, while it in fact waits for user input.

Did anyone encounter this behaviour ? Does anyone know a workaround ?

I've quickly made up a sample test application ; its source code can be found at http://pastebin.com/K4v2NNDs. A simple MSVC8 project can be found here.

PS. I've also posted on opengl.org forums, sorry for those of you that follow both.

EDIT

Thanks to Chris comment, I've tested the modal dialog on various events, such as WM_TIMER or WM_RBUTTONUP, but the problem is still there.

I've also called 'DwmEnableComposition' with 'DWM_EC_DISABLECOMPOSITION' just to check : problem still there.

I've also tested the application by replacing the OpenGL bits by DirectX, and this way everything works as expected... It's really OpenGL causing the problem.

(updated pastebin http://pastebin.com/Rq1Ehm3w and my scratchpad)

EDIT

The problem also exists on Windows 8.


A workaround has been posted on opengl.org by Joseph Steel, so, for reference I put it here as well :

The solution I found for this problem was to ensure that the pixel format for the window uses the WGL_SWAP_COPY_ARB swap method rather than the WGL_SWAP_EXCHANGE_ARB.

I've noted that one must use 'wglChoosePixelFormatARB' to obtain the pixel format.

I tried with the classic 'ChoosePixelFormat' with the 'PFD_SWAP_COPY' flag, but it does not work on my system (Win7 x64 + NVidia GeFo 9600GT v196.21) as it always returns me a pixel format with 'PFD_SWAP_EXCHANGE' instead.

I'm only half-happy with the results, as it introduces some tearing in my display, but as least it works !

For reference, I've updated my test source code.

EDIT, dec.2013

This workaround does not work anymore, at least on my system (laptop, Optimus GeForce 650M). The WGL_SWAP_COPY_ARB is setup but the modal dialog does not show. So far, it seems that creating the window with a 1 pixel border (adding WS_BORDER to WS_POPUP style) does the trick, and prevents entering 'fullscreen' mode.


Solution on my system was pretty simple: - DO NOT specify WS_POPUP style at the window creation time. - Just after you obtain hwnd, re-set your windows styles to what you want (but no WS_POPUP again) using SetWindowLong(hwnd,GWL_STYLE, yr_styles);


I had the same problem with OpenGL under Win7 64 bit. Modal dialog boxes and modal windows are not shown, also they are active in the background. My project used stereo display (quad buffers). In my case, the problem was due to an incorrect setting in the control panel of the display adapter (Nvidia Quadro FX3800). The setting was "Stereo Enabled", which was incorrectly on "off". Switching it on solved the problem.


when i want, for example, open a filedialog in OpenGL fullscreen (Windows10 or every Windows before), i call

RedrawWindow(hwnd, 0, 0, RDW_INTERNALPAINT);

( this causes a WM_PAINT message to be posted to the window regardless of whether any portion of the window is invalid )

and just after this i call the filedialog. The filedialog will be shown now in OpenGL fullscreen.

In WndProc inside the case WM_PAINT: i do a SwapBuffers(hdc)

RedrawWindow(hwnd, 0, 0, RDW_INTERNALPAINT);
// important when fullscreen; forces a WM_PAINT message,
GLwin->Fileselect(s_fname); // or whatever dialog

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lparam)
{
  switch(message)
  {
    case WM_PAINT:
    SwapBuffers(hdc);  // (same as in the render-loop)
    break;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号