aboutsummaryrefslogtreecommitdiff
path: root/samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-07-26 11:14:54 +0200
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-07-26 11:14:54 +0200
commit4842cb28522a89c0a6d800139b934001484fadbe (patch)
tree62086ddb090bb031e2677f13dfeec1a1a6b0033d /samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c
parent12c48a05b2f5c51c61ff744f419bdd85a552612c (diff)
downloadcodesamples-4842cb28522a89c0a6d800139b934001484fadbe.tar.gz
codesamples-4842cb28522a89c0a6d800139b934001484fadbe.tar.bz2
...
Diffstat (limited to 'samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c')
-rw-r--r--samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c b/samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c
index d918f0b..3c5908b 100644
--- a/samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c
+++ b/samples/OpenGL/x11argb_opengl_glsl/x11argb_opengl_glsl.c
@@ -311,16 +311,51 @@ static void createTheRenderContext()
fatalError("OpenGL not supported by X server\n");
}
- render_context = glXCreateNewContext(Xdisplay, fbconfig, GLX_RGBA_TYPE, 0, True);
- if (!render_context) {
- fatalError("Failed to create a GL context\n");
+#if USE_GLX_CREATE_CONTEXT_ATTRIB
+ #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
+ #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
+ render_context = NULL;
+ if( isExtensionSupported( glXQueryExtensionsString(Xdisplay, DefaultScreen(Xdisplay)), "GLX_ARB_create_context" ) ) {
+ typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
+ glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
+ if( glXCreateContextAttribsARB ) {
+ int context_attribs[] =
+ {
+ GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+ GLX_CONTEXT_MINOR_VERSION_ARB, 0,
+ //GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
+ None
+ };
+
+ int (*oldHandler)(Display*, XErrorEvent*) = XSetErrorHandler(&ctxErrorHandler);
+
+ render_context = glXCreateContextAttribsARB( Xdisplay, fbconfig, 0, True, context_attribs );
+
+ XSync( Xdisplay, False );
+ XSetErrorHandler( oldHandler );
+
+ fputs("glXCreateContextAttribsARB failed", stderr);
+ } else {
+ fputs("glXCreateContextAttribsARB could not be retrieved", stderr);
+ }
+ } else {
+ fputs("glXCreateContextAttribsARB not supported", stderr);
+ }
+
+ if(!render_context)
+ {
+#else
+ {
+#endif
+ render_context = glXCreateNewContext(Xdisplay, fbconfig, GLX_RGBA_TYPE, 0, True);
+ if (!render_context) {
+ fatalError("Failed to create a GL context\n");
+ }
}
if (!glXMakeContextCurrent(Xdisplay, glX_window_handle, glX_window_handle, render_context)) {
fatalError("glXMakeCurrent failed for window\n");
}
-
- glewInit();
}
static int updateTheMessageQueue()