summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/buffers.c12
-rw-r--r--src/mesa/main/clip.c15
-rw-r--r--src/mesa/main/context.c13
-rw-r--r--src/mesa/main/dd.h16
-rw-r--r--src/mesa/main/light.c254
-rw-r--r--src/mesa/main/matrix.c12
-rw-r--r--src/mesa/main/points.c3
-rw-r--r--src/mesa/main/rastpos.c9
-rw-r--r--src/mesa/main/state.c500
9 files changed, 438 insertions, 396 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index fe0382dfe9..513f0f69a0 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -1,4 +1,4 @@
-/* $Id: buffers.c,v 1.18 2000/10/31 18:09:44 keithw Exp $ */
+/* $Id: buffers.c,v 1.19 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -98,14 +98,14 @@ _mesa_Clear( GLbitfield mask )
fprintf(stderr, "glClear 0x%x\n", mask);
if (ctx->NewState) {
- gl_update_state( ctx );
+ gl_update_state( ctx ); /* update _Xmin, etc */
}
if (ctx->RenderMode==GL_RENDER) {
- const GLint x = ctx->DrawBuffer->Xmin;
- const GLint y = ctx->DrawBuffer->Ymin;
- const GLint height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
- const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin;
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
GLbitfield ddMask;
GLbitfield newMask;
diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c
index 19675552ab..244753020b 100644
--- a/src/mesa/main/clip.c
+++ b/src/mesa/main/clip.c
@@ -1,4 +1,4 @@
-/* $Id: clip.c,v 1.13 2000/11/05 18:40:57 keithw Exp $ */
+/* $Id: clip.c,v 1.14 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -215,19 +215,6 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
}
-void gl_update_userclip( GLcontext *ctx )
-{
- GLuint p;
-
- for (p = 0 ; p < MAX_CLIP_PLANES ; p++) {
- if (ctx->Transform.ClipEnabled[p]) {
- gl_transform_vector( ctx->Transform._ClipUserPlane[p],
- ctx->Transform.EyeUserPlane[p],
- ctx->ProjectionMatrix.inv );
- }
- }
-}
-
void
_mesa_GetClipPlane( GLenum plane, GLdouble *equation )
{
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 363793a574..f8efa20796 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.103 2000/11/05 18:40:57 keithw Exp $ */
+/* $Id: context.c,v 1.104 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1308,10 +1308,6 @@ init_attrib_groups( GLcontext *ctx )
ctx->Select.Hits = 0;
ctx->Select.NameStackDepth = 0;
- /* Optimized Accum buffer */
- ctx->IntegerAccumMode = GL_TRUE;
- ctx->IntegerAccumScaler = 0.0;
-
/* Renderer and client attribute stacks */
ctx->AttribStackDepth = 0;
ctx->ClientAttribStackDepth = 0;
@@ -1336,12 +1332,11 @@ init_attrib_groups( GLcontext *ctx )
/* Miscellaneous */
ctx->NewState = _NEW_ALL;
ctx->RenderMode = GL_RENDER;
- ctx->_NeedNormals = GL_FALSE;
ctx->_ImageTransferState = 0;
- ctx->_NeedEyeCoords = GL_FALSE;
- ctx->_NeedEyeNormals = GL_FALSE;
- ctx->_vb_proj_matrix = &ctx->_ModelProjectMatrix;
+ ctx->_NeedNormals = 0;
+ ctx->_NeedEyeCoords = 0;
+ ctx->_ModelViewInvScale = 1.0;
ctx->ErrorValue = (GLenum) GL_NO_ERROR;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 8505baeebd..da6aefbdca 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.39 2000/11/10 17:36:42 brianp Exp $ */
+/* $Id: dd.h,v 1.40 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -799,13 +799,6 @@ struct dd_function_table {
* gl_render_vb() function in vbrender.c for more details.
*/
- void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive );
- /* If registered, this will be called when rendering transitions between
- * points, lines and triangles. It is not called on transitions between
- * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
- * triangles and quads or triangles and polygons.
- */
-
GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno );
/* Driver may request additional render passes by returning GL_TRUE
* when this function is called. This function will be called
@@ -819,6 +812,11 @@ struct dd_function_table {
/***
*** NEW in Mesa 3.x
***/
+ void (*LightingSpaceChange)( GLcontext *ctx );
+ /* Notify driver that the special derived value _NeedEyeCoords has
+ * changed.
+ */
+
void (*RegisterVB)( struct vertex_buffer *VB );
void (*UnregisterVB)( struct vertex_buffer *VB );
@@ -890,7 +888,7 @@ struct dd_function_table {
void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
void (*IndexMask)(GLcontext *ctx, GLuint mask);
void (*Lightfv)(GLcontext *ctx, GLenum light,
- GLenum pname, const GLfloat *params, GLint nparams );
+ GLenum pname, const GLfloat *params );
void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
void (*LineWidth)(GLcontext *ctx, GLfloat width);
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 123ae89ade..e5159253e6 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.23 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: light.c,v 1.24 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -91,93 +91,85 @@ void
_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
- GLint l;
- GLint nParams;
+ GLint i = (GLint) (light - GL_LIGHT0);
+ struct gl_light *l = &ctx->Light.Light[i];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLight");
- l = (GLint) (light - GL_LIGHT0);
-
- if (l < 0 || l >= MAX_LIGHTS) {
+ if (i < 0 || i >= MAX_LIGHTS) {
gl_error( ctx, GL_INVALID_ENUM, "glLight" );
return;
}
switch (pname) {
case GL_AMBIENT:
- COPY_4V( ctx->Light.Light[l].Ambient, params );
- nParams = 4;
+ COPY_4V( l->Ambient, params );
break;
case GL_DIFFUSE:
- COPY_4V( ctx->Light.Light[l].Diffuse, params );
- nParams = 4;
+ COPY_4V( l->Diffuse, params );
break;
case GL_SPECULAR:
- COPY_4V( ctx->Light.Light[l].Specular, params );
- nParams = 4;
+ COPY_4V( l->Specular, params );
break;
case GL_POSITION:
/* transform position by ModelView matrix */
- TRANSFORM_POINT( ctx->Light.Light[l].EyePosition,
- ctx->ModelView.m,
- params );
- nParams = 4;
+ TRANSFORM_POINT( l->EyePosition, ctx->ModelView.m, params );
+ if (l->EyePosition[3] != 0.0F)
+ l->_Flags |= LIGHT_POSITIONAL;
+ else
+ l->_Flags &= ~LIGHT_POSITIONAL;
break;
case GL_SPOT_DIRECTION:
/* transform direction by inverse modelview */
if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
gl_matrix_analyze( &ctx->ModelView );
}
- TRANSFORM_NORMAL( ctx->Light.Light[l].EyeDirection,
- params,
- ctx->ModelView.inv );
- nParams = 3;
+ TRANSFORM_NORMAL( l->EyeDirection, params, ctx->ModelView.inv );
break;
case GL_SPOT_EXPONENT:
if (params[0]<0.0 || params[0]>128.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
- if (ctx->Light.Light[l].SpotExponent != params[0]) {
- ctx->Light.Light[l].SpotExponent = params[0];
- gl_compute_spot_exp_table( &ctx->Light.Light[l] );
+ if (l->SpotExponent != params[0]) {
+ l->SpotExponent = params[0];
+ gl_compute_spot_exp_table( l );
}
- nParams = 1;
break;
case GL_SPOT_CUTOFF:
if ((params[0]<0.0 || params[0]>90.0) && params[0]!=180.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
- ctx->Light.Light[l].SpotCutoff = params[0];
- ctx->Light.Light[l]._CosCutoff = cos(params[0]*DEG2RAD);
- if (ctx->Light.Light[l]._CosCutoff < 0)
- ctx->Light.Light[l]._CosCutoff = 0;
- nParams = 1;
+ l->SpotCutoff = params[0];
+ l->_CosCutoff = cos(params[0]*DEG2RAD);
+ if (l->_CosCutoff < 0)
+ l->_CosCutoff = 0;
+ if (l->SpotCutoff != 180.0F)
+ l->_Flags |= LIGHT_SPOT;
+ else
+ l->_Flags &= ~LIGHT_SPOT;
break;
case GL_CONSTANT_ATTENUATION:
if (params[0]<0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
- ctx->Light.Light[l].ConstantAttenuation = params[0];
- nParams = 1;
+ l->ConstantAttenuation = params[0];
break;
case GL_LINEAR_ATTENUATION:
if (params[0]<0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
- ctx->Light.Light[l].LinearAttenuation = params[0];
- nParams = 1;
+ l->LinearAttenuation = params[0];
break;
case GL_QUADRATIC_ATTENUATION:
if (params[0]<0.0) {
gl_error( ctx, GL_INVALID_VALUE, "glLight" );
return;
}
- ctx->Light.Light[l].QuadraticAttenuation = params[0];
- nParams = 1;
+ l->QuadraticAttenuation = params[0];
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glLight" );
@@ -185,7 +177,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
}
if (ctx->Driver.Lightfv)
- ctx->Driver.Lightfv( ctx, light, pname, params, nParams );
+ ctx->Driver.Lightfv( ctx, light, pname, params );
ctx->NewState |= _NEW_LIGHT;
}
@@ -612,11 +604,9 @@ void gl_update_material( GLcontext *ctx,
GLfloat tmp[4];
SUB_3V( tmp, src[0].Specular, mat->Specular );
foreach (light, list) {
- if (light->_Flags & LIGHT_SPECULAR) {
- ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, tmp );
- light->_IsMatSpecular[0] =
- (LEN_SQUARED_3FV(light->_MatSpecular[0]) > 1e-16);
- }
+ ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, tmp );
+ light->_IsMatSpecular[0] =
+ (LEN_SQUARED_3FV(light->_MatSpecular[0]) > 1e-16);
}
COPY_4FV( mat->Specular, src[0].Specular );
}
@@ -625,11 +615,9 @@ void gl_update_material( GLcontext *ctx,
GLfloat tmp[4];
SUB_3V( tmp, src[1].Specular, mat->Specular );
foreach (light, list) {
- if (light->_Flags & LIGHT_SPECULAR) {
- ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, tmp );
- light->_IsMatSpecular[1] =
- (LEN_SQUARED_3FV(light->_MatSpecular[1]) > 1e-16);
- }
+ ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, tmp );
+ light->_IsMatSpecular[1] =
+ (LEN_SQUARED_3FV(light->_MatSpecular[1]) > 1e-16);
}
COPY_4FV( mat->Specular, src[1].Specular );
}
@@ -771,11 +759,9 @@ void gl_update_color_material( GLcontext *ctx,
GLfloat tmp[4];
SUB_3V( tmp, color, mat->Specular );
foreach (light, list) {
- if (light->_Flags & LIGHT_SPECULAR) {
- ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, tmp );
- light->_IsMatSpecular[0] =
- (LEN_SQUARED_3FV(light->_MatSpecular[0]) > 1e-16);
- }
+ ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, tmp );
+ light->_IsMatSpecular[0] =
+ (LEN_SQUARED_3FV(light->_MatSpecular[0]) > 1e-16);
}
COPY_4FV( mat->Specular, color );
}
@@ -785,11 +771,9 @@ void gl_update_color_material( GLcontext *ctx,
GLfloat tmp[4];
SUB_3V( tmp, color, mat->Specular );
foreach (light, list) {
- if (light->_Flags & LIGHT_SPECULAR) {
- ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, tmp );
- light->_IsMatSpecular[1] =
- (LEN_SQUARED_3FV(light->_MatSpecular[1]) > 1e-16);
- }
+ ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, tmp );
+ light->_IsMatSpecular[1] =
+ (LEN_SQUARED_3FV(light->_MatSpecular[1]) > 1e-16);
}
COPY_4FV( mat->Specular, color );
}
@@ -1225,35 +1209,45 @@ void
gl_update_lighting( GLcontext *ctx )
{
struct gl_light *light;
-
+ ctx->_TriangleCaps &= ~(DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
+ ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT;
+ ctx->_NeedNormals &= ~NEED_NORMALS_LIGHT;
ctx->Light._Flags = 0;
+
+ if (!ctx->Light.Enabled)
+ return;
- foreach(light, &ctx->Light.EnabledList) {
-
- light->_Flags = 0;
+ ctx->_NeedNormals |= NEED_NORMALS_LIGHT;
- if (light->EyePosition[3] != 0.0F)
- light->_Flags |= LIGHT_POSITIONAL;
-
- if (LEN_SQUARED_3FV(light->Specular) > 1e-16)
- light->_Flags |= LIGHT_SPECULAR;
-
- if (light->SpotCutoff != 180.0F)
- light->_Flags |= LIGHT_SPOT;
+ if (ctx->Light.Model.TwoSide)
+ ctx->_TriangleCaps |= (DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
+ foreach(light, &ctx->Light.EnabledList) {
ctx->Light._Flags |= light->_Flags;
}
ctx->Light._NeedVertices =
((ctx->Light._Flags & (LIGHT_POSITIONAL|LIGHT_SPOT)) ||
- (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) ||
- (ctx->Light.Model.LocalViewer && (ctx->Light._Flags & LIGHT_SPECULAR)));
-
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
+ ctx->Light.Model.LocalViewer);
+
+ if ((ctx->Light._Flags & LIGHT_POSITIONAL) ||
+ ctx->Light.Model.LocalViewer)
+ ctx->_NeedEyeCoords |= NEED_EYE_LIGHT;
+
+
+ /* XXX: This test is overkill & needs to be fixed both for software and
+ * hardware t&l drivers. The above should be sufficient & should
+ * be tested to verify this.
+ */
+ if (ctx->Light._NeedVertices)
+ ctx->_NeedEyeCoords |= NEED_EYE_LIGHT;
+
/* Precompute some shading values.
*/
if (ctx->Visual.RGBAflag) {
- GLuint sides = ((ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) ? 2 : 1);
+ GLuint sides = ctx->Light.Model.TwoSide ? 2 : 1;
GLuint side;
for (side=0; side < sides; side++) {
struct gl_material *mat = &ctx->Light.Material[side];
@@ -1272,14 +1266,10 @@ gl_update_lighting( GLcontext *ctx )
const struct gl_material *mat = &ctx->Light.Material[side];
SCALE_3V( light->_MatDiffuse[side], light->Diffuse, mat->Diffuse );
SCALE_3V( light->_MatAmbient[side], light->Ambient, mat->Ambient );
- if (light->_Flags & LIGHT_SPECULAR) {
- SCALE_3V( light->_MatSpecular[side], light->Specular,
- mat->Specular);
- light->_IsMatSpecular[side] =
- (LEN_SQUARED_3FV(light->_MatSpecular[side]) > 1e-16);
- }
- else
- light->_IsMatSpecular[side] = 0;
+ SCALE_3V( light->_MatSpecular[side], light->Specular,
+ mat->Specular);
+ light->_IsMatSpecular[side] =
+ (LEN_SQUARED_3FV(light->_MatSpecular[side]) > 1e-16);
}
}
}
@@ -1290,28 +1280,34 @@ gl_update_lighting( GLcontext *ctx )
light->_sli = DOT3(ci, light->Specular);
}
}
-}
+ gl_update_lighting_function(ctx);
+}
-/* Need to seriously restrict the circumstances under which these
- * calc's are performed.
+/* _NEW_MODELVIEW
+ * _NEW_LIGHT
+ * _TNL_NEW_NEED_EYE_COORDS
+ *
+ * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled.
+ * Also update on lighting space changes.
*/
void
gl_compute_light_positions( GLcontext *ctx )
{
struct gl_light *light;
-
- if (1 /*ctx->Light.NeedVertices && !ctx->Light.Model.LocalViewer*/) {
- static const GLfloat eye_z[3] = { 0, 0, 1 };
- if (ctx->_NeedEyeCoords) {
- COPY_3V( ctx->_EyeZDir, eye_z );
- }
- else {
- TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelView.m );
- }
- }
+ static const GLfloat eye_z[3] = { 0, 0, 1 };
+
+ if (!ctx->Light.Enabled)
+ return;
+ if (ctx->_NeedEyeCoords) {
+ COPY_3V( ctx->_EyeZDir, eye_z );
+ }
+ else {
+ TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelView.m );
+ }
+
foreach (light, &ctx->Light.EnabledList) {
if (ctx->_NeedEyeCoords) {
@@ -1336,7 +1332,7 @@ gl_compute_light_positions( GLcontext *ctx )
}
if (light->_Flags & LIGHT_SPOT) {
- if (ctx->_NeedEyeNormals) {
+ if (ctx->_NeedEyeCoords) {
COPY_3V( light->_NormDirection, light->EyeDirection );
}
else {
@@ -1347,9 +1343,6 @@ gl_compute_light_positions( GLcontext *ctx )
NORMALIZE_3FV( light->_NormDirection );
-
- /* Unlikely occurrance?
- */
if (!(light->_Flags & LIGHT_POSITIONAL)) {
GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm,
light->_NormDirection);
@@ -1370,52 +1363,51 @@ gl_compute_light_positions( GLcontext *ctx )
}
+/* _NEW_TRANSFORM
+ * _NEW_MODELVIEW
+ * _TNL_NEW_NEED_NORMALS
+ * _TNL_NEW_NEED_EYE_COORDS
+ *
+ * Update on (_NEW_TRANSFORM|_NEW_MODELVIEW)
+ * And also on NewLightingSpaces() callback.
+ */
void
gl_update_normal_transform( GLcontext *ctx )
{
- ctx->_vb_rescale_factor = 1.0;
+
+ if (!ctx->_NeedNormals) {
+ ctx->_NormalTransform = 0;
+ return;
+ }
if (ctx->_NeedEyeCoords) {
- if (ctx->_NeedNormals) {
- GLuint transform = NORM_TRANSFORM_NO_ROT;
-
- if (ctx->ModelView.flags & (MAT_FLAG_GENERAL |
- MAT_FLAG_ROTATION |
- MAT_FLAG_GENERAL_3D |
- MAT_FLAG_PERSPECTIVE))
- transform = NORM_TRANSFORM;
+ GLuint transform = NORM_TRANSFORM_NO_ROT;
+
+ if (ctx->ModelView.flags & (MAT_FLAG_GENERAL |
+ MAT_FLAG_ROTATION |
+ MAT_FLAG_GENERAL_3D |
+ MAT_FLAG_PERSPECTIVE))
+ transform = NORM_TRANSFORM;
- ctx->_vb_rescale_factor = ctx->_rescale_factor;
- if (ctx->Transform.Normalize) {
- ctx->_NormalTransform = gl_normal_tab[transform | NORM_NORMALIZE];
- }
- else if (ctx->Transform.RescaleNormals &&
- ctx->_rescale_factor != 1.0) {
- ctx->_NormalTransform = gl_normal_tab[transform | NORM_RESCALE];
- }
- else {
- ctx->_NormalTransform = gl_normal_tab[transform];
- }
+ if (ctx->Transform.Normalize) {
+ ctx->_NormalTransform = gl_normal_tab[transform | NORM_NORMALIZE];
+ }
+ else if (ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0) {
+ ctx->_NormalTransform = gl_normal_tab[transform | NORM_RESCALE];
}
else {
- ctx->_NormalTransform = 0;
+ ctx->_NormalTransform = gl_normal_tab[transform];
}
}
else {
- if (ctx->_NeedNormals) {
- ctx->_vb_rescale_factor = 1.0/ctx->_rescale_factor;
-
- if (ctx->Transform.Normalize) {
- ctx->_NormalTransform = gl_normal_tab[NORM_NORMALIZE];
- }
- else if (!ctx->Transform.RescaleNormals &&
- ctx->_rescale_factor != 1.0) {
- ctx->_NormalTransform = gl_normal_tab[NORM_RESCALE];
- }
- else {
- ctx->_NormalTransform = 0;
- }
+ if (ctx->Transform.Normalize) {
+ ctx->_NormalTransform = gl_normal_tab[NORM_NORMALIZE];
+ }
+ else if (!ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0) {
+ ctx->_NormalTransform = gl_normal_tab[NORM_RESCALE];
}
else {
ctx->_NormalTransform = 0;
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index c161e847eb..7cf464e07b 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -1,4 +1,4 @@
-/* $Id: matrix.c,v 1.24 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: matrix.c,v 1.25 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -930,16 +930,6 @@ static void mat_mul_floats( GLmatrix *mat, const GLfloat *m, GLuint flags )
}
-void gl_calculate_model_project_matrix( GLcontext *ctx )
-{
- gl_matrix_mul( &ctx->_ModelProjectMatrix,
- &ctx->ProjectionMatrix,
- &ctx->ModelView );
-
- gl_matrix_analyze( &ctx->_ModelProjectMatrix );
-}
-
-
void gl_matrix_ctr( GLmatrix *m )
{
if ( m->m == 0 ) {
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index 27b9d8d77d..f5923374b7 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -1,4 +1,4 @@
-/* $Id: points.c,v 1.20 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: points.c,v 1.21 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -89,6 +89,7 @@ _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
if (tmp != ctx->Point._Attenuated) {
ctx->_Enabled ^= ENABLE_POINT_ATTEN;
ctx->_TriangleCaps ^= DD_POINT_ATTEN;
+ ctx->_NeedEyeCoords ^= NEED_EYE_POINT_ATTEN;
}
}
break;
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 1610b02574..e8d36a3ba0 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -1,4 +1,4 @@
-/* $Id: rastpos.c,v 1.12 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: rastpos.c,v 1.13 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -68,15 +68,10 @@ static void raster_pos4f( GLcontext *ctx,
/* raster color */
if (ctx->Light.Enabled)
{
- /*GLfloat *vert;*/
GLfloat *norm, eyenorm[3];
GLfloat *objnorm = ctx->Current.Normal;
- /* Not needed???
- vert = (ctx->_NeedEyeCoords ? eye : v);
- */
-
- if (ctx->_NeedEyeNormals) {
+ if (ctx->_NeedEyeCoords) {
GLfloat *inv = ctx->ModelView.inv;
TRANSFORM_NORMAL( eyenorm, objnorm, inv );
norm = eyenorm;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 1cd88a7b73..7071c0ad6f 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.42 2000/11/10 18:31:04 brianp Exp $ */
+/* $Id: state.c,v 1.43 2000/11/13 20:02:56 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -747,264 +747,348 @@ void gl_print_enable_flags( const char *msg, GLuint flags )
}
-/*
- * If ctx->NewState is non-zero then this function MUST be called before
- * rendering any primitive. Basically, function pointers and miscellaneous
- * flags are updated to reflect the current state of the state machine.
+/* Note: This routine refers to derived texture attribute values to
+ * compute the ENABLE_TEXMAT flags, but is only called on
+ * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT
+ * flags are updated by _mesa_update_textures(), below.
+ *
+ * If both TEXTURE and TEXTURE_MATRIX change at once, these values
+ * will be computed twice.
*/
-void gl_update_state( GLcontext *ctx )
+static void
+_mesa_update_texture_matrices( GLcontext *ctx )
{
GLuint i;
- if (MESA_VERBOSE & VERBOSE_STATE)
- gl_print_state("", ctx->NewState);
+ ctx->_Enabled &= ~(ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | ENABLE_TEXMAT2);
- if (ctx->NewState & (_NEW_PIXEL|_NEW_COLOR_MATRIX))
- _mesa_update_image_transfer_state(ctx);
+ for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) {
+ gl_matrix_analyze( &ctx->TextureMatrix[i] );
+ ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS;
- if (ctx->NewState & _NEW_ARRAY)
- gl_update_client_state( ctx );
+ if (ctx->Texture.Unit[i]._ReallyEnabled &&
+ ctx->TextureMatrix[i].type != MATRIX_IDENTITY)
+ ctx->_Enabled |= ENABLE_TEXMAT0 << i;
+ }
+ }
+}
- if (ctx->NewState & _NEW_TEXTURE_MATRIX) {
- ctx->_Enabled &= ~(ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | ENABLE_TEXMAT2);
- for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
- if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) {
- gl_matrix_analyze( &ctx->TextureMatrix[i] );
- ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS;
+/* Note: This routine refers to derived texture matrix values to
+ * compute the ENABLE_TEXMAT flags, but is only called on
+ * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT
+ * flags are updated by _mesa_update_texture_matrices, above.
+ *
+ * If both TEXTURE and TEXTURE_MATRIX change at once, these values
+ * will be computed twice.
+ */
+static void
+_mesa_update_textures( GLcontext *ctx )
+{
+ GLuint i;
+
+ ctx->Texture._ReallyEnabled = 0;
+ ctx->_Enabled &= ~(ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | ENABLE_TEXGEN2 |
+ ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | ENABLE_TEXMAT2 |
+ ENABLE_TEX0 | ENABLE_TEX1 | ENABLE_TEX2);
- if (ctx->Texture.Unit[i].Enabled &&
- ctx->TextureMatrix[i].type != MATRIX_IDENTITY)
- ctx->_Enabled |= ENABLE_TEXMAT0 << i;
- }
- }
- }
+ gl_update_dirty_texobjs(ctx);
- if (ctx->NewState & _NEW_TEXTURE) {
- ctx->Texture._MultiTextureEnabled = GL_FALSE;
- ctx->Texture._NeedNormals = GL_FALSE;
- gl_update_dirty_texobjs(ctx);
- ctx->_Enabled &= ~(ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | ENABLE_TEXGEN2);
- ctx->Texture._ReallyEnabled = 0;
+ for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
+
+ ctx->Texture.Unit[i]._ReallyEnabled = 0;
- for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
- if (ctx->Texture.Unit[i].Enabled) {
- gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] );
+ if (ctx->Texture.Unit[i].Enabled) {
- ctx->Texture._ReallyEnabled |=
- ctx->Texture.Unit[i]._ReallyEnabled << (i * 4);
+ gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] );
- if (ctx->Texture.Unit[i]._GenFlags != 0) {
- ctx->_Enabled |= ENABLE_TEXGEN0 << i;
+ if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ GLuint flag = ctx->Texture.Unit[i]._ReallyEnabled << (i * 4);
- if (ctx->Texture.Unit[i]._GenFlags & TEXGEN_NEED_NORMALS) {
- ctx->Texture._NeedNormals = GL_TRUE;
- ctx->Texture._NeedEyeCoords = GL_TRUE;
- }
+ ctx->Texture._ReallyEnabled |= flag;
+ ctx->_Enabled |= flag;
- if (ctx->Texture.Unit[i]._GenFlags & TEXGEN_NEED_EYE_COORD) {
- ctx->Texture._NeedEyeCoords = GL_TRUE;
- }
+ if (ctx->Texture.Unit[i]._GenFlags) {
+ ctx->_Enabled |= ENABLE_TEXGEN0 << i;
+ ctx->Texture._GenFlags |= ctx->Texture.Unit[i]._GenFlags;
}
- if (i > 0 && ctx->Texture.Unit[i]._ReallyEnabled) {
- ctx->Texture._MultiTextureEnabled = GL_TRUE;
- }
+ if (ctx->TextureMatrix[i].type != MATRIX_IDENTITY)
+ ctx->_Enabled |= ENABLE_TEXMAT0 << i;
}
- else {
- ctx->Texture.Unit[i]._ReallyEnabled = 0;
- }
}
- ctx->_Enabled = ((ctx->_Enabled & ~ENABLE_TEX_ANY) |
- ctx->Texture._ReallyEnabled);
- ctx->_NeedNormals = (ctx->Light.Enabled || ctx->Texture._NeedNormals);
}
+ ctx->_NeedNormals &= ~NEED_NORMALS_TEXGEN;
+ ctx->_NeedEyeCoords &= ~NEED_EYE_TEXGEN;
- if (ctx->NewState & (_NEW_BUFFERS|_NEW_SCISSOR)) {
- /* update scissor region */
- ctx->DrawBuffer->Xmin = 0;
- ctx->DrawBuffer->Ymin = 0;
- ctx->DrawBuffer->Xmax = ctx->DrawBuffer->Width;
- ctx->DrawBuffer->Ymax = ctx->DrawBuffer->Height;
- if (ctx->Scissor.Enabled) {
- if (ctx->Scissor.X > ctx->DrawBuffer->Xmin) {
- ctx->DrawBuffer->Xmin = ctx->Scissor.X;
- }
- if (ctx->Scissor.Y > ctx->DrawBuffer->Ymin) {
- ctx->DrawBuffer->Ymin = ctx->Scissor.Y;
- }
- if (ctx->Scissor.X + ctx->Scissor.Width < ctx->DrawBuffer->Xmax) {
- ctx->DrawBuffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width;
- }
- if (ctx->Scissor.Y + ctx->Scissor.Height < ctx->DrawBuffer->Ymax) {
- ctx->DrawBuffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
- }
- }
+ if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) {
+ ctx->_NeedNormals |= NEED_NORMALS_TEXGEN;
+ ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN;
+ }
+
+ if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) {
+ ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN;
}
+}
- if (ctx->NewState & _NEW_LIGHT) {
- ctx->_TriangleCaps &= ~(DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
- if (ctx->Light.Enabled) {
- if (ctx->Light.Model.TwoSide)
- ctx->_TriangleCaps |= (DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
- gl_update_lighting(ctx);
+static void
+_mesa_update_polygon( GLcontext *ctx )
+{
+ ctx->_TriangleCaps &= ~DD_TRI_CULL_FRONT_BACK;
+
+ /* Setup CullBits bitmask */
+ if (ctx->Polygon.CullFlag) {
+ switch(ctx->Polygon.CullFaceMode) {
+ case GL_BACK:
+ ctx->Polygon._CullBits = 1;
+ break;
+ case GL_FRONT:
+ ctx->Polygon._CullBits = 2;
+ break;
+ default:
+ case GL_FRONT_AND_BACK:
+ ctx->Polygon._CullBits = 0;
+ ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
+ break;
}
}
+ else {
+ ctx->Polygon._CullBits = 3;
+ }
- if (ctx->NewState & (_NEW_POLYGON | _NEW_LIGHT)) {
-
-
- if (ctx->NewState & _NEW_POLYGON) {
- ctx->_TriangleCaps &= ~DD_TRI_CULL_FRONT_BACK;
-
- /* Setup CullBits bitmask */
- if (ctx->Polygon.CullFlag) {
- ctx->_backface_sign = 1;
- switch(ctx->Polygon.CullFaceMode) {
- case GL_BACK:
- if(ctx->Polygon.FrontFace==GL_CCW)
- ctx->_backface_sign = -1;
- ctx->Polygon._CullBits = 1;
- break;
- case GL_FRONT:
- if(ctx->Polygon.FrontFace!=GL_CCW)
- ctx->_backface_sign = -1;
- ctx->Polygon._CullBits = 2;
- break;
- default:
- case GL_FRONT_AND_BACK:
- ctx->_backface_sign = 0;
- ctx->Polygon._CullBits = 0;
- ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
- break;
- }
- }
- else {
- ctx->Polygon._CullBits = 3;
- ctx->_backface_sign = 0;
- }
+ /* Any Polygon offsets enabled? */
+ ctx->_TriangleCaps &= ~DD_TRI_OFFSET;
- /* Any Polygon offsets enabled? */
- ctx->_TriangleCaps &= ~DD_TRI_OFFSET;
+ if (ctx->Polygon.OffsetPoint ||
+ ctx->Polygon.OffsetLine ||
+ ctx->Polygon.OffsetFill)
+ ctx->_TriangleCaps |= DD_TRI_OFFSET;
+}
- if (ctx->Polygon.OffsetPoint ||
- ctx->Polygon.OffsetLine ||
- ctx->Polygon.OffsetFill)
- ctx->_TriangleCaps |= DD_TRI_OFFSET;
- }
+static void
+_mesa_calculate_model_project_matrix( GLcontext *ctx )
+{
+ if (!ctx->_NeedEyeCoords) {
+ gl_matrix_mul( &ctx->_ModelProjectMatrix,
+ &ctx->ProjectionMatrix,
+ &ctx->ModelView );
+
+ gl_matrix_analyze( &ctx->_ModelProjectMatrix );
}
+}
- if (ctx->NewState & (_NEW_LIGHT|
- _NEW_TEXTURE|
- _NEW_FOG|
- _NEW_POLYGON))
- gl_update_clipmask(ctx);
+static void
+_mesa_update_modelview_scale( GLcontext *ctx )
+{
+ ctx->_ModelViewInvScale = 1.0F;
+ if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE |
+ MAT_FLAG_GENERAL_SCALE |
+ MAT_FLAG_GENERAL_3D |
+ MAT_FLAG_GENERAL) ) {
+ const GLfloat *m = ctx->ModelView.inv;
+ GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
+ if (f < 1e-12) f = 1.0;
+ if (ctx->_NeedEyeCoords)
+ ctx->_ModelViewInvScale = 1.0/GL_SQRT(f);
+ else
+ ctx->_ModelViewInvScale = GL_SQRT(f);
+ }
+}
- if (ctx->NewState & ctx->Driver.UpdateStateNotify)
+
+/* Bring uptodate any state that relies on _NeedEyeCoords.
+ */
+static void
+_mesa_update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords )
+{
+ /* Check if the truth-value interpretations of the bitfields have
+ * changed:
+ */
+ if ((oldneedeyecoords == 0) != (ctx->_NeedEyeCoords == 0))
{
- /*
- * Here the driver sets up all the ctx->Driver function pointers to
- * it's specific, private functions.
+ /* Recalculate all state that depends on _NeedEyeCoords.
*/
- ctx->Driver.UpdateState(ctx);
- gl_set_render_vb_function(ctx); /* fix me */
+ _mesa_update_modelview_scale(ctx);
+ _mesa_calculate_model_project_matrix(ctx);
+ gl_update_normal_transform( ctx );
+ gl_compute_light_positions( ctx );
+
+ if (ctx->Driver.LightingSpaceChange)
+ ctx->Driver.LightingSpaceChange( ctx );
}
+ else
+ {
+ GLuint new_state = ctx->NewState;
- /* Should only be calc'd when !need_eye_coords and not culling.
- */
- if (ctx->NewState & (_NEW_MODELVIEW|_NEW_PROJECTION)) {
- if (ctx->NewState & _NEW_MODELVIEW) {
- gl_matrix_analyze( &ctx->ModelView );
- ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS;
+ /* Recalculate that same state if and only if it has been
+ * invalidated by other statechanges.
+ */
+ if (new_state & _NEW_MODELVIEW)
+ _mesa_update_modelview_scale(ctx);
+
+ if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
+ _mesa_calculate_model_project_matrix(ctx);
+
+ if (new_state & _TNL_NEW_NORMAL_TRANSFORM)
+ gl_update_normal_transform( ctx ); /* references _ModelViewInvScale */
+
+ if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW))
+ gl_compute_light_positions( ctx );
+ }
+}
+
+
+static void
+_mesa_update_drawbuffer( GLcontext *ctx )
+{
+ ctx->DrawBuffer->_Xmin = 0;
+ ctx->DrawBuffer->_Ymin = 0;
+ ctx->DrawBuffer->_Xmax = ctx->DrawBuffer->Width;
+ ctx->DrawBuffer->_Ymax = ctx->DrawBuffer->Height;
+ if (ctx->Scissor.Enabled) {
+ if (ctx->Scissor.X > ctx->DrawBuffer->_Xmin) {
+ ctx->DrawBuffer->_Xmin = ctx->Scissor.X;
+ }
+ if (ctx->Scissor.Y > ctx->DrawBuffer->_Ymin) {
+ ctx->DrawBuffer->_Ymin = ctx->Scissor.Y;
+ }
+ if (ctx->Scissor.X + ctx->Scissor.Width < ctx->DrawBuffer->_Xmax) {
+ ctx->DrawBuffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
}
+ if (ctx->Scissor.Y + ctx->Scissor.Height < ctx->DrawBuffer->_Ymax) {
+ ctx->DrawBuffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
+ }
+ }
+}
- if (ctx->NewState & _NEW_PROJECTION) {
- gl_matrix_analyze( &ctx->ProjectionMatrix );
- ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS;
- if (ctx->Transform._AnyClip) {
- gl_update_userclip( ctx );
+/* NOTE: This routine references Tranform attribute values to compute
+ * userclip positions in clip space, but is only called on
+ * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values
+ * uptodate across changes to the Transform attributes.
+ */
+static void
+_mesa_update_projection( GLcontext *ctx )
+{
+ gl_matrix_analyze( &ctx->ProjectionMatrix );
+
+ /* Recompute clip plane positions in clipspace. This is also done
+ * in _mesa_ClipPlane().
+ */
+ if (ctx->Transform._AnyClip) {
+ GLuint p;
+ for (p = 0 ; p < MAX_CLIP_PLANES ; p++) {
+ if (ctx->Transform.ClipEnabled[p]) {
+ gl_transform_vector( ctx->Transform._ClipUserPlane[p],
+ ctx->Transform.EyeUserPlane[p],
+ ctx->ProjectionMatrix.inv );
}
}
-
- gl_calculate_model_project_matrix( ctx );
}
+}
+
+
+
+
+/*
+ * If ctx->NewState is non-zero then this function MUST be called before
+ * rendering any primitive. Basically, function pointers and miscellaneous
+ * flags are updated to reflect the current state of the state machine.
+ *
+ * Special care is taken with the derived value _NeedEyeCoords. These
+ * is a bitflag which is updated with information from a number of
+ * attribute groups (MODELVIEW, LIGHT, TEXTURE). A lot of derived
+ * state references this value, and must be treated with care to
+ * ensure that updates are done correctly. All state dependent on
+ * _NeedEyeCoords is calculated from within _mesa_update_tnl_spaces(),
+ * and from nowhere else.
+ */
+void gl_update_state( GLcontext *ctx )
+{
+ GLuint new_state = ctx->NewState;
+ GLuint oldneedeyecoords = ctx->_NeedEyeCoords;
+
+ if (MESA_VERBOSE & VERBOSE_STATE)
+ gl_print_state("", new_state);
+
+ if (new_state & _NEW_MODELVIEW)
+ gl_matrix_analyze( &ctx->ModelView );
+
+ if (new_state & _NEW_PROJECTION)
+ _mesa_update_projection( ctx );
- if (ctx->NewState & _NEW_COLOR_MATRIX) {
+ if (new_state & _NEW_TEXTURE_MATRIX)
+ _mesa_update_texture_matrices( ctx );
+
+ if (new_state & _NEW_COLOR_MATRIX)
gl_matrix_analyze( &ctx->ColorMatrix );
- }
+
+ /* References ColorMatrix.type (derived above).
+ */
+ if (new_state & (_NEW_PIXEL|_NEW_COLOR_MATRIX))
+ _mesa_update_image_transfer_state(ctx);
+
+ if (new_state & _NEW_ARRAY)
+ gl_update_client_state( ctx );
- /* Figure out whether we can light in object space or not. If we
- * can, find the current positions of the lights in object space
+ /* Contributes to NeedEyeCoords, NeedNormals.
*/
- if ((ctx->_Enabled & (ENABLE_POINT_ATTEN | ENABLE_LIGHT | ENABLE_FOG |
- ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | ENABLE_TEXGEN2)) &&
- (ctx->NewState & (_NEW_LIGHT |
- _NEW_TEXTURE |
- _NEW_FOG |
- _NEW_TRANSFORM |
- _NEW_MODELVIEW |
- _NEW_PROJECTION |
- _NEW_POINT |
- _NEW_RENDERMODE |
- _NEW_TRANSFORM)))
- {
- GLboolean oldcoord, oldnorm;
-
- oldcoord = ctx->_NeedEyeCoords;
- oldnorm = ctx->_NeedEyeNormals;
-
- ctx->_NeedNormals = (ctx->Light.Enabled || ctx->Texture._NeedNormals);
- ctx->_NeedEyeCoords = (ctx->Fog.Enabled || ctx->Point._Attenuated);
- ctx->_NeedEyeNormals = GL_FALSE;
-
- if (ctx->Light.Enabled) {
- if ((ctx->Light._Flags & LIGHT_POSITIONAL) ||
- ctx->Light._NeedVertices ||
- !TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING)) {
- /* Need length for attenuation or need angle for spotlights
- * or non-uniform scale matrix
- */
- ctx->_NeedEyeCoords = GL_TRUE;
- }
- ctx->_NeedEyeNormals = ctx->_NeedEyeCoords;
- }
- if (ctx->Texture._ReallyEnabled || ctx->RenderMode==GL_FEEDBACK) {
- if (ctx->Texture._NeedEyeCoords) ctx->_NeedEyeCoords = GL_TRUE;
- if (ctx->Texture._NeedNormals)
- ctx->_NeedNormals = ctx->_NeedEyeNormals = GL_TRUE;
- }
+ if (new_state & _NEW_TEXTURE)
+ _mesa_update_textures( ctx );
- if (ctx->_NeedEyeCoords)
- ctx->_vb_proj_matrix = &ctx->ProjectionMatrix;
- else
- ctx->_vb_proj_matrix = &ctx->_ModelProjectMatrix;
+ if (new_state & (_NEW_BUFFERS|_NEW_SCISSOR))
+ _mesa_update_drawbuffer( ctx );
- if (ctx->Light.Enabled) {
- gl_update_lighting_function(ctx);
+ if (new_state & _NEW_POLYGON)
+ _mesa_update_polygon( ctx );
- if ( (ctx->NewState & _NEW_LIGHT) ||
- ((ctx->NewState & (_NEW_MODELVIEW|_NEW_PROJECTION)) &&
- !ctx->_NeedEyeCoords) ||
- oldcoord != ctx->_NeedEyeCoords ||
- oldnorm != ctx->_NeedEyeNormals) {
- gl_compute_light_positions(ctx);
- }
+ /* Contributes to NeedEyeCoords, NeedNormals.
+ */
+ if (new_state & _NEW_LIGHT)
+ gl_update_lighting( ctx );
- ctx->_rescale_factor = 1.0F;
- if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE |
- MAT_FLAG_GENERAL_SCALE |
- MAT_FLAG_GENERAL_3D |
- MAT_FLAG_GENERAL) ) {
- const GLfloat *m = ctx->ModelView.inv;
- const GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
- if (f > 1e-12 && (f - 1.0) * (f - 1.0) > 1e-12)
- ctx->_rescale_factor = 1.0 / GL_SQRT(f);
- }
- }
+ if (new_state & (_NEW_LIGHT|_NEW_TEXTURE|_NEW_FOG|
+ _DD_NEW_TRI_LIGHT_TWOSIDE |
+ _DD_NEW_SEPERATE_SPECULAR |
+ _DD_NEW_TRI_UNFILLED ))
+ gl_update_clipmask(ctx);
+
+ /* We can light in object space if the modelview matrix preserves
+ * lengths and relative angles.
+ */
+ if (new_state & (_NEW_MODELVIEW|_NEW_LIGHT)) {
+ ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT_MODELVIEW;
+ if (ctx->Light.Enabled &&
+ !TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING))
+ ctx->_NeedEyeCoords |= NEED_EYE_LIGHT_MODELVIEW;
+ }
- gl_update_normal_transform( ctx );
+ /* ctx->_NeedEyeCoords and ctx->_NeedEyeNormals are now uptodate.
+ *
+ * If the truth value of either has changed, update for the new
+ * lighting space and recompute the positions of lights and the
+ * normal transform.
+ *
+ * If the lighting space hasn't changed, may still need to recompute
+ * light positions & normal transforms for other reasons.
+ */
+ if (new_state & (_NEW_MODELVIEW |
+ _NEW_PROJECTION |
+ _TNL_NEW_NORMAL_TRANSFORM |
+ _NEW_LIGHT |
+ _TNL_NEW_NEED_EYE_COORDS))
+ _mesa_update_tnl_spaces( ctx, oldneedeyecoords );
+
+ if (new_state & ctx->Driver.UpdateStateNotify)
+ {
+ /*
+ * Here the driver sets up all the ctx->Driver function pointers to
+ * it's specific, private functions.
+ */
+ ctx->Driver.UpdateState(ctx);
+ gl_set_render_vb_function(ctx); /* XXX: remove this mechanism */
}
gl_update_pipelines(ctx);