require GLX 1.4
[gltest.git] / glxbackend.cpp
index e40e90c5ba99dd23ad193a3e715f1e5e19c08d7b..d636f677fc29b75e11236a436bf998344510163b 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <stdio.h>
 #include <assert.h>
 
 #include <stdio.h>
 #include <assert.h>
-#include <stdlib.h>
 #include <GL/glxext.h>
 #include <string>
 
 #include <GL/glxext.h>
 #include <string>
 
@@ -59,10 +58,9 @@ VisualID GLXBackend::initialize(Display *display)
                int glxMajor, glxMinor;
                glXQueryVersion(display, &glxMajor, &glxMinor);
                printf("Using GLX version: %d.%d\n", glxMajor, glxMinor);
                int glxMajor, glxMinor;
                glXQueryVersion(display, &glxMajor, &glxMinor);
                printf("Using GLX version: %d.%d\n", glxMajor, glxMinor);
-               if (glxMajor < 1 || (glxMajor == 1 && glxMinor < 3)) {
-                       // glXChooseFBConfig and glXCreateNewContext require GLX 1.3
-                       fprintf(stderr, "Need at least GLX 1.3 to function properly\n");
-                       exit(1);
+               if (glxMajor == 1 && glxMinor < 4) {
+                       // glXChooseFBConfig and glXCreateNewContext require GLX 1.3; GLX_ARB_create_context requires GLX 1.4
+                       die("Need at least GLX 1.4 to function properly\n");
                }
                // check for extension-based functions
                funSwapIntervalMesa = (PFNGLXSWAPINTERVALMESAPROC)resolveGLXFunction("GLX_MESA_swap_control", "glXSwapIntervalMESA");
                }
                // check for extension-based functions
                funSwapIntervalMesa = (PFNGLXSWAPINTERVALMESAPROC)resolveGLXFunction("GLX_MESA_swap_control", "glXSwapIntervalMESA");
@@ -72,8 +70,7 @@ VisualID GLXBackend::initialize(Display *display)
                int count = 0;
                GLXFBConfig *configs = glXChooseFBConfig(display, DefaultScreen(display), configAttribs, &count);
                if (count < 1) {
                int count = 0;
                GLXFBConfig *configs = glXChooseFBConfig(display, DefaultScreen(display), configAttribs, &count);
                if (count < 1) {
-                       fprintf(stderr, "Failed to choose framebuffer configuration\n");
-                       exit(1);
+                       die("Failed to choose framebuffer configuration\n");
                }
                config = configs[0];
                XFree(configs);
                }
                config = configs[0];
                XFree(configs);
@@ -110,14 +107,12 @@ void GLXBackend::createContext(Window window)
        context = glXCreateNewContext(display, config, GLX_RGBA_TYPE, NULL, GL_TRUE);
 #else
        if (!funCreateContextAttribsARB) {
        context = glXCreateNewContext(display, config, GLX_RGBA_TYPE, NULL, GL_TRUE);
 #else
        if (!funCreateContextAttribsARB) {
-               fprintf(stderr, "Cannot create GL3 context: GLX_ARB_create_context not supported\n");
-               exit(1);
+               die("Cannot create GL3 context: GLX_ARB_create_context not supported\n");
        }
        context = funCreateContextAttribsARB(display, config, NULL, GL_TRUE, contextAttribs);
 #endif
        if (!context) {
        }
        context = funCreateContextAttribsARB(display, config, NULL, GL_TRUE, contextAttribs);
 #endif
        if (!context) {
-               fprintf(stderr, "Error creating context\n");
-               exit(1);
+               die("Error creating context\n");
        }
        glXMakeCurrent(display, window, context);                                      
        assert(glXIsDirect(display, context));
        }
        glXMakeCurrent(display, window, context);                                      
        assert(glXIsDirect(display, context));
@@ -147,8 +142,7 @@ void GLXBackend::setSwapInterval(int i) const
        assert(context != None);
        // check if swap interval value is supported
        if (i < 0) {
        assert(context != None);
        // check if swap interval value is supported
        if (i < 0) {
-               fprintf(stderr, "Cannot set swap interval to %d, must not be negative\n", i);
-               exit(1);
+               die("Cannot set swap interval to %d, must not be negative\n", i);
        }
        // set it
        if (funSwapIntervalExt)
        }
        // set it
        if (funSwapIntervalExt)
@@ -156,7 +150,6 @@ void GLXBackend::setSwapInterval(int i) const
        else if (funSwapIntervalMesa)
                funSwapIntervalMesa(i);
        else {
        else if (funSwapIntervalMesa)
                funSwapIntervalMesa(i);
        else {
-               fprintf(stderr, "At least one of GLX_EXT_swap_control, GLX_MESA_swap_control must be supported by the system\n");
-               abort();
+               die("At least one of GLX_EXT_swap_control, GLX_MESA_swap_control must be supported by the system\n");
        }
 }
        }
 }