/* 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
//---------------------------------------------------------------------------
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)
}
// Pick the first returned format that will return a pbuffer
- for (int i=0;i<nConfigs;i++)
+ if (glXVersion1_3Present)
+ {
+ int pbufAttrib[] = {
+ GLX_PBUFFER_WIDTH, _iWidth,
+ GLX_PBUFFER_HEIGHT, _iHeight,
+ GLX_LARGEST_PBUFFER, False,
+ None
+ };
+ for (int i=0;i<nConfigs;i++)
+ {
+ _hPBuffer = glXCreatePbuffer(_pDisplay, fbConfigs[i], pbufAttrib);
+ if (_hPBuffer)
+ {
+ XVisualInfo *visInfo = glXGetVisualFromFBConfig(_pDisplay, fbConfigs[i]);
+
+ _hGLContext = glXCreateContext(_pDisplay, visInfo,
+ _bShareObjects ? context : NULL,
+ True);
+ XFree( visInfo );
+ break;
+ }
+ }
+ }
+ else
{
- _hPBuffer = glXCreateGLXPbufferSGIX(_pDisplay, fbConfigs[i],
- _iWidth, _iHeight, NULL);
- if (_hPBuffer)
+ int iFormat = 0;
+ int iNumFormats;
+ int attrib = 0;
+ for (int i=0;i<nConfigs;i++)
{
- _hGLContext = glXCreateContextWithConfigSGIX(_pDisplay,
- fbConfigs[i],
- GLX_RGBA_TYPE,
- _bShareObjects ? context : NULL,
- True);
- break;
+ _hPBuffer = glXCreateGLXPbufferPtr(_pDisplay, fbConfigs[i],
+ _iWidth, _iHeight, NULL);
+ if (_hPBuffer)
+ {
+ _hGLContext = glXCreateContextWithConfigPtr(_pDisplay,
+ fbConfigs[i],
+ GLX_RGBA_TYPE,
+ _bShareObjects ? context : NULL,
+ True);
+ break;
+ }
}
}
+ XFree( fbConfigs );
if (!_hPBuffer)
{
fprintf(stderr,
- "RenderTexture Error: glXCreateGLXPbufferSGIX() failed.\n");
+ "RenderTexture Error: glXCreateGLXPbufferPtr() failed.\n");
return false;
}
}
}
- glXQueryGLXPbufferSGIX(_pDisplay, _hPBuffer, GLX_WIDTH_SGIX,
- (GLuint*)&_iWidth);
- glXQueryGLXPbufferSGIX(_pDisplay, _hPBuffer, GLX_HEIGHT_SGIX,
- (GLuint*)&_iHeight);
+ if (!glXVersion1_3Present)
+ {
+ glXQueryGLXPbufferSGIXPtr(_pDisplay, _hPBuffer, GLX_WIDTH_SGIX,
+ (GLuint*)&_iWidth);
+ glXQueryGLXPbufferSGIXPtr(_pDisplay, _hPBuffer, GLX_HEIGHT_SGIX,
+ (GLuint*)&_iHeight);
+ }
_bInitialized = true;
{
return false;
}
+ if (glXVersion1_3Present)
+ {
+ GLXDrawable draw = glXGetCurrentDrawable();
+ glXQueryDrawablePtr(_pDisplay, draw, GLX_WIDTH, (unsigned int*)&_iWidth);
+ glXQueryDrawablePtr(_pDisplay, draw, GLX_HEIGHT, (unsigned int*)&_iHeight);
+ }
#endif
return result;
_iNumStencilBits = 0;
if (_bIsTexture)
- glDeleteTextures(1, (const GLuint*)&_iTextureID);
+ glDeleteTextures(1, &_iTextureID);
if (_bIsDepthTexture)
{
// [Redge]
if (!_bHasARBDepthTexture) delete[] _pPoorDepthTexture;
// [/Redge]
- glDeleteTextures(1, (const GLuint*)&_iDepthTextureID);
+ glDeleteTextures(1, &_iDepthTextureID);
}
#ifdef _WIN32
if(glXGetCurrentContext() == _hGLContext)
// XXX I don't know if this is right at all
glXMakeCurrent(_pDisplay, _hPBuffer, 0);
- glXDestroyGLXPbufferSGIX(_pDisplay, _hPBuffer);
+ glXDestroyPbufferPtr(_pDisplay, _hPBuffer);
_hPBuffer = 0;
return true;
}
// Do same basic work as _Invalidate, but don't reset all our flags
if (_bIsTexture)
- glDeleteTextures(1, (const GLuint*)&_iTextureID);
+ glDeleteTextures(1, &_iTextureID);
if (_bIsDepthTexture)
- glDeleteTextures(1, (const GLuint*)&_iDepthTextureID);
+ glDeleteTextures(1, &_iDepthTextureID);
#ifdef _WIN32
if ( _hPBuffer )
{
if(glXGetCurrentContext() == _hGLContext)
// XXX I don't know if this is right at all
glXMakeCurrent(_pDisplay, _hPBuffer, 0);
- glXDestroyGLXPbufferSGIX(_pDisplay, _hPBuffer);
+ glXDestroyPbufferPtr(_pDisplay, _hPBuffer);
_hPBuffer = 0;
}
#endif
pfAttribs.push_back(AGL_SAMPLES_ARB);
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
#else
- pfAttribs.push_back(GL_SAMPLE_BUFFERS_ARB);
+ pfAttribs.push_back(GLX_SAMPLE_BUFFERS_ARB);
pfAttribs.push_back(1);
- pfAttribs.push_back(GL_SAMPLES_ARB);
+ pfAttribs.push_back(GLX_SAMPLES_ARB);
pfAttribs.push_back(strtol(kv.second.c_str(), 0, 10));
#endif
continue;
pfAttribs.push_back(AGL_DOUBLEBUFFER);
pfAttribs.push_back(True);
#else
- pfAttribs.push_back(GL_DOUBLEBUFFER);
+ pfAttribs.push_back(GLX_DOUBLEBUFFER);
pfAttribs.push_back(True);
#endif
continue;
#elif defined( __APPLE__ )
pfAttribs.push_back(AGL_AUX_BUFFERS);
#else
- pfAttribs.push_back(GL_AUX_BUFFERS);
+ pfAttribs.push_back(GLX_AUX_BUFFERS);
#endif
if (kv.second == "")
pfAttribs.push_back(0);
}
#elif defined( __APPLE__ )
#else
- if (GL_NV_float_buffer)
+ if (GLX_NV_float_buffer)
{
pfAttribs.push_back(GLX_FLOAT_COMPONENTS_NV);
pfAttribs.push_back(1);
}
#elif defined( __APPLE__ )
#else
- if (!GLX_SGIX_pbuffer)
- {
- PrintExtensionError("GL_SGIX_pbuffer");
+
+ int minor, major;
+ _pDisplay = glXGetCurrentDisplay();
+ if (!glXQueryVersion(_pDisplay, &major, &minor))
return false;
+
+ glXVersion1_3Present = major >= 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
#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
typedef BOOL (APIENTRY * wglSetPbufferAttribARBProc) (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif
+#elif !defined(__APPLE__) /* !WIN32 */
+
+/* GLX pcific OpenGL extenstions */
+#include <GL/glx.h>
+
+#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 */