Windows fixes.

This commit is contained in:
ehofman 2005-01-29 11:44:01 +00:00
parent 7795eb8239
commit 8ed96cad1d
4 changed files with 80 additions and 53 deletions

View 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)
{

View 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>

View File

@ -27,11 +27,11 @@
#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__

View 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