From 352d4dbfb24c65f327759c00c7db7d30a9482e35 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 10 May 2004 18:16:03 +0000 Subject: Add EXT_vertex_cull support to mesa --- src/mesa/main/clip.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/mesa/main/clip.h | 7 +++++++ src/mesa/main/enable.c | 9 +++++++++ src/mesa/main/extensions.c | 1 + src/mesa/main/matrix.c | 13 ++++++++++++- src/mesa/main/mtypes.h | 5 +++++ src/mesa/main/state.c | 2 ++ 7 files changed, 78 insertions(+), 1 deletion(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c index 31e6af91bd..a1eda32ebf 100644 --- a/src/mesa/main/clip.c +++ b/src/mesa/main/clip.c @@ -117,3 +117,45 @@ _mesa_GetClipPlane( GLenum plane, GLdouble *equation ) equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3]; } +void GLAPIENTRY +_mesa_CullParameterfvEXT (GLenum cap, GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (cap) { + case GL_CULL_VERTEX_EYE_POSITION_EXT: + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + COPY_4FV(ctx->Transform.CullEyePos, v); + + _mesa_transform_vector( ctx->Transform.CullObjPos, + ctx->Transform.CullEyePos, + ctx->ModelviewMatrixStack.Top->inv ); + break; + + case GL_CULL_VERTEX_OBJECT_POSITION_EXT: + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + COPY_4FV(ctx->Transform.CullObjPos, v); + + _mesa_transform_vector( ctx->Transform.CullEyePos, + ctx->Transform.CullObjPos, + ctx->ModelviewMatrixStack.Top->m ); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glCullParameterfvEXT" ); + } +} + +void GLAPIENTRY +_mesa_CullParameterdvEXT (GLenum cap, GLdouble *v) +{ + GLfloat f[4]; + + f[0] = (GLfloat)v[0]; + f[1] = (GLfloat)v[1]; + f[2] = (GLfloat)v[2]; + f[3] = (GLfloat)v[3]; + + _mesa_CullParameterfvEXT(cap, f); +} + diff --git a/src/mesa/main/clip.h b/src/mesa/main/clip.h index 9442e86439..d53afb45bd 100644 --- a/src/mesa/main/clip.h +++ b/src/mesa/main/clip.h @@ -39,4 +39,11 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *equation ); extern void GLAPIENTRY _mesa_GetClipPlane( GLenum plane, GLdouble *equation ); +extern void GLAPIENTRY +_mesa_CullParameterfvEXT (GLenum cap, GLfloat *v); + +extern void GLAPIENTRY +_mesa_CullParameterdvEXT (GLenum cap, GLdouble *v); + + #endif diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 64cc4d17ca..25bb7938c0 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -290,6 +290,15 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.CullFlag = state; break; + + case GL_CULL_VERTEX_EXT: + CHECK_EXTENSION(EXT_cull_vertex, cap); + if (ctx->Transform.CullVertexFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.CullVertexFlag = state; + break; + case GL_DEPTH_TEST: if (state && ctx->Visual.depthBits==0) { _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index f840b3fe08..172843a4a4 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -75,6 +75,7 @@ static const struct { { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) }, { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) }, { ON, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, + { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) }, { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, { OFF, "GL_EXT_convolution", F(EXT_convolution) }, { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 19e8dc3a5a..1e6b9dd394 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -745,8 +745,16 @@ calculate_model_project_matrix( GLcontext *ctx ) */ void _mesa_update_modelview_project( GLcontext *ctx, GLuint new_state ) { - if (new_state & _NEW_MODELVIEW) + if (new_state & _NEW_MODELVIEW) { _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + + /* Bring cull position uptodate. + */ + TRANSFORM_POINT3( ctx->Transform.CullObjPos, + ctx->ModelviewMatrixStack.Top->inv, + ctx->Transform.CullEyePos ); + } + if (new_state & _NEW_PROJECTION) update_projection( ctx ); @@ -898,6 +906,9 @@ void _mesa_init_transform( GLcontext *ctx ) ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 ); } ctx->Transform.ClipPlanesEnabled = 0; + + ASSIGN_4V( ctx->Transform.CullObjPos, 0.0, 0.0, 1.0, 0.0 ); + ASSIGN_4V( ctx->Transform.CullEyePos, 0.0, 0.0, 1.0, 0.0 ); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index e045c1f35b..1458f16a53 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1323,6 +1323,10 @@ struct gl_transform_attrib { GLboolean Normalize; /**< Normalize all normals? */ GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ + + GLboolean CullVertexFlag; /**< True if GL_CULL_VERTEX_EXT is enabled */ + GLfloat CullEyePos[4]; + GLfloat CullObjPos[4]; }; @@ -1885,6 +1889,7 @@ struct gl_extensions GLboolean EXT_blend_minmax; GLboolean EXT_blend_subtract; GLboolean EXT_clip_volume_hint; + GLboolean EXT_cull_vertex; GLboolean EXT_convolution; GLboolean EXT_compiled_vertex_array; GLboolean EXT_copy_texture; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index c894241a73..0f3750e61c 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -211,6 +211,8 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->ClipPlane = _mesa_ClipPlane; exec->ColorMaterial = _mesa_ColorMaterial; exec->CopyPixels = _mesa_CopyPixels; + exec->CullParameterfvEXT = _mesa_CullParameterfvEXT; + exec->CullParameterdvEXT = _mesa_CullParameterdvEXT; exec->DeleteLists = _mesa_DeleteLists; exec->DepthFunc = _mesa_DepthFunc; exec->DepthMask = _mesa_DepthMask; -- cgit v1.2.3