[Xquartz-changes] [172] AppleSGLX/trunk/tests/glxpixmap/glxpixmap_create_destroy.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 18 21:08:28 PST 2009


Revision: 172
          http://trac.macosforge.org/projects/xquartz/changeset/172
Author:   gstaplin at apple.com
Date:     2009-02-18 21:08:28 -0800 (Wed, 18 Feb 2009)
Log Message:
-----------
Greatly improve the create and destroy GLXPixmap test.

This creates and destroys GLXPixmaps, as well as the base pixmap, and 
draws with Xlib and OpenGL to the same drawable.  It's quite nice
looking too.

Modified Paths:
--------------
    AppleSGLX/trunk/tests/glxpixmap/glxpixmap_create_destroy.c

Modified: AppleSGLX/trunk/tests/glxpixmap/glxpixmap_create_destroy.c
===================================================================
--- AppleSGLX/trunk/tests/glxpixmap/glxpixmap_create_destroy.c	2009-02-19 04:41:03 UTC (rev 171)
+++ AppleSGLX/trunk/tests/glxpixmap/glxpixmap_create_destroy.c	2009-02-19 05:08:28 UTC (rev 172)
@@ -13,10 +13,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 static GLXContext ctx;
 static XVisualInfo *visinfo;
 static GC gc;
+static GC rectgc;
 
 static Window make_rgb_window( Display *dpy,
 				  unsigned int width, unsigned int height )
@@ -158,6 +160,8 @@
    Pixmap pm;
    GLXPixmap glxpm;
    int eventbase, errorbase;
+   double rcolor, gcolor, bcolor;
+   XGCValues gcval;
 
    dpy = XOpenDisplay(NULL);
 
@@ -176,6 +180,10 @@
    
    XMapWindow(dpy, win);
 
+   rcolor = 0.0;
+   gcolor = 0.0;
+   bcolor = 0.0;
+
    while(1) {
        glxpm = make_pixmap( dpy, win, 300, 300, &pm );
 
@@ -194,15 +202,46 @@
        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 );
+       glColor3f( rcolor, gcolor, bcolor);
        glRectf( -0.75, -0.75, 0.75, 0.75 );
        glFlush();
        
        glFinish();
 
+       gcval.foreground = WhitePixel(dpy, DefaultScreen(dpy));
+       
+       rectgc = XCreateGC(dpy, pm, GCForeground, &gcval);
+
+       XFillRectangle(dpy, pm, rectgc, 130, 130, 40, 40);
+       
+       XCopyArea( dpy, pm, win,
+		  gc, 0, 0, 300, 300,          /* gc, src pos, size */
+		  0, 0 );
+
+       glXWaitX();
+
+       XFreeGC(dpy, rectgc);
+ 
        glXMakeCurrent(dpy, None, ctx);
 
        glXDestroyGLXPixmap(dpy, glxpm);
+
+       XFreePixmap(dpy, pm);
+
+       rcolor += 0.01;
+       gcolor += 0.02;
+       bcolor += 0.03;
+
+       if(rcolor >= 1.0)
+	   rcolor = 0.0;
+
+       if(gcolor >= 1.0)
+	   gcolor = 0.0;
+
+       if(bcolor >= 1.0)
+	   bcolor = 0.0;
+       
+       usleep(5000);
    }
 
    /* NOT REACHED */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/xquartz-changes/attachments/20090218/4398e225/attachment-0001.html>


More information about the Xquartz-changes mailing list