- if (this->display == NULL) { // this implies that the context is also unitialized
- this->display = display;
- // debugging: show version information
- int glxMajor, glxMinor;
- glXQueryVersion(display, &glxMajor, &glxMinor);
- printf("Using GLX version: %d.%d\n", glxMajor, glxMinor);
- 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");
- funSwapIntervalExt = (PFNGLXSWAPINTERVALEXTPROC)resolveGLXFunction("GLX_EXT_swap_control", "glXSwapIntervalEXT");
- funCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)resolveGLXFunction("GLX_ARB_create_context", "glXCreateContextAttribsARB");
- // get the first usable framebuffer configuration
- int count = 0;
- GLXFBConfig *configs = glXChooseFBConfig(display, DefaultScreen(display), configAttribs, &count);
- if (count < 1) {
- die("Failed to choose framebuffer configuration\n");
- }
- config = configs[0];
- XFree(configs);
- }
- // return visual ID
- XVisualInfo *vi = glXGetVisualFromFBConfig(display, config);
- if (vi== NULL) {
- die("The GLXFBConfig I got is invalid\n");
- }
- VisualID visualid = vi->visualid;
- XFree(vi);
- return visualid;
+ if (this->display == NULL) { // this implies that the context is also unitialized
+ this->display = display;
+ // debugging: show version information
+ int glxMajor, glxMinor;
+ glXQueryVersion(display, &glxMajor, &glxMinor);
+ printf("Using GLX version: %d.%d\n", glxMajor, glxMinor);
+ 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");
+ funSwapIntervalExt = (PFNGLXSWAPINTERVALEXTPROC)resolveGLXFunction("GLX_EXT_swap_control", "glXSwapIntervalEXT");
+ funCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)resolveGLXFunction("GLX_ARB_create_context", "glXCreateContextAttribsARB");
+ // get the first usable framebuffer configuration
+ int count = 0;
+ GLXFBConfig *configs = glXChooseFBConfig(display, DefaultScreen(display), configAttribs, &count);
+ if (count < 1) {
+ die("Failed to choose framebuffer configuration\n");
+ }
+ config = configs[0];
+ XFree(configs);
+ }
+ // return visual ID
+ XVisualInfo *vi = glXGetVisualFromFBConfig(display, config);
+ if (vi== NULL) {
+ die("The GLXFBConfig I got is invalid\n");
+ }
+ VisualID visualid = vi->visualid;
+ XFree(vi);
+ return visualid;