]> git.mxchange.org Git - simgear.git/commitdiff
Windows fixes.
authorehofman <ehofman>
Sat, 29 Jan 2005 11:44:01 +0000 (11:44 +0000)
committerehofman <ehofman>
Sat, 29 Jan 2005 11:44:01 +0000 (11:44 +0000)
simgear/screen/RenderTexture.cpp
simgear/screen/TestRenderTexture.cpp
simgear/screen/extensions.cxx
simgear/screen/extensions.hxx

index bb49f308c17c0378552e67568ca088a5c461e541..96aeeaa3d46fe06fbd84671c3811f4a9840c7352 100644 (file)
@@ -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)
     {
index 70d211517ad90e424f8124e2cb7199154239f12c..8b018cb8240fafc46859b5538507ed9120939240 100644 (file)
@@ -1,10 +1,18 @@
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear/simgear_config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#  include <windows.h>
+#endif
+
 #include <simgear/compiler.h>
 
 #include SG_GL_H
 #include <GL/glut.h>
-#include <simgear/screen/RenderTexture.h>
 #include <simgear/screen/extensions.hxx>
+#include <simgear/screen/RenderTexture.h>
 
 #include <assert.h>
 #include <stdio.h>
index b3a1e9f46268e02e7b7970bd64ea6e37f26d6b14..968b7e481289b24ba0f23611427ae020dc2d754e 100644 (file)
 #include "extensions.hxx"
 #include <simgear/debug/logstream.hxx>
 
-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__
index 4cad70f176b50f15a56e5ba86a814281612b790a..46597681d8e7efc47f970d4e3ff905de3014c2b0 100644 (file)
@@ -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