567
* Determine whether or not a GLX extension is supported.
570
is_glx_extension_supported(Display *dpy, const char *query)
572
const int scrnum = DefaultScreen(dpy);
573
const char *glx_extensions = NULL;
574
const size_t len = strlen(query);
577
if (glx_extensions == NULL) {
578
glx_extensions = glXQueryExtensionsString(dpy, scrnum);
581
ptr = strstr(glx_extensions, query);
582
return ((ptr != NULL) && ((ptr[len] == ' ') || (ptr[len] == '\0')));
587
* Attempt to determine whether or not the display is synched to vblank.
590
query_vsync(Display *dpy)
595
#ifdef GLX_MESA_swap_control
597
&& is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
598
PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA =
599
(PFNGLXGETSWAPINTERVALMESAPROC)
600
glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA");
602
interval = (*pglXGetSwapIntervalMESA)();
607
#ifdef GLX_SGI_video_sync
609
&& is_glx_extension_supported(dpy, "GLX_SGI_video_sync")) {
610
PFNGLXGETVIDEOSYNCSGIPROC pglXGetVideoSyncSGI =
611
(PFNGLXGETVIDEOSYNCSGIPROC)
612
glXGetProcAddressARB((const GLubyte *) "glXGetVideoSyncSGI");
615
if ((*pglXGetVideoSyncSGI)(& count) == 0) {
616
interval = (int) count;
623
printf("Running synchronized to the vertical refresh. The framerate should be\n");
625
printf("approximately the same as the monitor refresh rate.\n");
626
} else if (interval > 1) {
627
printf("approximately 1/%d the monitor refresh rate.\n",
564
634
* Handle one X event.
565
635
* \return NOP, EXIT or DRAW
568
638
handle_event(Display *dpy, Window win, XEvent *event)
570
643
switch (event->type) {
686
759
make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx);
687
760
XMapWindow(dpy, win);
688
761
glXMakeCurrent(dpy, win, ctx);
691
765
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));