/** * gdk_gl_query_extension: * * Indicates whether the window system supports the OpenGL extension * (GLX, WGL, etc.). * * Return value: TRUE if OpenGL is supported, FALSE otherwise. **/ gboolean gdk_gl_query_extension (void) { #ifdef GDKGLEXT_MULTIHEAD_SUPPORT return glXQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), NULL, NULL); #else /* GDKGLEXT_MULTIHEAD_SUPPORT */ return glXQueryExtension (gdk_x11_get_default_xdisplay (), NULL, NULL); #endif /* GDKGLEXT_MULTIHEAD_SUPPORT */ }
GAE_RenderContext_t* GAE_RenderContext_init(GAE_RenderContext_t* context) { GAE_X11_RenderWindow_t* x11Window = (GAE_X11_RenderWindow_t*)context->window->platform; int errorBase, eventBase; int visualArgs[] = { GLX_RGBA , GLX_DEPTH_SIZE, 16 , GLX_DOUBLEBUFFER , None }; XVisualInfo* visualInfo = 0; if (0 == glXQueryExtension(x11Window->display, &errorBase, &eventBase)) { } visualInfo = glXChooseVisual(x11Window->display, XDefaultScreen(x11Window->display), visualArgs); if (0 == visualInfo) { } context->context = glXCreateContext(x11Window->display, visualInfo, 0, 1); if (0 == context->context) { } free(visualInfo); glXMakeCurrent(x11Window->display, x11Window->window, context->context); glViewport(0, 0, context->window->width, context->window->height); glScissor(0, 0, context->window->width, context->window->height); glClearColor(0.4F, 0.4F, 0.4F, 0.0F); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); return context; }
/* ---------------------------------------------------------------------*/ static int check_openGL(Display *dpy) { /* Fixme: add code here to check if extension exists */ const char *ext_table; char *t1, *t2; int b, e; if (glXQueryExtension(dpy, &b, &e) && (ext_table = glXQueryExtensionsString(dpy, DefaultScreen(dpy)))) { t1 = lib_stralloc(ext_table); t2 = strtok(t1, " "); while (t2) { if (strcmp(t2, "GLX_SGI_video_sync") == 0) { log_message(openGL_log, "GLX_SGI_video_sync extension is supported"); lib_free(t1); return 0; } t2 = strtok(NULL, " "); } lib_free(t1); } log_message(openGL_log, "GLX_SGI_video_sync extension not supported"); return 1; }
jboolean queryGLX13(Display *display) { int major, minor; int errorBase, eventBase; if (!glXQueryExtension(display, &errorBase, &eventBase)) { fprintf(stderr, "ES2 Prism: Error - GLX extension is not supported\n"); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } /* Query the GLX version number */ if (!glXQueryVersion(display, &major, &minor)) { fprintf(stderr, "ES2 Prism: Error - Unable to query GLX version\n"); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } /* fprintf(stderr, "Checking GLX version : %d.%d\n", major, minor); */ /* Check for GLX 1.3 and higher */ if (!(major == 1 && minor >= 3)) { fprintf(stderr, "ES2 Prism: Error - reported GLX version = %d.%d\n", major, minor); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } return JNI_TRUE; }
int main( int argc, char *argv[] ) { Display *dpy; Window win; Pixmap pm; GLXPixmap glxpm; int eventbase, errorbase; dpy = XOpenDisplay(NULL); if(NULL == dpy) { fprintf(stderr, "error: opening display\n"); return EXIT_FAILURE; } if(!glXQueryExtension(dpy, &eventbase, &errorbase)) { fprintf(stderr, "GLX is not available!\n"); return EXIT_FAILURE; } win = make_rgb_window( dpy, 300, 300 ); fprintf(stderr, "This test should produce a GLXBadPixmap error.\n"); glXDestroyPixmap(dpy, /*intentional*/ win); return 0; }
int S9xOpenGLDisplayDriver::query_availability () { GdkDisplay *gdk_display = gdk_display_get_default (); #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gdk_display)) { return 1; } #endif #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (gdk_display)) { Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display); if (glXQueryExtension (dpy, NULL, NULL) == True) { return 1; } } #endif if (gui_config->hw_accel == HWA_OPENGL) gui_config->hw_accel = HWA_NONE; return 0; }
int main( int argc, char *argv[] ) { XVisualInfo *xvVisualInfo; Colormap cmColorMap; XSetWindowAttributes winAttr; GLXContext glXContext; int Attr[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None }; // Connect to X Server dpy = XOpenDisplay(NULL); if(dpy == NULL) return 0; // Could not open display // GLX extension is supported? if(!glXQueryExtension(dpy, NULL, NULL)) return 0; // Return, if X server haven't GLX // Find visual xvVisualInfo = glXChooseVisual(dpy, DefaultScreen(dpy), Attr); if(xvVisualInfo == NULL) return 0; // If Visual info can't be shoosed // Create new colormap for our window cmColorMap = XCreateColormap(dpy, RootWindow(dpy, xvVisualInfo->screen), xvVisualInfo->visual, AllocNone); winAttr.colormap = cmColorMap; winAttr.border_pixel = 0; winAttr.background_pixel = 0; winAttr.event_mask = ExposureMask | ButtonPressMask | StructureNotifyMask | KeyPressMask; // Create window win = XCreateWindow(dpy, RootWindow(dpy, xvVisualInfo->screen), 0, 0, 640, 480, 0, xvVisualInfo->depth, InputOutput, xvVisualInfo->visual, CWBorderPixel | CWColormap | CWEventMask, &winAttr); // Create OpenGL rendering context glXContext = glXCreateContext(dpy, xvVisualInfo, None, True); if(glXContext == NULL) return 0; // Can't create rendering context // Make it current glXMakeCurrent(dpy, win, glXContext); // Map window on the display XMapWindow(dpy, win); initShader(); loadTextures(); // Enter to the main X loop event_loop(); glDeleteTextures( 1, &datatexID ); glDeleteObjectARB( g_vertexShader ); glDeleteObjectARB( g_fragmentShader ); glDeleteObjectARB( g_programObj ); return 0; }
void init(void) { initX(); int major = 0, minor = 0; if (!glXQueryVersion(display, &major, &minor)) { std::cerr << "error: failed to obtain GLX version\n"; exit(1); } const int requiredMajor = 1, requiredMinor = 3; if (major < requiredMajor || (major == requiredMajor && minor < requiredMinor)) { std::cerr << "error: GLX version " << requiredMajor << "." << requiredMinor << " required, but got version " << major << "." << minor << "\n"; exit(1); } glXQueryExtension(display, &errorBase, &eventBase); oldErrorHandler = XSetErrorHandler(errorHandler); extensions = glXQueryExtensionsString(display, screen); #define CHECK_EXTENSION(name) \ has_##name = checkExtension(#name, extensions) CHECK_EXTENSION(GLX_ARB_create_context); CHECK_EXTENSION(GLX_ARB_create_context_profile); CHECK_EXTENSION(GLX_EXT_create_context_es_profile); CHECK_EXTENSION(GLX_EXT_create_context_es2_profile); #undef CHECK_EXTENSION }
void i4_x11_opengl_display_class::init() { int errbase, eventbase; // get the input handler to open X connection if (!input.display) { if (!input.open_display()) { i4_warning("WARNING: X11 OpenGL renderer: could not convince input handler to open display. \n" "Check the preceeding lines for X warnings.\n"); return; } } i4_warning("Connection to XServer established successfully"); if (!glXQueryExtension(input.display,&errbase,&eventbase)) { i4_warning("WARNING: glX extension unavailable on the current display."); //return; } setup_modes(); i4_opengl_display_class::init(); if (the_visual!=0) { XFree(the_visual); } the_visual=0; input.close_display(); }
static GLboolean CreateContext(GLContext* ctx) { int attrib[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None }; int erb, evb; XSetWindowAttributes swa; /* check input */ if (NULL == ctx) return GL_TRUE; /* open display */ ctx->dpy = XOpenDisplay(display); if (NULL == ctx->dpy) return GL_TRUE; /* query for glx */ if (!glXQueryExtension(ctx->dpy, &erb, &evb)) return GL_TRUE; /* choose visual */ ctx->vi = glXChooseVisual(ctx->dpy, DefaultScreen(ctx->dpy), attrib); if (NULL == ctx->vi) return GL_TRUE; /* create context */ ctx->ctx = glXCreateContext(ctx->dpy, ctx->vi, None, True); if (NULL == ctx->ctx) return GL_TRUE; /* create window */ /*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/ ctx->cmap = XCreateColormap(ctx->dpy, RootWindow(ctx->dpy, ctx->vi->screen), ctx->vi->visual, AllocNone); swa.border_pixel = 0; swa.colormap = ctx->cmap; ctx->wnd = XCreateWindow(ctx->dpy, RootWindow(ctx->dpy, ctx->vi->screen), 0, 0, 1, 1, 0, ctx->vi->depth, InputOutput, ctx->vi->visual, CWBorderPixel | CWColormap, &swa); /* make context current */ if (!glXMakeCurrent(ctx->dpy, ctx->wnd, ctx->ctx)) return GL_TRUE; return GL_FALSE; }
int main() { Display *dpy; int attrib[] = { GLX_RGBA, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None }; int eventbase, errorbase; int screen; dpy = XOpenDisplay(NULL); if(NULL == dpy) { fprintf(stderr, "error: unable to open display!\n"); return EXIT_FAILURE; } if(!glXQueryExtension(dpy, &eventbase, &errorbase)) { fprintf(stderr, "GLX is not available!\n"); return EXIT_FAILURE; } screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); visinfo = glXChooseVisual(dpy, screen, attrib); if(!visinfo) { fprintf(stderr, "error: couldn't get an RGBA, double-buffered visual!\n"); return EXIT_FAILURE; } attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask; mainwin = win = XCreateWindow(dpy, root, /*x*/ 0, /*y*/ 0, /*width*/ 400, /*height*/ 400, 0, visinfo->depth, InputOutput, visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &attr); ctx = glXCreateContext(dpy, visinfo, NULL, True ); if(!ctx) { fprintf(stderr, "error: glXCreateContext failed!\n"); return EXIT_FAILURE; } XMapWindow(dpy, win); glXMakeCurrent(dpy, win, ctx); event_loop(dpy); return EXIT_SUCCESS; }
xcb_visualtype_t * ephyr_glamor_get_visual(void) { xcb_screen_t *xscreen = xcb_aux_get_screen(XGetXCBConnection(dpy), DefaultScreen(dpy)); int attribs[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, 1, None }; int event_base = 0, error_base = 0, nelements; GLXFBConfig *fbconfigs; if (!glXQueryExtension (dpy, &error_base, &event_base)) FatalError("Couldn't find GLX extension\n"); fbconfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &nelements); if (!nelements) FatalError("Couldn't choose an FBConfig\n"); fb_config = fbconfigs[0]; free(fbconfigs); visual_info = glXGetVisualFromFBConfig(dpy, fb_config); if (visual_info == NULL) FatalError("Couldn't get RGB visual\n"); return xcb_aux_find_visual_by_id(xscreen, visual_info->visualid); }
gboolean _gdk_x11_gl_query_extension_for_display (GdkDisplay *display) { g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); return glXQueryExtension (GDK_DISPLAY_XDISPLAY (display), NULL, NULL); }
void OglInit(void){ dpy=XOpenDisplay(0); if(!dpy) Error("no display\n"); else if (glXQueryExtension(dpy,&glx_erbase,&glx_evbase)==False) Error("no glx\n"); else if (!(visinfo = glXChooseVisual(dpy,DefaultScreen(dpy),attribs))) Error("no visual\n"); }
static gboolean _vte_gl_check(struct _vte_draw *draw, GtkWidget *widget) { int attributes[] = {_vte_gl_attributes}; XVisualInfo *visual_info; GLXContext context = NULL; GdkDisplay *gdisplay; Display *display; GdkScreen *gscreen; int screen; int error, event; gboolean direct; gdisplay = gtk_widget_get_display (widget); display = gdk_x11_display_get_xdisplay (gdisplay); gscreen = gtk_widget_get_screen (widget); screen = gdk_x11_screen_get_screen_number (gscreen); /* Check for GLX. */ if (!glXQueryExtension(display, &error, &event)) { #ifdef VTE_DEBUG g_warning("Unable to use GLX.\n"); #endif return FALSE; } /* See if a suitable visual exists. */ visual_info = glXChooseVisual(display, screen, attributes); if (visual_info == NULL) { #ifdef VTE_DEBUG g_warning("Unable to find a suitable GLX visual.\n"); #endif return FALSE; } /* Create a GLX context. */ context = glXCreateContext(display, visual_info, NULL, GL_TRUE); if (context == NULL) { #ifdef VTE_DEBUG g_warning("Unable to create a GLX context.\n"); #endif return FALSE; } /* Check if it's a direct rendering context. */ direct = glXIsDirect(display, context); #ifdef VTE_DEBUG if (!direct) { g_warning("Unable to create a direct GLX context.\n"); } #endif glXDestroyContext(display, context); return (direct == True) ? TRUE : FALSE; }
/* * Class: javax_media_j3d_X11NativeScreenInfo * Method: queryGLX13 * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_javax_media_j3d_X11NativeScreenInfo_queryGLX13( JNIEnv *env, jclass cls, jlong display) { /* Fix for Issue 20 */ MYPFNGLXCHOOSEFBCONFIG tmpfp; int major, minor; int errorBase, eventBase; Display* dpy = (Display*)display; /* It should be cleaner to return both the major and minor to the caller. */ if (!glXQueryExtension(dpy, &errorBase, &eventBase)) { fprintf(stderr, "Java 3D ERROR : GLX extension is not supported\n"); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } /* Query the GLX version number */ if (!glXQueryVersion(dpy, &major, &minor)) { fprintf(stderr, "Java 3D ERROR : Unable to query GLX version\n"); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } /*fprintf(stderr, "Checking GLX version : %d.%d\n", major, minor);*/ tmpfp = (MYPFNGLXCHOOSEFBCONFIG)dlsym(RTLD_DEFAULT, "glXChooseFBConfig"); if (tmpfp == NULL) { fprintf(stderr, "Java 3D ERROR : glXChooseFBConfig not found\n"); fprintf(stderr, " GLX version = %d.%d\n", major, minor); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } /* Check for GLX 1.3 and higher */ if (!(major == 1 && minor >= 3)) { fprintf(stderr, "Java 3D WARNING : reported GLX version = %d.%d\n", major, minor); fprintf(stderr, " GLX version 1.3 or higher is required\n"); fprintf(stderr, " The reported version number may be incorrect. There is a known\n"); fprintf(stderr, " ATI driver bug in glXQueryVersion that incorrectly reports the GLX\n"); fprintf(stderr, " version as 1.2 when it really is 1.3, so Java 3D will attempt to\n"); fprintf(stderr, " run anyway.\n"); /*return JNI_FALSE;*/ } return JNI_TRUE; }
static int QGL_Init (OpenGLBinding& table) { #if defined __linux__ || defined __FreeBSD__ || defined __APPLE__ qglXGetProcAddressARB = reinterpret_cast<glXGetProcAddressARBProc*>(reinterpret_cast<uintptr_t>(dlsym(RTLD_DEFAULT, "glXGetProcAddressARB"))); if (!glXQueryExtension(GDK_DISPLAY(), 0, 0)) return 0; #elif !defined _WIN32 #error "unsupported platform" #endif return 1; }
void X11Window::internalCheckGL() { #ifdef OPENGL_ES m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_display); if(m_eglDisplay == EGL_NO_DISPLAY) g_logger.fatal("EGL not supported"); if(!eglInitialize(m_eglDisplay, NULL, NULL)) g_logger.fatal("Unable to initialize EGL"); #else if(!glXQueryExtension(m_display, NULL, NULL)) g_logger.fatal("GLX not supported"); #endif }
int main( int argc, char *argv[] ) { Display *dpy; Window win; Pixmap pm; GLXPixmap glxpm; int eventbase, errorbase; dpy = XOpenDisplay(NULL); if(NULL == dpy) { fprintf(stderr, "error: opening display\n"); return EXIT_FAILURE; } if(!glXQueryExtension(dpy, &eventbase, &errorbase)) { fprintf(stderr, "GLX is not available!\n"); return EXIT_FAILURE; } win = make_rgb_window( dpy, 300, 300 ); glxpm = make_pixmap( dpy, win, 300, 300, &pm ); printf("glxpm 0x%lx\n", glxpm); if(!glXMakeCurrent(dpy, glxpm, ctx)) { fprintf(stderr, "glXMakeCurrent failed!\n"); return EXIT_FAILURE; } printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); /* Render an image into the pixmap */ glShadeModel( GL_FLAT ); glClearColor( 0.5, 0.5, 0.5, 1.0 ); glClear( GL_COLOR_BUFFER_BIT ); glViewport( 0, 0, 300, 300 ); glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); glColor3f( 0.0, 0.0, 1.0 ); glRectf( -0.75, -0.75, 0.75, 0.75 ); glFlush(); XMapWindow( dpy, win ); event_loop( dpy, pm ); return 0; }
// --------------------------------------------------------------------------- // --------------------------------------------------------------------------- X11GUIFactory::X11GUIFactory(const char* displayname) : xdisplay(0) , xvisualinfo(0) , xfont(0) { // Open one display connection for all RGL X11 devices xdisplay = XOpenDisplay(displayname); if (xdisplay == 0) { throw_error("unable to open X11 display"); return; } // Load System font xfont = XLoadFont(xdisplay,"fixed"); // Obtain display atoms static char* atom_names[GUI_X11_ATOM_LAST] = { "WM_DELETE_WINDOW" }; Status s = XInternAtoms(xdisplay, atom_names, sizeof(atom_names)/sizeof(char*), True, atoms); if (!s) lib::printMessage("some atoms not available"); // Query glx extension if ( glXQueryExtension(xdisplay, &errorBase, &eventBase) == False ) { throw_error("GLX extension missing on server"); return; } // Choose GLX visual static int attribList[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_ALPHA_SIZE, 0, GLX_DEPTH_SIZE, 1, None }; xvisualinfo = glXChooseVisual( xdisplay, DefaultScreen(xdisplay), attribList ); if (xvisualinfo == 0) { throw_error("no suitable visual available"); return; } }
/***************************************************************************** * OpenDisplay: open and initialize OpenGL device *****************************************************************************/ static int CheckGLX( vlc_object_t *p_this, vlc_bool_t *b_glx13 ) { Display *p_display = NULL; int i_opcode, i_evt, i_err = 0; int i_maj, i_min = 0; /* Open the display */ p_display = XOpenDisplay( NULL ); if( p_display == NULL ) { msg_Err( p_this, "Cannot open display" ); return VLC_EGENERIC; } /* Check for GLX extension */ if( !XQueryExtension( p_display, "GLX", &i_opcode, &i_evt, &i_err ) ) { msg_Err( p_this, "GLX extension not supported" ); XCloseDisplay( p_display ); return VLC_EGENERIC; } if( !glXQueryExtension( p_display, &i_err, &i_evt ) ) { msg_Err( p_this, "glXQueryExtension failed" ); XCloseDisplay( p_display ); return VLC_EGENERIC; } /* Check GLX version */ if (!glXQueryVersion( p_display, &i_maj, &i_min ) ) { msg_Err( p_this, "glXQueryVersion failed" ); XCloseDisplay( p_display ); return VLC_EGENERIC; } if( i_maj <= 0 || ((i_maj == 1) && (i_min < 3)) ) { *b_glx13 = VLC_FALSE; msg_Dbg( p_this, "Using GLX 1.2 API" ); } else { *b_glx13 = VLC_TRUE; msg_Dbg( p_this, "Using GLX 1.3 API" ); } XCloseDisplay( p_display ); return VLC_SUCCESS; }
int S9xOpenGLDisplayDriver::query_availability (void) { int errorBase, eventBase; Display *display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); if (glXQueryExtension (display, &errorBase, &eventBase) == False) { if (gui_config->hw_accel == HWA_OPENGL) gui_config->hw_accel = HWA_NONE; return 0; } return 1; }
int S9xOpenGLDisplayDriver::query_availability (void) { int errorBase, eventBase; if (glXQueryExtension (GDK_DISPLAY (), &errorBase, &eventBase) == False) { if (gui_config->hw_accel == HWA_OPENGL) gui_config->hw_accel = HWA_NONE; return 0; } return 1; }
JNIEXPORT jboolean JNICALL GLX_NATIVE(glXQueryExtension) (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) { jint *lparg1=NULL; jint *lparg2=NULL; jboolean rc = 0; GLX_NATIVE_ENTER(env, that, glXQueryExtension_FUNC); if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; rc = (jboolean)glXQueryExtension(arg0, lparg1, lparg2); fail: if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); GLX_NATIVE_EXIT(env, that, glXQueryExtension_FUNC); return rc; }
WindowSystem::WindowSystem(Options& o) { // If running in "compare" mode we never actually use the window // system, so we don't initialize it here. This allows us to run // on systems without graphics hardware/software. if (o.mode == Options::compare) { dpy = 0; GLXVersMajor = GLXVersMinor = 0; vip = 0; return; } // Open the X11 display: dpy = XOpenDisplay(o.dpyName.c_str()); if (!dpy) throw CantOpenDisplay(); // Verify that GLX is supported: int error_base, event_base; if (glXQueryExtension(dpy, &error_base, &event_base) == False) throw NoOpenGL(); // Record version numbers for later use: if (glXQueryVersion(dpy, &GLXVersMajor, &GLXVersMinor) == False) throw Error(); // this should never happen :-) // Get the list of raw XVisualInfo structures: XVisualInfo vit; vit.screen = DefaultScreen(dpy); int n; vip = XGetVisualInfo(dpy, VisualScreenMask, &vit, &n); // Construct a vector of DrawingSurfaceConfigs corresponding to the // XVisualInfo structures that indicate they support OpenGL: vector<DrawingSurfaceConfig*> glxv; for (int i = 0; i < n; ++i) { int supportsOpenGL; glXGetConfig(dpy, &vip[i], GLX_USE_GL, &supportsOpenGL); if (supportsOpenGL) glxv.push_back(new DrawingSurfaceConfig (dpy, &vip[i])); } // Filter the basic list of DrawingSurfaceConfigs according to // constraints provided by the user. (This makes it convenient // to run tests on just a subset of all available configs.) DrawingSurfaceFilter f(o.visFilter); // may throw an exception! surfConfigs = f.filter(glxv, o.maxVisuals); } // WindowSystem::WindowSystem
int main(int argc, char *argv[]) { Display *dpy; int eventbase, errorbase; int major, minor; GLXFBConfig *configs; int numconfigs, i; dpy = XOpenDisplay(NULL); if(NULL == dpy) { fprintf(stderr, "error: unable to open display!\n"); return EXIT_FAILURE; } if(!glXQueryExtension(dpy, &eventbase, &errorbase)) { fprintf(stderr, "GLX is not available!\n"); return EXIT_FAILURE; } printf("GLX eventbase %d errorbase %d\n", eventbase, errorbase); if(!glXQueryVersion(dpy, &major, &minor)) { fprintf(stderr, "GLX version query error!\n"); return EXIT_FAILURE; } printf("GLX version: %d.%d\n", major, minor); configs = glXGetFBConfigs(dpy, DefaultScreen(dpy), &numconfigs); if(NULL == configs) { fprintf(stderr, "error: retrieving GLXFBConfigs!\n"); return EXIT_FAILURE; } for(i = 0; i < numconfigs; ++i) { int value; if(Success != glXGetFBConfigAttrib(dpy, configs[i], GLX_STEREO, &value)) { fprintf(stderr, "unable to query GLX_STEREO!\n"); return EXIT_FAILURE; } printf("GLXFBConfig[%d] has stereo %d\n", i, value); } return EXIT_SUCCESS; }
/* * If you use this in an X error handler - and you will - pre-call it as: * piglit_glx_get_error(dpy, NULL); * outside the error handler to cache errbase. Otherwise this will * generate protocol, and you'll deadlock. * * Returns -1 if the error is not a GLX error, otherwise returns the * GLX error code. */ int piglit_glx_get_error(Display *dpy, XErrorEvent *err) { static int errbase, evbase; if (!errbase) glXQueryExtension(dpy, &errbase, &evbase); if (!err) return -1; if (err->error_code < errbase || err->error_code > errbase + GLXBadProfileARB) return -1; return err->error_code - errbase; }
static gboolean ccm_display_init_glx(CCMDisplay *self) { g_return_val_if_fail(self != NULL, FALSE); if (glXQueryExtension (self->priv->xdisplay, &self->priv->glx.event_base, &self->priv->glx.error_base)) { self->priv->glx.available = TRUE; ccm_debug ("GLX EVENT BASE: %i", self->priv->glx.event_base); ccm_debug ("GLX ERROR BASE: %i", self->priv->glx.error_base); return TRUE; } return FALSE; }
static int driver_probe( CoreGraphicsDevice *device ) { switch (dfb_system_type()) { case CORE_X11: { int ee; DFBX11 *x11 = dfb_system_data(); return glXQueryExtension( x11->display, &ee, &ee ); } default: break; } return 0; }
static GLXContext _getGLXctx(Display *dpy, XVisualInfo *visInfo) { int dummy; if (!glXQueryExtension(dpy, &dummy, &dummy)) { printf("X server has no OpenGL GLX extension"); exit(0); } GLXContext ctx = glXCreateContext(dpy, visInfo, None, GL_TRUE); if (ctx == NULL) { printf("could not create GLX rendering context"); exit(0); } return ctx; }