X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_state.c;h=5a2f081bc6a15aff7d9e62b7bcd923ec51183616;hb=f2afa8e09dc46f89642a9cbbbc19250554c7ec5f;hp=ff375b9e00411dd4b850f15b9a0a7b3f3514d875;hpb=e9a96a71a2feff9da7ccae395c5f316e67af3bd0;p=freeglut diff --git a/src/freeglut_state.c b/src/freeglut_state.c index ff375b9..5a2f081 100644 --- a/src/freeglut_state.c +++ b/src/freeglut_state.c @@ -45,7 +45,7 @@ /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 /* * Queries the GL context about some attributes */ @@ -119,16 +119,28 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value ) } } +#if TARGET_HOST_MS_WINDOWS +/* WRONG-- FIXME */ +/* The following include file is available from SGI but is not standard: + * #include + * So we copy the necessary parts out of it to support the multisampling query + */ +#define WGL_SAMPLES_ARB 0x2042 +#endif + + /* * General settings query method */ int FGAPIENTRY glutGet( GLenum eWhat ) { -#if TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#if TARGET_HOST_MS_WINDOWS int returnValue ; GLboolean boolValue ; #endif + int nsamples = 0; + switch (eWhat) { case GLUT_INIT_STATE: @@ -154,15 +166,17 @@ int FGAPIENTRY glutGet( GLenum eWhat ) case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Y ; case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ; +#if TARGET_HOST_POSIX_X11 /* * The window/context specific queries are handled mostly by * fghGetConfig(). */ case GLUT_WINDOW_NUM_SAMPLES: - /* XXX Multisampling. Return what I know about multisampling. */ - return 0; +#ifdef GLX_VERSION_1_3 + glGetIntegerv(GL_SAMPLES, &nsamples); +#endif + return nsamples; -#if TARGET_HOST_UNIX_X11 /* * The rest of GLX queries under X are general enough to use a macro to * check them @@ -260,7 +274,15 @@ int FGAPIENTRY glutGet( GLenum eWhat ) /* I do not know yet if there will be a fgChooseVisual() function for Win32 */ case GLUT_DISPLAY_MODE_POSSIBLE: - return( fgChooseVisual() == NULL ? 0 : 1 ); + { + XVisualInfo* visualInfo = fgChooseVisual(); + if ( visualInfo == NULL ) { + return 0; + } else { + XFree( visualInfo ); + return 1; + } + } /* This is system-dependant */ case GLUT_WINDOW_FORMAT_ID: @@ -269,7 +291,11 @@ int FGAPIENTRY glutGet( GLenum eWhat ) return fgStructure.CurrentWindow->Window.VisualInfo->visualid; -#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#elif TARGET_HOST_MS_WINDOWS + + case GLUT_WINDOW_NUM_SAMPLES: + glGetIntegerv(WGL_SAMPLES_ARB, &nsamples); + return nsamples; /* Handle the OpenGL inquiries */ case GLUT_WINDOW_RGBA: @@ -361,8 +387,8 @@ int FGAPIENTRY glutGet( GLenum eWhat ) /* ...then we've got to correct the results we've just received... */ -#if !TARGET_HOST_WINCE - if ( ( fgStructure.GameMode != fgStructure.CurrentWindow ) && ( fgStructure.CurrentWindow->Parent == NULL ) && +#if !defined(_WIN32_WCE) + if ( ( fgStructure.GameModeWindow != fgStructure.CurrentWindow ) && ( fgStructure.CurrentWindow->Parent == NULL ) && ( ! fgStructure.CurrentWindow->IsMenu ) ) { winRect.left += GetSystemMetrics( SM_CXSIZEFRAME ); @@ -370,7 +396,7 @@ int FGAPIENTRY glutGet( GLenum eWhat ) winRect.top += GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ); winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME ); } -#endif /* !TARGET_HOST_WINCE */ +#endif /* !defined(_WIN32_WCE) */ switch( eWhat ) { @@ -383,33 +409,33 @@ int FGAPIENTRY glutGet( GLenum eWhat ) break; case GLUT_WINDOW_BORDER_WIDTH : -#if TARGET_HOST_WINCE +#if defined(_WIN32_WCE) return 0; #else return GetSystemMetrics( SM_CXSIZEFRAME ); -#endif /* !TARGET_HOST_WINCE */ +#endif /* !defined(_WIN32_WCE) */ case GLUT_WINDOW_HEADER_HEIGHT : -#if TARGET_HOST_WINCE +#if defined(_WIN32_WCE) return 0; #else return GetSystemMetrics( SM_CYCAPTION ); -#endif /* TARGET_HOST_WINCE */ +#endif /* defined(_WIN32_WCE) */ case GLUT_DISPLAY_MODE_POSSIBLE: -#if TARGET_HOST_WINCE +#if defined(_WIN32_WCE) return GL_FALSE; #else return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE, PFD_MAIN_PLANE ); -#endif /* TARGET_HOST_WINCE */ +#endif /* defined(_WIN32_WCE) */ case GLUT_WINDOW_FORMAT_ID: -#if !TARGET_HOST_WINCE +#if !defined(_WIN32_WCE) if( fgStructure.CurrentWindow != NULL ) return GetPixelFormat( fgStructure.CurrentWindow->Window.Device ); -#endif /* TARGET_HOST_WINCE */ +#endif /* defined(_WIN32_WCE) */ return 0; #endif @@ -478,7 +504,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat ) */ return TRUE ; -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 case GLUT_HAS_MOUSE: return TRUE ; @@ -505,7 +531,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat ) */ return 3 ; -#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#elif TARGET_HOST_MS_WINDOWS case GLUT_HAS_MOUSE: /* @@ -516,11 +542,11 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat ) case GLUT_NUM_MOUSE_BUTTONS: /* We are much more fortunate under Win32 about this... */ -#if TARGET_HOST_WINCE +#if defined(_WIN32_WCE) return 1; #else return GetSystemMetrics( SM_CMOUSEBUTTONS ); -#endif /* TARGET_HOST_WINCE */ +#endif /* defined(_WIN32_WCE) */ #endif @@ -604,7 +630,7 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat ) switch( eWhat ) { -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 case GLUT_OVERLAY_POSSIBLE: return FALSE; @@ -630,7 +656,7 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat ) case GLUT_OVERLAY_DAMAGED: return -1; -#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#elif TARGET_HOST_MS_WINDOWS case GLUT_OVERLAY_POSSIBLE: /* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,