[Xquartz-changes] [203] AppleSGLX/trunk/tests

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 20 03:07:34 PST 2009


Revision: 203
          http://trac.macosforge.org/projects/xquartz/changeset/203
Author:   gstaplin at apple.com
Date:     2009-02-20 03:07:33 -0800 (Fri, 20 Feb 2009)
Log Message:
-----------
Add a drawable_types test.

It's used to test for GLX_WINDOW_BIT, GLX_PIXMAP_BIT,
and GLX_PBUFFER_BIT.  It iterates the GLXFBConfigs and
produces output indicating which bits are set. 

(Note: I previously intended for render_types to do that.
 I was mixing up names.)

Modified Paths:
--------------
    AppleSGLX/trunk/tests/simple/render_types.c
    AppleSGLX/trunk/tests/simple/simple.mk
    AppleSGLX/trunk/tests/tests.mk

Added Paths:
-----------
    AppleSGLX/trunk/tests/simple/drawable_types.c

Added: AppleSGLX/trunk/tests/simple/drawable_types.c
===================================================================
--- AppleSGLX/trunk/tests/simple/drawable_types.c	                        (rev 0)
+++ AppleSGLX/trunk/tests/simple/drawable_types.c	2009-02-20 11:07:33 UTC (rev 203)
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <GL/glx.h>
+
+int main(int argc, char *argv[]) {
+    Display *dpy;
+    int eventbase, errorbase;
+    int major, minor;
+    GLXFBConfig *fbconfigs;
+    int i, numfbconfigs;
+    
+    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);
+
+    fbconfigs = glXGetFBConfigs(dpy, DefaultScreen(dpy), &numfbconfigs);
+  
+    if(NULL == fbconfigs) {
+	fprintf(stderr, "%s: failed to get GLXFBConfigs!\n", __func__);
+	return EXIT_FAILURE;
+    }
+
+    for(i = 0; i < numfbconfigs; ++i) {
+	int r, value;
+	
+	r = glXGetFBConfigAttrib(dpy, fbconfigs[i], GLX_DRAWABLE_TYPE, &value);
+	
+	printf("fbconfigs[%d] GLX_DRAWABLE_TYPE is %x supporting: %s %s %s\n",
+	       i, value,
+	       (value & GLX_WINDOW_BIT) ? "GLX_WINDOW_BIT" : "",
+	       (value & GLX_PIXMAP_BIT) ? "GLX_PIXMAP_BIT" : "",
+	       (value & GLX_PBUFFER_BIT) ? "GLX_PBUFFER_BIT" : "");
+    }
+
+    return EXIT_SUCCESS;
+}

Modified: AppleSGLX/trunk/tests/simple/render_types.c
===================================================================
--- AppleSGLX/trunk/tests/simple/render_types.c	2009-02-20 10:25:53 UTC (rev 202)
+++ AppleSGLX/trunk/tests/simple/render_types.c	2009-02-20 11:07:33 UTC (rev 203)
@@ -43,11 +43,8 @@
 	
 	r = glXGetFBConfigAttrib(dpy, fbconfigs[i], GLX_RENDER_TYPE, &value);
 	
-	printf("fbconfigs[%d] GLX_RENDER_TYPE is %x supporting: %s %s %s\n",
-	       i, value,
-	       value & GLX_WINDOW_BIT ? "GLX_WINDOW_BIT" : "",
-	       value & GLX_PIXMAP_BIT ? "GLX_PIXMAP_BIT" : "",
-	       value & GLX_PBUFFER_BIT ? "GLX_PBUFFER_BIT" : "");
+	printf("fbconfigs[%d] GLX_RENDER_TYPE is %x supporting %s\n",
+		i, value, (value == GLX_RGBA_BIT) ? "GLX_RGBA" : "GLX_COLOR_INDEX_BIT");
     }
 
     return EXIT_SUCCESS;

Modified: AppleSGLX/trunk/tests/simple/simple.mk
===================================================================
--- AppleSGLX/trunk/tests/simple/simple.mk	2009-02-20 10:25:53 UTC (rev 202)
+++ AppleSGLX/trunk/tests/simple/simple.mk	2009-02-20 11:07:33 UTC (rev 203)
@@ -4,3 +4,5 @@
 $(TEST_BUILD_DIR)/render_types: tests/simple/render_types.c $(LIBGL)
 	$(CC) tests/simple/render_types.c -Iinclude -I/usr/X11/include -o $(TEST_BUILD_DIR)/render_types $(LINK_TEST)
 
+$(TEST_BUILD_DIR)/drawable_types: tests/simple/drawable_types.c $(LIBGL)
+	$(CC) tests/simple/drawable_types.c -Iinclude -I/usr/X11/include -o $(TEST_BUILD_DIR)/drawable_types $(LINK_TEST)

Modified: AppleSGLX/trunk/tests/tests.mk
===================================================================
--- AppleSGLX/trunk/tests/tests.mk	2009-02-20 10:25:53 UTC (rev 202)
+++ AppleSGLX/trunk/tests/tests.mk	2009-02-20 11:07:33 UTC (rev 203)
@@ -28,4 +28,6 @@
   $(TEST_BUILD_DIR)/create_destroy_context_with_drawable_2 \
   $(TEST_BUILD_DIR)/render_types \
   $(TEST_BUILD_DIR)/glxpixmap_create_destroy \
-  $(TEST_BUILD_DIR)/sharedtex
+  $(TEST_BUILD_DIR)/sharedtex \
+  $(TEST_BUILD_DIR)/drawable_types
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/xquartz-changes/attachments/20090220/d1b4b186/attachment-0001.html>


More information about the Xquartz-changes mailing list