diff options
-rw-r--r-- | include/GL/gl.h | 12 | ||||
-rw-r--r-- | include/GL/osmesa.h | 35 | ||||
-rw-r--r-- | progs/demos/gears.c | 54 | ||||
-rw-r--r-- | progs/demos/osdemo.c | 22 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 108 | ||||
-rw-r--r-- | src/mesa/main/enums.c | 5 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 4 |
7 files changed, 143 insertions, 97 deletions
diff --git a/include/GL/gl.h b/include/GL/gl.h index b211ebd88a9..b22295ec339 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -1,4 +1,4 @@ -/* $Id: gl.h,v 1.35 2000/03/23 16:54:50 brianp Exp $ */ +/* $Id: gl.h,v 1.36 2000/03/28 16:59:39 rjfrank Exp $ */ /* * Mesa 3-D graphics library @@ -2095,6 +2095,16 @@ GLAPI void GLAPIENTRY glUnlockArraysEXT( void ); #endif /* GL_EXT_compiled_vertex_array */ +/* + * 137. GL_HP_occlusion_test + */ +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 + +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 + +#endif /* GL_HP_occlusion_test */ /* diff --git a/include/GL/osmesa.h b/include/GL/osmesa.h index ac66e77e854..9746d74f919 100644 --- a/include/GL/osmesa.h +++ b/include/GL/osmesa.h @@ -1,4 +1,4 @@ -/* $Id: osmesa.h,v 1.4 2000/01/18 17:29:18 brianp Exp $ */ +/* $Id: osmesa.h,v 1.5 2000/03/28 16:59:39 rjfrank Exp $ */ /* * Mesa 3-D graphics library @@ -96,15 +96,6 @@ extern "C" { #define OSMESA_TYPE 0x23 -/* - * Accepted by OSMesaGetBooleanv: - * New in version 3.3 - */ -/* This is based on the HP proposed extension */ -#define OSMESA_OCCLUSION_TEST_RESULT_HP 0x30 - - - typedef struct osmesa_context *OSMesaContext; @@ -212,16 +203,6 @@ GLAPI void GLAPIENTRY OSMesaGetIntegerv( GLint pname, GLint *value ); /* - * Return a boolean value like glGetBooleanv. - * Input: pname - - * OSMESA_OCCLUSION_TEST_RESULT_HP return current test result - * value - pointer to boolean in which to return result. - */ -GLAPI void GLAPIENTRY OSMesaGetBooleanv( GLint pname, GLboolean *value ); - - - -/* * Return the depth buffer associated with an OSMesa context. * Input: c - the OSMesa context * Output: width, height - size of buffer in pixels @@ -237,6 +218,20 @@ GLAPI GLboolean GLAPIENTRY OSMesaGetDepthBuffer( OSMesaContext c, void **buffer ); +/* + * Return the color buffer associated with an OSMesa context. + * Input: c - the OSMesa context + * Output: width, height - size of buffer in pixels + * format - buffer format (OSMESA_FORMAT) + * buffer - pointer to depth buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + * + * New in Mesa 3.3. + */ +GLAPI GLboolean GLAPIENTRY OSMesaGetColorBuffer( OSMesaContext c, + GLint *width, GLint *height, + GLint *format, + void **buffer ); #if defined(__BEOS__) || defined(__QUICKDRAW__) diff --git a/progs/demos/gears.c b/progs/demos/gears.c index 91f5eff024e..96e7de2a2b8 100644 --- a/progs/demos/gears.c +++ b/progs/demos/gears.c @@ -1,4 +1,4 @@ -/* $Id: gears.c,v 1.2 1999/10/21 16:39:06 brianp Exp $ */ +/* $Id: gears.c,v 1.3 2000/03/28 16:59:39 rjfrank Exp $ */ /* * 3-D gear wheels. This program is in the public domain. @@ -14,6 +14,9 @@ /* * $Log: gears.c,v $ + * Revision 1.3 2000/03/28 16:59:39 rjfrank + * Implemented support for the HP occlusion test extension (osmesa and X) + * * Revision 1.2 1999/10/21 16:39:06 brianp * added -info command line option * @@ -178,12 +181,14 @@ gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, } static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; -static GLint gear1, gear2, gear3; +static GLint gear1, gear2, gear3, gear3box; static GLfloat angle = 0.0; static void draw(void) { + GLboolean bRet = GL_TRUE; + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); @@ -206,7 +211,20 @@ draw(void) glPushMatrix(); glTranslatef(-3.1, 4.2, 0.0); glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); - glCallList(gear3); + +#ifdef GL_HP_occlusion_test + glDepthMask(GL_FALSE); + glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); + glEnable(GL_OCCLUSION_TEST_HP); + glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet); + glCallList(gear3box); + glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet); + glDepthMask(GL_TRUE); + glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + glDisable(GL_OCCLUSION_TEST_HP); +#endif + + if (bRet) glCallList(gear3); glPopMatrix(); glPopMatrix(); @@ -305,6 +323,16 @@ init(int argc, char *argv[]) {0.0, 0.8, 0.2, 1.0}; static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; + static float cube[8][3] = { + {-2.35,-2.35,-0.5}, + { 2.35,-2.35,-0.5}, + { 2.35, 2.35,-0.5}, + {-2.35, 2.35,-0.5}, + {-2.35,-2.35, 0.5}, + { 2.35,-2.35, 0.5}, + { 2.35, 2.35, 0.5}, + {-2.35, 2.35, 0.5}, + }; glLightfv(GL_LIGHT0, GL_POSITION, pos); glEnable(GL_CULL_FACE); @@ -331,6 +359,26 @@ init(int argc, char *argv[]) gear(1.3, 2.0, 0.5, 10, 0.7); glEndList(); + gear3box = glGenLists(1); + glNewList(gear3box, GL_COMPILE); + glDisable(GL_LIGHTING); + glBegin(GL_QUADS); + glVertex3fv(cube[3]); glVertex3fv(cube[2]); + glVertex3fv(cube[1]); glVertex3fv(cube[0]); + glVertex3fv(cube[4]); glVertex3fv(cube[5]); + glVertex3fv(cube[6]); glVertex3fv(cube[7]); + glVertex3fv(cube[0]); glVertex3fv(cube[1]); + glVertex3fv(cube[5]); glVertex3fv(cube[4]); + glVertex3fv(cube[1]); glVertex3fv(cube[2]); + glVertex3fv(cube[6]); glVertex3fv(cube[5]); + glVertex3fv(cube[2]); glVertex3fv(cube[3]); + glVertex3fv(cube[7]); glVertex3fv(cube[6]); + glVertex3fv(cube[3]); glVertex3fv(cube[0]); + glVertex3fv(cube[4]); glVertex3fv(cube[7]); + glEnd(); + glEnable(GL_LIGHTING); + glEndList(); + glEnable(GL_NORMALIZE); if (argc > 1 && strcmp(argv[1], "-info")==0) { diff --git a/progs/demos/osdemo.c b/progs/demos/osdemo.c index 83f29af0703..7411d4ad4e0 100644 --- a/progs/demos/osdemo.c +++ b/progs/demos/osdemo.c @@ -1,4 +1,4 @@ -/* $Id: osdemo.c,v 1.3 2000/03/06 23:56:21 brianp Exp $ */ +/* $Id: osdemo.c,v 1.4 2000/03/28 16:59:39 rjfrank Exp $ */ /* * Demo of off-screen Mesa rendering @@ -75,24 +75,26 @@ static void render_image( void ) glutSolidCone(1.0, 2.0, 16, 1); glPopMatrix(); -#ifdef OSMESA_OCCLUSION_TEST_RESULT_HP +#ifdef GL_HP_occlusion_test { GLboolean bRet; - OSMesaGetBooleanv(OSMESA_OCCLUSION_TEST_RESULT_HP,&bRet); glDepthMask(GL_FALSE); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); + glEnable(GL_OCCLUSION_TEST_HP); + glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet); glPushMatrix(); - glTranslatef(0.75, 0.0, -1.0); + glTranslatef(0.75, 0.0, -1.0); glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat ); glutSolidSphere(1.0, 20, 20); glPopMatrix(); - OSMesaGetBooleanv(OSMESA_OCCLUSION_TEST_RESULT_HP,&bRet); + glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet); printf("Occlusion test 1 (result should be 1): %d\n",bRet); glDepthMask(GL_TRUE); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + glDisable(GL_OCCLUSION_TEST_HP); } #endif @@ -102,26 +104,28 @@ static void render_image( void ) glutSolidSphere(1.0, 20, 20); glPopMatrix(); -#ifdef OSMESA_OCCLUSION_TEST_RESULT_HP +#ifdef GL_HP_occlusion_test { GLboolean bRet; - OSMesaGetBooleanv(OSMESA_OCCLUSION_TEST_RESULT_HP,&bRet); glDepthMask(GL_FALSE); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); + glEnable(GL_OCCLUSION_TEST_HP); + glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet); /* draw a sphere inside the previous sphere */ glPushMatrix(); - glTranslatef(0.75, 0.0, -1.0); + glTranslatef(0.75, 0.0, -1.0); glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat ); glutSolidSphere(0.5, 20, 20); glPopMatrix(); - OSMesaGetBooleanv(OSMESA_OCCLUSION_TEST_RESULT_HP,&bRet); + glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet); printf("Occlusion test 2 (result should be 0): %d\n",bRet); glDepthMask(GL_TRUE); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + glDisable(GL_OCCLUSION_TEST_HP); } #endif diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 426154df562..3cbfcc453e7 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.11 2000/03/17 15:32:29 brianp Exp $ */ +/* $Id: osmesa.c,v 1.12 2000/03/28 16:59:39 rjfrank Exp $ */ /* * Mesa 3-D graphics library @@ -47,6 +47,7 @@ #include "matrix.h" #include "types.h" #include "vb.h" +#include "extensions.h" #endif @@ -74,7 +75,6 @@ struct osmesa_context { void *rowaddr[MAX_HEIGHT]; /* address of first pixel in each image row */ GLboolean yup; /* TRUE -> Y increases upward */ /* FALSE -> Y increases downward */ - GLboolean bVisible; /* TRUE if geometry is visible */ }; @@ -224,7 +224,7 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist ) FREE(osmesa); return NULL; } - + gl_extensions_enable(&(osmesa->gl_ctx),"GL_HP_occlusion_test"); osmesa->gl_buffer = gl_create_framebuffer( osmesa->gl_visual, osmesa->gl_visual->DepthBits > 0, @@ -254,7 +254,6 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist ) osmesa->rind = rind; osmesa->gind = gind; osmesa->bind = bind; - osmesa->bVisible = GL_FALSE; } return osmesa; } @@ -466,21 +465,6 @@ void GLAPIENTRY OSMesaGetIntegerv( GLint pname, GLint *value ) } } -void GLAPIENTRY OSMesaGetBooleanv( GLint pname, GLboolean *value ) -{ - OSMesaContext ctx = OSMesaGetCurrentContext(); - - switch (pname) { - case OSMESA_OCCLUSION_TEST_RESULT_HP: - *value = ctx->bVisible; - ctx->bVisible = GL_FALSE; - return; - default: - gl_error(&ctx->gl_ctx, GL_INVALID_ENUM, "OSMesaGetBooleanv(pname)" ); - return; - } -} - /* * Return the depth buffer associated with an OSMesa context. * Input: c - the OSMesa context @@ -508,8 +492,31 @@ GLboolean GLAPIENTRY OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint } } - - +/* + * Return the color buffer associated with an OSMesa context. + * Input: c - the OSMesa context + * Output: width, height - size of buffer in pixels + * format - the pixel format (OSMESA_FORMAT) + * buffer - pointer to color buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + */ +GLboolean GLAPIENTRY OSMesaGetColorBuffer( OSMesaContext c, GLint *width, + GLint *height, GLint *format, void **buffer ) +{ + if (!c->buffer) { + *width = 0; + *height = 0; + *format = 0; + *buffer = 0; + return GL_FALSE; + } else { + *width = c->width; + *height = c->height; + *format = c->format; + *buffer = c->buffer; + return GL_TRUE; + } +} /**********************************************************************/ /*** Device Driver Functions ***/ @@ -711,7 +718,6 @@ static void write_rgba_span( const GLcontext *ctx, GLint gshift = osmesa->gshift; GLint bshift = osmesa->bshift; GLint ashift = osmesa->ashift; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ if (mask) { for (i=0;i<n;i++,ptr4++) { if (mask[i]) { @@ -737,7 +743,6 @@ static void write_rgba_span_rgba( const GLcontext *ctx, GLuint *ptr4 = PIXELADDR4( x, y ); const GLuint *rgba4 = (const GLuint *) rgba; GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ if (mask) { for (i=0;i<n;i++) { if (mask[i]) { @@ -763,7 +768,6 @@ static void write_rgb_span( const GLcontext *ctx, GLint gshift = osmesa->gshift; GLint bshift = osmesa->bshift; GLint ashift = osmesa->ashift; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ if (mask) { for (i=0;i<n;i++,ptr4++) { if (mask[i]) { @@ -787,7 +791,6 @@ static void write_monocolor_span( const GLcontext *ctx, OSMesaContext osmesa = (OSMesaContext) ctx; GLuint *ptr4 = PIXELADDR4(x,y); GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++,ptr4++) { if (mask[i]) { *ptr4 = osmesa->pixel; @@ -807,7 +810,6 @@ static void write_rgba_pixels( const GLcontext *ctx, GLint gshift = osmesa->gshift; GLint bshift = osmesa->bshift; GLint ashift = osmesa->ashift; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++) { if (mask[i]) { GLuint *ptr4 = PIXELADDR4(x[i],y[i]); @@ -824,7 +826,6 @@ static void write_monocolor_pixels( const GLcontext *ctx, { OSMesaContext osmesa = (OSMesaContext) ctx; GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++) { if (mask[i]) { GLuint *ptr4 = PIXELADDR4(x[i],y[i]); @@ -894,7 +895,6 @@ static void write_rgba_span3( const GLcontext *ctx, GLint rind = osmesa->rind; GLint gind = osmesa->gind; GLint bind = osmesa->bind; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ if (mask) { for (i=0;i<n;i++,ptr3+=3) { if (mask[i]) { @@ -924,7 +924,6 @@ static void write_rgb_span3( const GLcontext *ctx, GLint rind = osmesa->rind; GLint gind = osmesa->gind; GLint bind = osmesa->bind; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ if (mask) { for (i=0;i<n;i++,ptr3+=3) { if (mask[i]) { @@ -960,7 +959,6 @@ static void write_monocolor_span3( const GLcontext *ctx, GLubyte *ptr3 = PIXELADDR3( x, y); GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++,ptr3+=3) { if (mask[i]) { ptr3[rind] = rval; @@ -979,7 +977,6 @@ static void write_rgba_pixels3( const GLcontext *ctx, GLint rind = osmesa->rind; GLint gind = osmesa->gind; GLint bind = osmesa->bind; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++) { if (mask[i]) { GLubyte *ptr3 = PIXELADDR3(x[i],y[i]); @@ -1002,7 +999,6 @@ static void write_monocolor_pixels3( const GLcontext *ctx, GLubyte rval = UNPACK_RED(osmesa->pixel); GLubyte gval = UNPACK_GREEN(osmesa->pixel); GLubyte bval = UNPACK_BLUE(osmesa->pixel); - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++) { if (mask[i]) { GLubyte *ptr3 = PIXELADDR3(x[i],y[i]); @@ -1064,7 +1060,6 @@ static void write_index32_span( const GLcontext *ctx, OSMesaContext osmesa = (OSMesaContext) ctx; GLubyte *ptr1 = PIXELADDR1(x,y); GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ if (mask) { for (i=0;i<n;i++,ptr1++) { if (mask[i]) { @@ -1088,7 +1083,6 @@ static void write_index8_span( const GLcontext *ctx, OSMesaContext osmesa = (OSMesaContext) ctx; GLubyte *ptr1 = PIXELADDR1(x,y); GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ if (mask) { for (i=0;i<n;i++,ptr1++) { if (mask[i]) { @@ -1109,7 +1103,6 @@ static void write_monoindex_span( const GLcontext *ctx, OSMesaContext osmesa = (OSMesaContext) ctx; GLubyte *ptr1 = PIXELADDR1(x,y); GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++,ptr1++) { if (mask[i]) { *ptr1 = (GLubyte) osmesa->pixel; @@ -1124,7 +1117,6 @@ static void write_index_pixels( const GLcontext *ctx, { OSMesaContext osmesa = (OSMesaContext) ctx; GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++) { if (mask[i]) { GLubyte *ptr1 = PIXELADDR1(x[i],y[i]); @@ -1140,7 +1132,6 @@ static void write_monoindex_pixels( const GLcontext *ctx, { OSMesaContext osmesa = (OSMesaContext) ctx; GLuint i; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ for (i=0;i<n;i++) { if (mask[i]) { GLubyte *ptr1 = PIXELADDR1(x[i],y[i]); @@ -1192,7 +1183,6 @@ static void flat_rgba_line( GLcontext *ctx, OSMesaContext osmesa = (OSMesaContext) ctx; GLubyte *color = ctx->VB->ColorPtr->data[pvert]; unsigned long pixel = PACK_RGBA( color[0], color[1], color[2], color[3] ); - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ #define INTERP_XY 1 #define CLIP_HACK 1 @@ -1215,7 +1205,6 @@ static void flat_rgba_z_line( GLcontext *ctx, OSMesaContext osmesa = (OSMesaContext) ctx; GLubyte *color = ctx->VB->ColorPtr->data[pvert]; unsigned long pixel = PACK_RGBA( color[0], color[1], color[2], color[3] ); - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ #define INTERP_XY 1 #define INTERP_Z 1 @@ -1252,7 +1241,6 @@ static void flat_blend_rgba_line( GLcontext *ctx, GLint rvalue = VB->ColorPtr->data[pvert][0]*avalue; GLint gvalue = VB->ColorPtr->data[pvert][1]*avalue; GLint bvalue = VB->ColorPtr->data[pvert][2]*avalue; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ #define INTERP_XY 1 #define CLIP_HACK 1 @@ -1289,7 +1277,6 @@ static void flat_blend_rgba_z_line( GLcontext *ctx, GLint rvalue = VB->ColorPtr->data[pvert][0]*avalue; GLint gvalue = VB->ColorPtr->data[pvert][1]*avalue; GLint bvalue = VB->ColorPtr->data[pvert][2]*avalue; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ #define INTERP_XY 1 #define INTERP_Z 1 @@ -1329,7 +1316,6 @@ static void flat_blend_rgba_z_line_write( GLcontext *ctx, GLint rvalue = VB->ColorPtr->data[pvert][0]*avalue; GLint gvalue = VB->ColorPtr->data[pvert][1]*avalue; GLint bvalue = VB->ColorPtr->data[pvert][2]*avalue; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ #define INTERP_XY 1 #define INTERP_Z 1 @@ -1470,7 +1456,7 @@ static void smooth_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLint bshift = osmesa->bshift; GLint ashift = osmesa->ashift; (void) pv; - osmesa->bVisible = GL_TRUE; /* if here, the occlusion test is misused */ + #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 @@ -1573,16 +1559,15 @@ static triangle_func choose_triangle_function( GLcontext *ctx ) /**********************************************************************/ #define OCC_STD_MASK_TEST \ - OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; \ - if (osmesa->bVisible) return; \ + if (ctx->OcclusionResult) return; \ if (mask) { \ GLuint i; \ for (i=0;i<n;i++) if (mask[i]) { \ - osmesa->bVisible = GL_TRUE; \ + ((GLcontext *)ctx)->OcclusionResult = GL_TRUE; \ return; \ } \ } else { \ - osmesa->bVisible = GL_TRUE; \ + ((GLcontext *)ctx)->OcclusionResult = GL_TRUE; \ } \ return; @@ -1679,16 +1664,14 @@ static void write_monocolor_pixels_occ( const GLcontext *ctx, static void line_occ( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert ) { - OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; - osmesa->bVisible = GL_TRUE; + ctx->OcclusionResult = GL_TRUE; } static void line_z_occ( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert ) { - OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; - if (osmesa->bVisible) return; + if (ctx->OcclusionResult) return; #define INTERP_XY 1 #define INTERP_Z 1 @@ -1696,7 +1679,7 @@ static void line_z_occ( GLcontext *ctx, #define CLIP_HACK 1 #define PLOT(X,Y) \ if (Z < *zPtr) { \ - osmesa->bVisible = GL_TRUE; \ + ctx->OcclusionResult = GL_TRUE; \ return; \ } @@ -1714,16 +1697,15 @@ static void line_z_occ( GLcontext *ctx, static void triangle_occ( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv ) { - OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; - osmesa->bVisible = GL_TRUE; + ctx->OcclusionResult = GL_TRUE; } static void triangle_z_occ( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv ) { - OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; - if (osmesa->bVisible) return; + if (ctx->OcclusionResult) return; + #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INNER_LOOP( LEFT, RIGHT, Y ) \ @@ -1732,7 +1714,7 @@ static void triangle_z_occ( GLcontext *ctx, GLuint v0, GLuint v1, for (i=0;i<len;i++) { \ GLdepth z = FixedToDepth(ffz); \ if (z < zRow[i]) { \ - osmesa->bVisible = GL_TRUE; \ + ctx->OcclusionResult = GL_TRUE; \ return; \ } \ ffz += fdzdx; \ @@ -1831,15 +1813,17 @@ static void osmesa_update_state( GLcontext *ctx ) * extension use will just cause unnecessary rasterization * to occur. The image will be correct in any case. */ - if ((ctx->Color.IndexMask == 0) && + if ((ctx->Depth.OcclusionTest) && + (((!ctx->Visual->RGBAflag) && + (ctx->Color.IndexMask == 0)) || + ((ctx->Visual->RGBAflag) && (ctx->Color.ColorMask[0] == 0) && (ctx->Color.ColorMask[1] == 0) && (ctx->Color.ColorMask[2] == 0) && - (ctx->Color.ColorMask[3] == 0) && + (ctx->Color.ColorMask[3] == 0))) && + (ctx->Depth.Func == GL_LESS) && (ctx->Stencil.Enabled == GL_FALSE)) { - /* XXX depth.func == GL_LESS ? */ - ctx->Driver.WriteCI32Span = write_index32_span_occ; ctx->Driver.WriteCI8Span = write_index8_span_occ; ctx->Driver.WriteMonoCISpan = write_monoindex_span_occ; @@ -1859,5 +1843,7 @@ static void osmesa_update_state( GLcontext *ctx ) ctx->Driver.LineFunc = line_occ; ctx->Driver.TriangleFunc = triangle_occ; } + } else { + ctx->OcclusionResult = GL_TRUE; } } diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index 9c49a810bed..417a76bf3e8 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -1,4 +1,4 @@ -/* $Id: enums.c,v 1.7 2000/03/07 17:54:58 brianp Exp $ */ +/* $Id: enums.c,v 1.8 2000/03/28 16:59:39 rjfrank Exp $ */ /* * Mesa 3-D graphics library @@ -769,6 +769,9 @@ enum_elt all_enums[] = { "GL_CLIENT_ACTIVE_TEXTURE_ARB", 0x84E1 }, { "GL_MAX_TEXTURE_UNITS_ARB", 0x84E2 }, + { "GL_OCCLUSION_TEST_HP", 0x8165 }, + { "GL_OCCLUSION_TEST_RESULT_HP", 0x8166 }, + { "GL_TEXTURE_FILTER_CONTROL_EXT", 0x8500 }, { "GL_TEXTUER_LOD_BIAS_EXT", 0x8501 }, diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index f60ae01de9d..65495a48a09 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,4 +1,4 @@ -/* $Id: extensions.c,v 1.20 2000/03/11 23:23:26 brianp Exp $ */ +/* $Id: extensions.c,v 1.21 2000/03/28 16:59:39 rjfrank Exp $ */ /* * Mesa 3-D graphics library @@ -130,7 +130,7 @@ static int set_extension( GLcontext *ctx, const char *name, GLint state ) if (i == ctx->Extensions.ext_list) return 1; - if (i->enabled && !(i->enabled & ALWAYS_ENABLED)) { + if (!(i->enabled & ALWAYS_ENABLED)) { if (i->notify) i->notify( ctx, state ); i->enabled = state; } |