summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/attrib.c17
-rw-r--r--src/mesa/main/clip.c6
-rw-r--r--src/mesa/main/context.c5
-rw-r--r--src/mesa/main/enable.c16
-rw-r--r--src/mesa/main/get.c25
-rw-r--r--src/mesa/main/mtypes.h7
-rw-r--r--src/mesa/main/rastpos.c7
-rw-r--r--src/mesa/main/state.c6
-rw-r--r--src/mesa/tnl/t_vb_cliptmp.h36
-rw-r--r--src/mesa/tnl/t_vb_vertex.c6
10 files changed, 67 insertions, 64 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index aad2ee7f8f4..739791878fd 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.61 2002/03/28 22:42:41 brianp Exp $ */
+/* $Id: attrib.c,v 1.62 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -180,9 +180,7 @@ _mesa_PushAttrib(GLbitfield mask)
attr->AlphaTest = ctx->Color.AlphaEnabled;
attr->AutoNormal = ctx->Eval.AutoNormal;
attr->Blend = ctx->Color.BlendEnabled;
- for (i=0;i<MAX_CLIP_PLANES;i++) {
- attr->ClipPlane[i] = ctx->Transform.ClipEnabled[i];
- }
+ attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled;
attr->ColorMaterial = ctx->Light.ColorMaterialEnabled;
attr->Convolution1D = ctx->Pixel.Convolution1DEnabled;
attr->Convolution2D = ctx->Pixel.Convolution2DEnabled;
@@ -451,9 +449,10 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND);
for (i=0;i<MAX_CLIP_PLANES;i++) {
- if (ctx->Transform.ClipEnabled[i] != enable->ClipPlane[i])
+ const GLuint mask = 1 << i;
+ if ((ctx->Transform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask))
_mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i),
- enable->ClipPlane[i]);
+ (enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE);
}
TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial,
@@ -1055,12 +1054,10 @@ _mesa_PopAttrib(void)
/* restore clip planes */
for (i = 0; i < MAX_CLIP_PLANES; i++) {
+ const GLuint mask = 1 << 1;
const GLfloat *eyePlane = xform->EyeUserPlane[i];
COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane);
- if (xform->ClipEnabled[i]) {
- _mesa_transform_vector( ctx->Transform._ClipUserPlane[i],
- eyePlane,
- ctx->ProjectionMatrixStack.Top->inv );
+ if (xform->ClipPlanesEnabled & mask) {
_mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
}
else {
diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c
index 700d271f7bd..168ae350b27 100644
--- a/src/mesa/main/clip.c
+++ b/src/mesa/main/clip.c
@@ -1,4 +1,4 @@
-/* $Id: clip.c,v 1.24 2001/12/18 04:06:44 brianp Exp $ */
+/* $Id: clip.c,v 1.25 2002/03/29 17:29:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -90,9 +90,9 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
* matrix, and is recalculated on changes to the projection matrix by
* code in _mesa_update_state().
*/
- if (ctx->Transform.ClipEnabled[p]) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
if (ctx->ProjectionMatrixStack.Top->flags & MAT_DIRTY)
- _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
+ _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
_mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
ctx->Transform.EyeUserPlane[p],
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 8d0c52a0c34..fa86aaef97e 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.157 2002/03/19 16:47:04 brianp Exp $ */
+/* $Id: context.c,v 1.158 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1182,10 +1182,9 @@ init_attrib_groups( GLcontext *ctx )
ctx->Transform.RescaleNormals = GL_FALSE;
ctx->Transform.RasterPositionUnclipped = GL_FALSE;
for (i=0;i<MAX_CLIP_PLANES;i++) {
- ctx->Transform.ClipEnabled[i] = GL_FALSE;
ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 );
}
- ctx->Transform._AnyClip = GL_FALSE;
+ ctx->Transform.ClipPlanesEnabled = 0;
/* Viewport group */
ctx->Viewport.X = 0;
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 385ceffb98f..88361bd8307 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.58 2002/03/28 22:45:45 brianp Exp $ */
+/* $Id: enable.c,v 1.59 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -207,20 +207,18 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
{
- GLuint p = cap - GL_CLIP_PLANE0;
+ const GLuint p = cap - GL_CLIP_PLANE0;
- if (ctx->Transform.ClipEnabled[p] == state)
+ if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == (state << p))
return;
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
- ctx->Transform.ClipEnabled[p] = state;
if (state) {
- ctx->Transform._AnyClip++;
+ ctx->Transform.ClipPlanesEnabled |= (1 << p);
- if (ctx->ProjectionMatrixStack.Top->flags & MAT_DIRTY) {
+ if (ctx->ProjectionMatrixStack.Top->flags & MAT_DIRTY)
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
- }
/* This derived state also calculated in clip.c and
* from _mesa_update_state() on changes to EyeUserPlane
@@ -231,7 +229,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->ProjectionMatrixStack.Top->inv );
}
else {
- ctx->Transform._AnyClip--;
+ ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
}
}
break;
@@ -930,7 +928,7 @@ _mesa_IsEnabled( GLenum cap )
case GL_CLIP_PLANE3:
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
- return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
+ return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
case GL_COLOR_MATERIAL:
return ctx->Light.ColorMaterialEnabled;
case GL_CULL_FACE:
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index efbed8ccb1f..8cb99ecdbff 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,10 +1,10 @@
-/* $Id: get.c,v 1.75 2001/12/18 04:06:45 brianp Exp $ */
+/* $Id: get.c,v 1.76 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -228,7 +228,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
case GL_CLIP_PLANE3:
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
- *params = ctx->Transform.ClipEnabled[pname-GL_CLIP_PLANE0];
+ if (ctx->Transform.ClipPlanesEnabled & (1 << (pname - GL_CLIP_PLANE0)))
+ *params = GL_TRUE;
+ else
+ *params = GL_FALSE;
break;
case GL_COLOR_CLEAR_VALUE:
params[0] = ctx->Color.ClearColor[0] ? GL_TRUE : GL_FALSE;
@@ -1554,7 +1557,10 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
case GL_CLIP_PLANE3:
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
- *params = (GLdouble) ctx->Transform.ClipEnabled[pname-GL_CLIP_PLANE0];
+ if (ctx->Transform.ClipPlanesEnabled & (1 << (pname - GL_CLIP_PLANE0)))
+ *params = 1.0;
+ else
+ *params = 0.0;
break;
case GL_COLOR_CLEAR_VALUE:
params[0] = (GLdouble) CHAN_TO_FLOAT(ctx->Color.ClearColor[0]);
@@ -2790,7 +2796,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
case GL_CLIP_PLANE3:
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
- *params = (GLfloat) ctx->Transform.ClipEnabled[pname-GL_CLIP_PLANE0];
+ if (ctx->Transform.ClipPlanesEnabled & (1 << (pname - GL_CLIP_PLANE0)))
+ *params = 1.0;
+ else
+ *params = 0.0;
break;
case GL_COLOR_CLEAR_VALUE:
params[0] = CHAN_TO_FLOAT(ctx->Color.ClearColor[0]);
@@ -3996,8 +4005,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
case GL_CLIP_PLANE3:
case GL_CLIP_PLANE4:
case GL_CLIP_PLANE5:
- i = (GLint) (pname - GL_CLIP_PLANE0);
- *params = (GLint) ctx->Transform.ClipEnabled[i];
+ if (ctx->Transform.ClipPlanesEnabled & (1 << (pname - GL_CLIP_PLANE0)))
+ *params = 1;
+ else
+ *params = 0;
break;
case GL_COLOR_CLEAR_VALUE:
params[0] = FLOAT_TO_INT( (ctx->Color.ClearColor[0]) );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a47b472c280..a8154738309 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.68 2002/03/23 16:33:53 brianp Exp $ */
+/* $Id: mtypes.h,v 1.69 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -379,7 +379,7 @@ struct gl_enable_attrib {
GLboolean AlphaTest;
GLboolean AutoNormal;
GLboolean Blend;
- GLboolean ClipPlane[MAX_CLIP_PLANES];
+ GLuint ClipPlanes;
GLboolean ColorMaterial;
GLboolean Convolution1D;
GLboolean Convolution2D;
@@ -1009,8 +1009,7 @@ struct gl_transform_attrib {
GLenum MatrixMode; /* Matrix mode */
GLfloat EyeUserPlane[MAX_CLIP_PLANES][4];
GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /* derived */
- GLboolean ClipEnabled[MAX_CLIP_PLANES];
- GLubyte _AnyClip; /* How many ClipEnabled? */
+ GLuint ClipPlanesEnabled; /* on/off bitmask */
GLboolean Normalize; /* Normalize all normals? */
GLboolean RescaleNormals; /* GL_EXT_rescale_normal */
GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 34fb931c0cd..3f2f6bab57c 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -1,4 +1,4 @@
-/* $Id: rastpos.c,v 1.35 2002/02/15 16:26:08 brianp Exp $ */
+/* $Id: rastpos.c,v 1.36 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -92,7 +92,7 @@ userclip_point( GLcontext* ctx, const GLfloat v[] )
GLuint p;
for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipEnabled[p]) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
+ v[1] * ctx->Transform._ClipUserPlane[p][1]
+ v[2] * ctx->Transform._ClipUserPlane[p][2]
@@ -344,8 +344,7 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
}
/* clip to user clipping planes */
- if (ctx->Transform._AnyClip &&
- userclip_point(ctx, clip) == 0) {
+ if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) {
ctx->Current.RasterPosValid = GL_FALSE;
return;
}
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 8ea069560d3..ee8389a7513 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.78 2002/03/16 18:07:39 brianp Exp $ */
+/* $Id: state.c,v 1.79 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -650,10 +650,10 @@ update_projection( GLcontext *ctx )
/* Recompute clip plane positions in clipspace. This is also done
* in _mesa_ClipPlane().
*/
- if (ctx->Transform._AnyClip) {
+ if (ctx->Transform.ClipPlanesEnabled) {
GLuint p;
for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipEnabled[p]) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
_mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
ctx->Transform.EyeUserPlane[p],
ctx->ProjectionMatrixStack.Top->inv );
diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h
index 305d45b6ba7..33d605f96d5 100644
--- a/src/mesa/tnl/t_vb_cliptmp.h
+++ b/src/mesa/tnl/t_vb_cliptmp.h
@@ -1,4 +1,4 @@
-/* $Id: t_vb_cliptmp.h,v 1.14 2001/07/13 17:26:39 brianp Exp $ */
+/* $Id: t_vb_cliptmp.h,v 1.15 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -140,11 +140,11 @@ TAG(clip_line)( GLcontext *ctx, GLuint i, GLuint j, GLubyte mask )
if (mask & CLIP_USER_BIT) {
for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipEnabled[p]) {
- GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
LINE_CLIP( CLIP_USER_BIT, a, b, c, d );
}
}
@@ -188,13 +188,13 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
if (mask & CLIP_USER_BIT) {
for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipEnabled[p]) {
- GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
- }
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
+ }
}
}
@@ -241,11 +241,11 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
if (mask & CLIP_USER_BIT) {
for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipEnabled[p]) {
- GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
}
}
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index 9026ec51445..4369df16f6c 100644
--- a/src/mesa/tnl/t_vb_vertex.c
+++ b/src/mesa/tnl/t_vb_vertex.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_vertex.c,v 1.12 2002/01/22 14:35:17 brianp Exp $ */
+/* $Id: t_vb_vertex.c,v 1.13 2002/03/29 17:27:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -79,7 +79,7 @@ static void NAME( GLcontext *ctx, \
GLuint p; \
\
for (p = 0; p < ctx->Const.MaxClipPlanes; p++) \
- if (ctx->Transform.ClipEnabled[p]) { \
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { \
GLuint nr, i; \
const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; \
const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; \
@@ -211,7 +211,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
/* Test userclip planes. This contributes to VB->ClipMask, so
* is essentially required to be in this stage.
*/
- if (ctx->Transform._AnyClip) {
+ if (ctx->Transform.ClipPlanesEnabled) {
usercliptab[VB->ClipPtr->size]( ctx,
VB->ClipPtr,
store->clipmask,