From: ehofman Date: Sat, 29 Jan 2005 11:44:01 +0000 (+0000) Subject: Windows fixes. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8ed96cad1d283ce89afa85496907afa31cc20a08;p=simgear.git Windows fixes. --- diff --git a/simgear/screen/RenderTexture.cpp b/simgear/screen/RenderTexture.cpp index bb49f308..96aeeaa3 100644 --- a/simgear/screen/RenderTexture.cpp +++ b/simgear/screen/RenderTexture.cpp @@ -1648,12 +1648,24 @@ bool RenderTexture::_VerifyExtensions() if ( !fctPtrInited ) { fctPtrInited = true; - if ( SGIsOpenGLExtensionSupported("WGL_ARB_pixel_format" ) ) + wglGetExtensionsStringARBProc wglGetExtensionsStringARBPtr = (wglGetExtensionsStringARBProc)wglGetProcAddress( "wglGetExtensionsStringARB" ); + if ( wglGetExtensionsStringARBPtr == 0 ) + { + PrintExtensionError("WGL_ARB_extensions_string"); + return false; + } + string wglExtensionsString = wglGetExtensionsStringARBPtr( wglGetCurrentDC() ); + if ( SGSearchExtensionsString( wglExtensionsString.c_str(), "WGL_ARB_pixel_format" ) ) { wglChoosePixelFormatARBPtr = (wglChoosePixelFormatARBProc)SGLookupFunction("wglChoosePixelFormatARB"); wglGetPixelFormatAttribivARBPtr = (wglGetPixelFormatAttribivARBProc)SGLookupFunction("wglGetPixelFormatAttribivARB"); } - if ( SGIsOpenGLExtensionSupported("WGL_ARB_pbuffer" ) ) + else + { + PrintExtensionError("WGL_ARB_pixel_format"); + return false; + } + if ( SGSearchExtensionsString( wglExtensionsString.c_str(), "WGL_ARB_pbuffer" ) ) { wglCreatePbufferARBPtr = (wglCreatePbufferARBProc)SGLookupFunction("wglCreatePbufferARB"); wglGetPbufferDCARBPtr = (wglGetPbufferDCARBProc)SGLookupFunction("wglGetPbufferDCARB"); @@ -1661,57 +1673,52 @@ bool RenderTexture::_VerifyExtensions() wglReleasePbufferDCARBPtr = (wglReleasePbufferDCARBProc)SGLookupFunction("wglReleasePbufferDCARB"); wglDestroyPbufferARBPtr = (wglDestroyPbufferARBProc)SGLookupFunction("wglDestroyPbufferARB"); } - if ( SGIsOpenGLExtensionSupported("WGL_ARB_render_texture" ) ) + else + { + PrintExtensionError("WGL_ARB_pbuffer"); + return false; + } + if ( SGSearchExtensionsString( wglExtensionsString.c_str(), "WGL_ARB_render_texture" ) ) { wglBindTexImageARBPtr = (wglBindTexImageARBProc)SGLookupFunction("wglBindTexImageARB"); wglReleaseTexImageARBPtr = (wglReleaseTexImageARBProc)SGLookupFunction("wglReleaseTexImageARB"); } - } - if (!WGL_ARB_pbuffer) - { - PrintExtensionError("WGL_ARB_pbuffer"); - return false; - } - if (!WGL_ARB_pixel_format) - { - PrintExtensionError("WGL_ARB_pixel_format"); - return false; - } - if (_bIsTexture && !WGL_ARB_render_texture) - { - PrintExtensionError("WGL_ARB_render_texture"); - return false; - } - if (_bRectangle && !GL_NV_texture_rectangle) - { - PrintExtensionError("GL_NV_texture_rectangle"); - return false; - } - if (_bFloat && !(GL_NV_float_buffer || WGL_ATI_pixel_format_float)) - { - PrintExtensionError("GL_NV_float_buffer or GL_ATI_pixel_format_float"); - return false; - - } - if (_bFloat && _bIsTexture && !(GL_NV_float_buffer || GL_ATI_texture_float)) - { - PrintExtensionError("NV_float_buffer or ATI_texture_float"); - } - if (_bIsDepthTexture && !GL_ARB_depth_texture) - { - // [Redge] + else if ( _bIsTexture ) + { + PrintExtensionError("WGL_ARB_render_texture"); + return false; + } + if (_bRectangle && !SGIsOpenGLExtensionSupported( "GL_NV_texture_rectangle" )) + { + PrintExtensionError("GL_NV_texture_rectangle"); + return false; + } + if (_bFloat && !(SGIsOpenGLExtensionSupported( "GL_NV_float_buffer" ) || SGSearchExtensionsString( wglExtensionsString.c_str(), "WGL_ATI_pixel_format_float" ))) + { + PrintExtensionError("GL_NV_float_buffer or GL_ATI_pixel_format_float"); + return false; + + } + if (_bFloat && _bIsTexture && !(SGIsOpenGLExtensionSupported( "GL_NV_float_buffer" ) || SGIsOpenGLExtensionSupported( "GL_ATI_texture_float" ))) + { + PrintExtensionError("NV_float_buffer or ATI_texture_float"); + } + if (_bIsDepthTexture && !SGIsOpenGLExtensionSupported( "GL_ARB_depth_texture" )) + { + // [Redge] #if defined(_DEBUG) | defined(DEBUG) - fprintf(stderr, - "RenderTexture Warning: " - "OpenGL extension GL_ARB_depth_texture not available.\n" - " Using glReadPixels() to emulate behavior.\n"); + fprintf(stderr, + "RenderTexture Warning: " + "OpenGL extension GL_ARB_depth_texture not available.\n" + " Using glReadPixels() to emulate behavior.\n"); #endif - _bHasARBDepthTexture = false; - //PrintExtensionError("GL_ARB_depth_texture"); - //return false; - // [/Redge] + _bHasARBDepthTexture = false; + //PrintExtensionError("GL_ARB_depth_texture"); + //return false; + // [/Redge] + } + SetLastError(0); } - SetLastError(0); #else if (!GLX_SGIX_pbuffer) { diff --git a/simgear/screen/TestRenderTexture.cpp b/simgear/screen/TestRenderTexture.cpp index 70d21151..8b018cb8 100644 --- a/simgear/screen/TestRenderTexture.cpp +++ b/simgear/screen/TestRenderTexture.cpp @@ -1,10 +1,18 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_WINDOWS_H +# include +#endif + #include #include SG_GL_H #include -#include #include +#include #include #include diff --git a/simgear/screen/extensions.cxx b/simgear/screen/extensions.cxx index b3a1e9f4..968b7e48 100644 --- a/simgear/screen/extensions.cxx +++ b/simgear/screen/extensions.cxx @@ -27,11 +27,11 @@ #include "extensions.hxx" #include -static bool SGSearchExtensionsString(char *extString, char *extName) { +bool SGSearchExtensionsString(const char *extString, const char *extName) { // Returns GL_TRUE if the *extName string appears in the *extString string, // surrounded by white spaces, or GL_FALSE otherwise. - char *p, *end; + const char *p, *end; int n, extNameLen; if ((extString == NULL) || (extName == NULL)) @@ -60,7 +60,7 @@ bool SGIsOpenGLExtensionSupported(char *extName) { // The *extName string must follow the OpenGL extensions naming scheme // (ie: "GL_type_extension", like GL_EXT_convolution) - return SGSearchExtensionsString((char *)glGetString(GL_EXTENSIONS),extName); + return SGSearchExtensionsString((const char *)glGetString(GL_EXTENSIONS),extName); } #ifdef __APPLE__ diff --git a/simgear/screen/extensions.hxx b/simgear/screen/extensions.hxx index 4cad70f1..46597681 100644 --- a/simgear/screen/extensions.hxx +++ b/simgear/screen/extensions.hxx @@ -49,7 +49,7 @@ extern "C" { #define APIENTRY #endif - // static bool SGSearchExtensionsString(char *extString, char *extName); +bool SGSearchExtensionsString(const char *extString, const char *extName); bool SGIsOpenGLExtensionSupported(char *extName); #ifdef __APPLE__ @@ -266,13 +266,25 @@ typedef void (APIENTRY * glClientActiveTextureProc)(GLenum texture); #endif - +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* WGL spcific OpenGL extenstions */ #ifdef WIN32 /* - * ARB_pbuffer + * WGL_ARB_extensions_string + */ +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +typedef const char * (APIENTRY * wglGetExtensionsStringARBProc) (HDC hDC); +#endif + +/* + * WGL_ARB_pbuffer */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1