#if TARGET_HOST_POSIX_X11
#include <limits.h> /* LONG_MAX */
+#include <unistd.h> /* usleep */
#endif
#if defined(_WIN32_WCE)
ppfd->cGreenShift = 0;
ppfd->cBlueShift = 0;
ppfd->cAlphaShift = 0;
- ppfd->cAccumBits = 0;
+ ppfd->cAccumBits = ( fgState.DisplayMode & GLUT_ACCUM ) ? 1 : 0;
ppfd->cAccumRedBits = 0;
ppfd->cAccumGreenBits = 0;
ppfd->cAccumBlueBits = 0;
PIXELFORMATDESCRIPTOR pfd;
PIXELFORMATDESCRIPTOR* ppfd = &pfd;
int pixelformat;
+ HDC current_hDC;
+ GLboolean success;
- fghFillPFD( ppfd, window->Window.Device, layer_type );
- pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
+ if (checkOnly)
+ current_hDC = CreateDC(TEXT("DISPLAY"), NULL ,NULL ,NULL);
+ else
+ current_hDC = window->Window.Device;
+
+ fghFillPFD( ppfd, current_hDC, layer_type );
+ pixelformat = ChoosePixelFormat( current_hDC, ppfd );
/* windows hack for multismapling/sRGB */
if ( ( fgState.DisplayMode & GLUT_MULTISAMPLE ) ||
hWnd=CreateWindow(_T("FREEGLUT_dummy"), _T(""), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW , 0,0,0,0, 0, 0, fgDisplay.Instance, 0 );
hDC=GetDC(hWnd);
SetPixelFormat( hDC, pixelformat, ppfd );
-
+
rc = wglCreateContext( hDC );
wglMakeCurrent(hDC, rc);
-
+
if ( fghIsExtensionSupported( hDC, "WGL_ARB_multisample" ) )
{
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARBProc =
float fAttributes[] = { 0, 0 };
UINT numFormats;
fghFillPixelFormatAttributes( attributes, ppfd );
- bValid = wglChoosePixelFormatARBProc(window->Window.Device, attributes, fAttributes, 1, &iPixelFormat, &numFormats);
+ bValid = wglChoosePixelFormatARBProc(hDC, attributes, fAttributes, 1, &iPixelFormat, &numFormats);
if ( bValid && numFormats > 0 )
{
UnregisterClass(_T("FREEGLUT_dummy"), fgDisplay.Instance);
}
- return ( pixelformat != 0 ) && ( checkOnly || SetPixelFormat( window->Window.Device, pixelformat, ppfd ) );
+ success = ( pixelformat != 0 ) && ( checkOnly || SetPixelFormat( current_hDC, pixelformat, ppfd ) );
+
+ if (checkOnly)
+ DeleteDC(current_hDC);
+
+ return success;
#endif /* defined(_WIN32_WCE) */
}
#endif
+#if TARGET_HOST_POSIX_X11
+static Bool fghWindowIsVisible( Display *display, XEvent *event, XPointer arg)
+{
+ Window window = arg;
+ return (event->type == MapNotify) && (event->xmap.window == window);
+}
+#endif
+
/*
* Opens a window. Requires a SFG_Window object created and attached
XTextProperty textProperty;
XSizeHints sizeHints;
XWMHints wmHints;
+ XEvent eventReturnBuffer; /* return buffer required for a call */
unsigned long mask;
int num_FBConfigs, i;
unsigned int current_DisplayMode = fgState.DisplayMode ;
XFree(visualInfo);
+ if( !isSubWindow)
+ XPeekIfEvent( fgDisplay.Display, &eventReturnBuffer, &fghWindowIsVisible, window->Window.Handle );
+
#elif TARGET_HOST_MS_WINDOWS
WNDCLASS wc;
*/
void fgCloseWindow( SFG_Window* window )
{
+ /* if we're in gamemode, call glutLeaveGameMode first to make sure the
+ * gamemode is properly closed before closing the window
+ */
+ if (fgStructure.GameModeWindow != NULL)
+ glutLeaveGameMode();
+
#if TARGET_HOST_POSIX_X11
if( window->Window.Context )