i tried to profile mesa by adding -pg to the cflags and then run gears but only calls in gears are listed in gmon.out.. what did i do wrong ? and.. culling looks like broken.. i wrote this little (attached) test prog and nearly all polys are drawn.. the polygon line mode looks broken too compared to the output from mesa 3.0 .. :( -- ralf willenbacher ([EMAIL PROTECTED])
/* $Id: glxdemo.c,v 3.0 1998/02/21 02:16:54 brianp Exp $ */ /* * A demonstration of using the GLX functions. This program is in the * public domain. * * Brian Paul */ /* * $Log: glxdemo.c,v $ * Revision 3.0 1998/02/21 02:16:54 brianp * initial rev * */ #include <GL/gl.h> #include <GL/glx.h> #include <stdio.h> #include <stdlib.h> unsigned char texture[] = { 0, 0, 0, 63, 63, 63, 127, 127, 127, 255, 255, 255, 0, 0, 0, 63, 0, 63, 127, 0, 127, 255, 0, 255, 0, 0, 0, 0, 63, 63, 0, 127, 127, 0, 255, 255, 0, 0, 0, 63, 63, 0, 127, 127, 0, 255, 255, 0}; void draw_clockwise_polygon(float x, float y, float scale) { glBegin(GL_POLYGON); glTexCoord2f(0.0, 0.0); glVertex2f((-1.0*scale)+x, (1.0*scale)+y); glTexCoord2f(1.0, 0.0); glVertex2f((1.0*scale)+x, (1.0*scale)+y); glTexCoord2f(1.0, 1.0); glVertex2f((1.0*scale)+x, (-1.0*scale)+y); glTexCoord2f(0.0, 1.0); glVertex2f((-1.0*scale)+x, (-1.0*scale)+y); glEnd(); } void draw_counterclockwise_polygon(float x, float y, float scale) { glBegin(GL_POLYGON); glTexCoord2f(0.0, 0.0); glVertex2f((-1.0*scale)+x, (1.0*scale)+y); glTexCoord2f(0.0, 1.0); glVertex2f((-1.0*scale)+x, (-1.0*scale)+y); glTexCoord2f(1.0, 1.0); glVertex2f((1.0*scale)+x, (-1.0*scale)+y); glTexCoord2f(1.0, 0.0); glVertex2f((1.0*scale)+x, (1.0*scale)+y); glEnd(); } static void redraw( Display *dpy, Window w ) { printf("Redraw event\n"); glClear( GL_COLOR_BUFFER_BIT ); glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, &texture); glShadeModel(GL_NONE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glColor3f(1.0, 1.0, 1.0); glFrontFace(GL_CCW); glEnable(GL_TEXTURE_2D); /* draw a row of counterclockwise textured polygons in the upper row*/ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_CULL_FACE); draw_counterclockwise_polygon(-0.8, 0.8, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); draw_counterclockwise_polygon(-0.4, 0.8, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_counterclockwise_polygon(0.0, 0.8, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT_AND_BACK); draw_counterclockwise_polygon(0.4, 0.8, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_clockwise_polygon(0.8, 0.8, 0.18); /* draw a row of polygons with front filled and back lined */ glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_LINE); glDisable(GL_CULL_FACE); draw_counterclockwise_polygon(-0.8, 0.4, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); draw_counterclockwise_polygon(-0.4, 0.4, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_counterclockwise_polygon(0.0, 0.4, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT_AND_BACK); draw_counterclockwise_polygon(0.4, 0.4, 0.18); glDisable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_clockwise_polygon(0.8, 0.4, 0.18); /* front lined, back filled */ glPolygonMode(GL_FRONT, GL_LINE); glPolygonMode(GL_BACK, GL_FILL); glDisable(GL_CULL_FACE); draw_counterclockwise_polygon(-0.8, 0.0, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); draw_counterclockwise_polygon(-0.4, 0.0, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_counterclockwise_polygon(0.0, 0.0, 0.18); glEnable(GL_CULL_FACE); glCullFace(GL_FRONT_AND_BACK); draw_counterclockwise_polygon(0.4, 0.0, 0.18); glDisable(GL_CULL_FACE); glCullFace(GL_FRONT); draw_clockwise_polygon(0.8, 0.0, 0.18); /* disable culling und draw a row of clockwise / counterclockwise polys */ glDisable(GL_CULL_FACE); glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_LINE); draw_counterclockwise_polygon(-0.8, -0.4, 0.18); draw_clockwise_polygon(-0.4, -0.4, 0.18); glPolygonMode(GL_FRONT, GL_LINE); glPolygonMode(GL_BACK, GL_FILL); draw_counterclockwise_polygon(0.0, -0.4, 0.18); draw_clockwise_polygon(0.4, -0.4, 0.18); glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); draw_counterclockwise_polygon(0.8, -0.4, 0.18); /* try to draw the same row with culling enabled and set to GL_FRONT_AND_BACK */ glEnable(GL_CULL_FACE); glCullFace(GL_FRONT_AND_BACK); glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_LINE); draw_counterclockwise_polygon(-0.8, -0.8, 0.18); draw_clockwise_polygon(-0.4, -0.8, 0.18); glPolygonMode(GL_FRONT, GL_LINE); glPolygonMode(GL_BACK, GL_FILL); draw_counterclockwise_polygon(0.0, -0.8, 0.18); draw_clockwise_polygon(0.4, -0.8, 0.18); glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); draw_counterclockwise_polygon(0.8, -0.8, 0.18); glXSwapBuffers( dpy, w ); } static void resize( unsigned int width, unsigned int height ) { printf("Resize event\n"); glViewport( 0, 0, width, height ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); } static Window make_rgb_db_window( Display *dpy, unsigned int width, unsigned int height ) { int attrib[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None }; int scrnum; XSetWindowAttributes attr; unsigned long mask; Window root; Window win; GLXContext ctx; XVisualInfo *visinfo; scrnum = DefaultScreen( dpy ); root = RootWindow( dpy, scrnum ); visinfo = glXChooseVisual( dpy, scrnum, attrib ); if (!visinfo) { printf("Error: couldn't get an RGB, Double-buffered visual\n"); exit(1); } /* window attributes */ attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow( dpy, root, 0, 0, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr ); ctx = glXCreateContext( dpy, visinfo, NULL, True ); glXMakeCurrent( dpy, win, ctx ); return win; } static void event_loop( Display *dpy ) { XEvent event; while (1) { XNextEvent( dpy, &event ); switch (event.type) { case Expose: redraw( dpy, event.xany.window ); break; case ConfigureNotify: resize( event.xconfigure.width, event.xconfigure.height ); break; } } } int main( int argc, char *argv[] ) { Display *dpy; Window win; dpy = XOpenDisplay(NULL); win = make_rgb_db_window( dpy, 300, 300 ); glShadeModel( GL_FLAT ); glClearColor( 0.5, 0.2, 0.4, 1.0 ); XMapWindow( dpy, win ); event_loop( dpy ); return 0; }