From: ehofman Date: Wed, 13 Jul 2005 12:00:30 +0000 (+0000) Subject: Adjustments to better support GLX1.3 and ATI drivers. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=73cb6ff00d8ad7112cec623452fc1d2c4a523fdf;p=simgear.git Adjustments to better support GLX1.3 and ATI drivers. --- diff --git a/simgear/screen/RenderTexture.cpp b/simgear/screen/RenderTexture.cpp index 71de90ea..5a59bb9f 100644 --- a/simgear/screen/RenderTexture.cpp +++ b/simgear/screen/RenderTexture.cpp @@ -82,6 +82,18 @@ static wglDestroyPbufferARBProc wglDestroyPbufferARBPtr = 0; /* WGL_ARB_render_texture */ static wglBindTexImageARBProc wglBindTexImageARBPtr = 0; static wglReleaseTexImageARBProc wglReleaseTexImageARBPtr = 0; + +#elif defined( __APPLE__ ) +#else /* !_WIN32 */ +static bool glXVersion1_3Present = false; +static glXChooseFBConfigProc glXChooseFBConfigPtr = 0; +static glXCreateGLXPbufferProc glXCreateGLXPbufferPtr = 0; +static glXGetVisualFromFBConfigProc glXGetVisualFromFBConfigPtr = 0; +static glXCreateContextWithConfigProc glXCreateContextWithConfigPtr = 0; +static glXCreateContextProc glXCreateContextPtr = 0; +static glXDestroyPbufferProc glXDestroyPbufferPtr = 0; +static glXQueryDrawableProc glXQueryDrawablePtr = 0; +static glXQueryGLXPbufferSGIXProc glXQueryGLXPbufferSGIXPtr = 0; #endif //--------------------------------------------------------------------------- @@ -449,14 +461,10 @@ bool RenderTexture::Initialize(int width, int height, int screen = DefaultScreen(_pDisplay); XVisualInfo *visInfo; - int iFormat = 0; - int iNumFormats; - int attrib = 0; - - GLXFBConfigSGIX *fbConfigs; + GLXFBConfig *fbConfigs; int nConfigs; - fbConfigs = glXChooseFBConfigSGIX(_pDisplay, screen, + fbConfigs = glXChooseFBConfigPtr(_pDisplay, screen, &_pixelFormatAttribs[0], &nConfigs); if (nConfigs == 0 || !fbConfigs) @@ -467,25 +475,55 @@ bool RenderTexture::Initialize(int width, int height, } // Pick the first returned format that will return a pbuffer - for (int i=0;i= 1 && minor >= 3; + if (glXVersion1_3Present) + { + glXChooseFBConfigPtr = (glXChooseFBConfigProc)SGLookupFunction("glXChooseFBConfig"); + glXCreateGLXPbufferPtr = (glXCreateGLXPbufferProc)SGLookupFunction("glXCreatePbuffer"); + glXGetVisualFromFBConfigPtr = (glXGetVisualFromFBConfigProc)SGLookupFunction("glXGetVisualFromFBConfig"); + glXCreateContextPtr = (glXCreateContextProc)SGLookupFunction("glXCreateContext"); + glXDestroyPbufferPtr = (glXDestroyPbufferProc)SGLookupFunction("glXDestroyPbuffer"); + glXQueryDrawablePtr = (glXQueryDrawableProc)SGLookupFunction("glXQueryDrawable"); + + if (!glXChooseFBConfigPtr || + !glXCreateGLXPbufferPtr || + !glXGetVisualFromFBConfigPtr || + !glXCreateContextPtr || + !glXDestroyPbufferPtr || + !glXQueryDrawablePtr) + return false; } - if (!GLX_SGIX_fbconfig) + else { - PrintExtensionError("GL_SGIX_fbconfig"); - return false; + glXChooseFBConfigPtr = (glXChooseFBConfigProc)SGLookupFunction("glXChooseFBConfigSGIX"); + glXCreateGLXPbufferPtr = (glXCreateGLXPbufferProc)SGLookupFunction("glXCreateGLXPbufferSGIX"); + glXGetVisualFromFBConfigPtr = (glXGetVisualFromFBConfigProc)SGLookupFunction("glXGetVisualFromFBConfigSGIX"); + glXCreateContextWithConfigPtr = (glXCreateContextWithConfigProc)SGLookupFunction("glXCreateContextWithConfigSGIX"); + glXDestroyPbufferPtr = (glXDestroyPbufferProc)SGLookupFunction("glXDestroyGLXPbufferSGIX"); + glXQueryGLXPbufferSGIXPtr = (glXQueryGLXPbufferSGIXProc)SGLookupFunction("glXQueryGLXPbufferSGIX"); + + + if (!glXChooseFBConfigPtr || + !glXCreateGLXPbufferPtr || + !glXGetVisualFromFBConfigPtr || + !glXCreateContextWithConfigPtr || + !glXDestroyPbufferPtr || + !glXQueryGLXPbufferSGIXPtr) + return false; } + +// if (!GLX_SGIX_pbuffer) +// { +// PrintExtensionError("GL_SGIX_pbuffer"); +// return false; +// } +// if (!GLX_SGIX_fbconfig) +// { +// PrintExtensionError("GLX_SGIX_fbconfig"); +// return false; +// } if (_bIsDepthTexture && !GL_ARB_depth_texture) { PrintExtensionError("GL_ARB_depth_texture"); return false; } - if (_bFloat && _bIsTexture && !GL_NV_float_buffer) + if (_bFloat && _bIsTexture && !GLX_NV_float_buffer) { - PrintExtensionError("GL_NV_float_buffer"); + PrintExtensionError("GLX_NV_float_buffer"); return false; } if (_eUpdateMode == RT_RENDER_TO_TEXTURE) { - PrintExtensionError("Some GLX render texture extension: FIXME!"); + PrintExtensionError("Some GLX render texture extension: Please implement me!"); return false; } #endif diff --git a/simgear/screen/RenderTexture.h b/simgear/screen/RenderTexture.h index 3b823e2d..d2c9da49 100644 --- a/simgear/screen/RenderTexture.h +++ b/simgear/screen/RenderTexture.h @@ -359,8 +359,8 @@ protected: // data // Texture stuff GLenum _iTextureTarget; - unsigned int _iTextureID; - unsigned int _iDepthTextureID; + GLuint _iTextureID; + GLuint _iDepthTextureID; unsigned short* _pPoorDepthTexture; // [Redge] diff --git a/simgear/screen/extensions.cxx b/simgear/screen/extensions.cxx index 968b7e48..9a6de53b 100644 --- a/simgear/screen/extensions.cxx +++ b/simgear/screen/extensions.cxx @@ -110,6 +110,9 @@ void *SGGetGLProcAddress(const char *func) { if (libHandle == NULL) libHandle = dlopen("libGL.so", RTLD_LAZY); + if (libHandle == NULL) + libHandle = dlopen("libGL.so.1", RTLD_LAZY); + if (libHandle != NULL) { fptr = dlsym(libHandle, func); diff --git a/simgear/screen/extensions.hxx b/simgear/screen/extensions.hxx index 46597681..1c3afd60 100644 --- a/simgear/screen/extensions.hxx +++ b/simgear/screen/extensions.hxx @@ -261,9 +261,10 @@ typedef void (APIENTRY * glClientActiveTextureProc)(GLenum texture); #define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA #define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB #define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_AUX_BUFFERS 0x0C00 #define WGL_SAMPLE_BUFFERS_ARB 0x2041 #define WGL_SAMPLES_ARB 0x2042 - #endif #ifndef GL_SGIS_generate_mipmap @@ -409,6 +410,39 @@ typedef BOOL (APIENTRY * wglReleaseTexImageARBProc) (HPBUFFERARB hPbuffer, int i typedef BOOL (APIENTRY * wglSetPbufferAttribARBProc) (HPBUFFERARB hPbuffer, const int *piAttribList); #endif +#elif !defined(__APPLE__) /* !WIN32 */ + +/* GLX pcific OpenGL extenstions */ +#include + +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample1 +#define GLX_SAMPLE_BUFFERS_ARB 100001 +#define GLX_SAMPLES_ARB 100000 +#endif + +#ifndef GLX_SGIX_pbuffer +#define GLX_SGIX_pbuffer 1 +#define GLX_DOUBLEBUFFER 5 +#define GLX_AUX_BUFFERS 0x00000010 +#endif + +#ifndef GLXPbuffer +#define GLXPbuffer GLXPbufferSGIX +#endif +#ifndef GLXFBConfig +#define GLXFBConfig GLXFBConfigSGIX +#endif + +typedef GLXFBConfig *(*glXChooseFBConfigProc) (Display *dpy, int screen, int *attribList, int *nitems); +typedef GLXPbuffer (*glXCreateGLXPbufferProc) (Display *dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list); +typedef GLXPbuffer (*glXCreatePbufferProc) (Display *dpy, GLXFBConfig config, int *attrib_list); +typedef XVisualInfo *(*glXGetVisualFromFBConfigProc) (Display *dpy, GLXFBConfig config); +typedef GLXContext (*glXCreateContextWithConfigProc) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef GLXContext (*glXCreateContextProc) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); +typedef void (*glXDestroyPbufferProc) (Display *dpy, GLXPbuffer pbuf); +typedef int (*glXQueryGLXPbufferSGIXProc) (Display *, GLXPbufferSGIX, int, unsigned int *); +typedef void (*glXQueryDrawableProc) (Display *, GLXDrawable, int, unsigned int *); #endif /* WIN32 */