summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/attrib.c41
-rw-r--r--src/mesa/main/attrib.h3
-rw-r--r--src/mesa/main/dd.h6
-rw-r--r--src/mesa/main/enable.c7
-rw-r--r--src/mesa/main/light.c14
-rw-r--r--src/mesa/main/macros.h9
-rw-r--r--src/mesa/main/mtypes.h3
-rw-r--r--src/mesa/main/state.c42
-rw-r--r--src/mesa/main/state.h4
9 files changed, 94 insertions, 35 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 81365a6153..139a5d030f 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.59 2002/01/05 21:53:20 brianp Exp $ */
+/* $Id: attrib.c,v 1.60 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -52,6 +52,7 @@
#include "texobj.h"
#include "texstate.h"
#include "mtypes.h"
+#include "math/m_xform.h"
#endif
@@ -917,11 +918,30 @@ _mesa_PopAttrib(void)
/* lighting enable */
_mesa_set_enable(ctx, GL_LIGHTING, light->Enabled);
/* per-light state */
+
+ if (ctx->ModelviewMatrixStack.Top->flags & MAT_DIRTY_INVERSE)
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+
for (i = 0; i < MAX_LIGHTS; i++) {
GLenum lgt = (GLenum) (GL_LIGHT0 + i);
- _mesa_set_enable(ctx, lgt, light->Light[i].Enabled);
- MEMCPY(&ctx->Light.Light[i], &light->Light[i],
- sizeof(struct gl_light));
+ const struct gl_light *l = &light->Light[i];
+ GLfloat tmp[4];
+ _mesa_set_enable(ctx, lgt, l->Enabled);
+ _mesa_Lightfv( lgt, GL_AMBIENT, l->Ambient );
+ _mesa_Lightfv( lgt, GL_DIFFUSE, l->Diffuse );
+ _mesa_Lightfv( lgt, GL_SPECULAR, l->Specular );
+ TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->inv, l->EyePosition );
+ _mesa_Lightfv( lgt, GL_POSITION, tmp );
+ TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->m, l->EyeDirection );
+ _mesa_Lightfv( lgt, GL_SPOT_DIRECTION, tmp );
+ _mesa_Lightfv( lgt, GL_SPOT_EXPONENT, &l->SpotExponent );
+ _mesa_Lightfv( lgt, GL_SPOT_CUTOFF, &l->SpotCutoff );
+ _mesa_Lightfv( lgt, GL_CONSTANT_ATTENUATION,
+ &l->ConstantAttenuation );
+ _mesa_Lightfv( lgt, GL_LINEAR_ATTENUATION,
+ &l->LinearAttenuation );
+ _mesa_Lightfv( lgt, GL_QUADRATIC_ATTENUATION,
+ &l->QuadraticAttenuation );
}
/* light model */
_mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT,
@@ -1030,15 +1050,16 @@ _mesa_PopAttrib(void)
const struct gl_transform_attrib *xform;
xform = (const struct gl_transform_attrib *) attr->data;
_mesa_MatrixMode(xform->MatrixMode);
- /* clip planes */
- MEMCPY(ctx->Transform.EyeUserPlane, xform->EyeUserPlane,
- sizeof(xform->EyeUserPlane));
- MEMCPY(ctx->Transform._ClipUserPlane, xform->_ClipUserPlane,
- sizeof(xform->EyeUserPlane));
- /* clip plane enable flags */
for (i = 0; i < MAX_CLIP_PLANES; i++) {
+ GLdouble equation[4];
+ const GLfloat *eq = xform->EyeUserPlane[i];
_mesa_set_enable(ctx, GL_CLIP_PLANE0 + i,
xform->ClipEnabled[i]);
+ equation[0] = (GLdouble) eq[0];
+ equation[1] = (GLdouble) eq[1];
+ equation[2] = (GLdouble) eq[2];
+ equation[3] = (GLdouble) eq[3];
+ _mesa_ClipPlane( GL_CLIP_PLANE0 + i, equation );
}
/* normalize/rescale */
_mesa_set_enable(ctx, GL_NORMALIZE, ctx->Transform.Normalize);
diff --git a/src/mesa/main/attrib.h b/src/mesa/main/attrib.h
index 5ce75fcd91..fabe3e0d03 100644
--- a/src/mesa/main/attrib.h
+++ b/src/mesa/main/attrib.h
@@ -1,4 +1,4 @@
-/* $Id: attrib.h,v 1.5 2001/03/12 00:48:37 gareth Exp $ */
+/* $Id: attrib.h,v 1.6 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,7 +31,6 @@
#include "mtypes.h"
-
extern void
_mesa_PushAttrib( GLbitfield mask );
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index f22aa94319..b96a132b42 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.65 2001/12/14 02:50:01 brianp Exp $ */
+/* $Id: dd.h,v 1.66 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -474,10 +474,11 @@ struct dd_function_table {
void (*ClearDepth)(GLcontext *ctx, GLclampd d);
void (*ClearIndex)(GLcontext *ctx, GLuint index);
void (*ClearStencil)(GLcontext *ctx, GLint s);
+ void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
GLboolean bmask, GLboolean amask );
+ void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode);
void (*CullFace)(GLcontext *ctx, GLenum mode);
- void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
void (*FrontFace)(GLcontext *ctx, GLenum mode);
void (*DepthFunc)(GLcontext *ctx, GLenum func);
void (*DepthMask)(GLcontext *ctx, GLboolean flag);
@@ -634,7 +635,6 @@ struct dd_function_table {
void (*UnlockArraysEXT)( GLcontext *ctx );
/* Called by glLockArraysEXT() and glUnlockArraysEXT(), respectively.
*/
-
};
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 755f74ac39..366c2cef84 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.56 2002/01/22 18:40:46 brianp Exp $ */
+/* $Id: enable.c,v 1.57 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -307,6 +307,11 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.Enabled = state;
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
+ else
+ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
+
if ((ctx->Light.Enabled &&
ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
|| ctx->Fog.ColorSumEnabled)
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 9286642d3a..ee9d9d177e 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.48 2001/12/18 04:06:45 brianp Exp $ */
+/* $Id: light.c,v 1.49 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -407,6 +407,11 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.Model.TwoSide = newbool;
+
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
+ else
+ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
break;
case GL_LIGHT_MODEL_COLOR_CONTROL:
if (params[0] == (GLfloat) GL_SINGLE_COLOR)
@@ -883,6 +888,9 @@ _mesa_ColorMaterial( GLenum face, GLenum mode )
FLUSH_CURRENT( ctx, 0 );
_mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
}
+
+ if (ctx->Driver.ColorMaterial)
+ (*ctx->Driver.ColorMaterial)( ctx, face, mode );
}
@@ -1162,7 +1170,6 @@ void
_mesa_update_lighting( GLcontext *ctx )
{
struct gl_light *light;
- ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT;
ctx->_NeedNormals &= ~NEED_NORMALS_LIGHT;
ctx->Light._Flags = 0;
@@ -1172,9 +1179,6 @@ _mesa_update_lighting( GLcontext *ctx )
ctx->_NeedNormals |= NEED_NORMALS_LIGHT;
- if (ctx->Light.Model.TwoSide)
- ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
-
foreach(light, &ctx->Light.EnabledList) {
ctx->Light._Flags |= light->_Flags;
}
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index d4cd6b858a..bb83b30d5d 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -1,4 +1,4 @@
-/* $Id: macros.h,v 1.24 2001/06/11 07:52:51 joukj Exp $ */
+/* $Id: macros.h,v 1.25 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -270,6 +270,13 @@ do { \
(DST)[2] = (SRCA)[2] * (SRCB)[2]; \
} while (0)
+#define SELF_SCALE_3V( DST, SRC ) \
+do { \
+ (DST)[0] *= (SRC)[0]; \
+ (DST)[1] *= (SRC)[1]; \
+ (DST)[2] *= (SRC)[2]; \
+} while (0)
+
#define ACC_3V( DST, SRC ) \
do { \
(DST)[0] += (SRC)[0]; \
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0dec13c3ae..14b9f0188a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.63 2002/01/22 14:35:16 brianp Exp $ */
+/* $Id: mtypes.h,v 1.64 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1591,6 +1591,7 @@ struct matrix_stack
#define NEED_EYE_LIGHT 0x2
#define NEED_EYE_LIGHT_MODELVIEW 0x4
#define NEED_EYE_POINT_ATTEN 0x8
+#define NEED_EYE_DRIVER 0x10
/*
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 3d093de48e..f100fe6ffc 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.76 2002/01/12 02:55:30 brianp Exp $ */
+/* $Id: state.c,v 1.77 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -555,13 +555,11 @@ update_polygon( GLcontext *ctx )
static void
calculate_model_project_matrix( GLcontext *ctx )
{
- if (!ctx->_NeedEyeCoords) {
_math_matrix_mul_matrix( &ctx->_ModelProjectMatrix,
ctx->ProjectionMatrixStack.Top,
ctx->ModelviewMatrixStack.Top );
_math_matrix_analyse( &ctx->_ModelProjectMatrix );
- }
}
static void
@@ -595,7 +593,6 @@ update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords )
/* Recalculate all state that depends on _NeedEyeCoords.
*/
update_modelview_scale(ctx);
- calculate_model_project_matrix(ctx);
_mesa_compute_light_positions( ctx );
if (ctx->Driver.LightingSpaceChange)
@@ -610,9 +607,6 @@ update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords )
if (new_state & _NEW_MODELVIEW)
update_modelview_scale(ctx);
- if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
- calculate_model_project_matrix(ctx);
-
if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW))
_mesa_compute_light_positions( ctx );
}
@@ -757,12 +751,12 @@ update_texture_matrices( GLcontext *ctx )
if (ctx->TextureMatrixStack[i].Top->flags & MAT_DIRTY) {
_math_matrix_analyse( ctx->TextureMatrixStack[i].Top );
- if (ctx->Driver.TextureMatrix)
- ctx->Driver.TextureMatrix( ctx, i, ctx->TextureMatrixStack[i].Top);
-
if (ctx->Texture.Unit[i]._ReallyEnabled &&
ctx->TextureMatrixStack[i].Top->type != MATRIX_IDENTITY)
ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(i);
+
+ if (ctx->Driver.TextureMatrix)
+ ctx->Driver.TextureMatrix( ctx, i, ctx->TextureMatrixStack[i].Top);
}
}
}
@@ -889,6 +883,7 @@ update_texture_state( GLcontext *ctx )
}
+
/*
* If ctx->NewState is non-zero then this function MUST be called before
* rendering any primitive. Basically, function pointers and miscellaneous
@@ -957,6 +952,8 @@ void _mesa_update_state( GLcontext *ctx )
ctx->_NeedEyeCoords |= NEED_EYE_LIGHT_MODELVIEW;
}
+
+#if 0
/* XXX this is a bit of a hack. We should be checking elsewhere if
* vertex program mode is enabled. We set _NeedEyeCoords to zero to
* ensure that the combined modelview/projection matrix is computed
@@ -964,6 +961,15 @@ void _mesa_update_state( GLcontext *ctx )
*/
if (ctx->VertexProgram.Enabled)
ctx->_NeedEyeCoords = 0;
+ /* KW: it's now always computed.
+ */
+#endif
+
+ /* Keep ModelviewProject uptodate always to allow tnl
+ * implementations that go model->clip even when eye is required.
+ */
+ if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
+ calculate_model_project_matrix(ctx);
/* ctx->_NeedEyeCoords is now uptodate.
*
@@ -975,7 +981,6 @@ void _mesa_update_state( GLcontext *ctx )
* light positions & normal transforms for other reasons.
*/
if (new_state & (_NEW_MODELVIEW |
- _NEW_PROJECTION |
_NEW_LIGHT |
_MESA_NEW_NEED_EYE_COORDS))
update_tnl_spaces( ctx, oldneedeyecoords );
@@ -1034,3 +1039,18 @@ void _mesa_update_state( GLcontext *ctx )
#endif
}
}
+
+/* Is this helpful?
+ */
+void
+_mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag )
+{
+ if (flag)
+ ctx->_NeedEyeCoords &= ~NEED_EYE_DRIVER;
+ else
+ ctx->_NeedEyeCoords |= NEED_EYE_DRIVER;
+
+ ctx->NewState |= _NEW_POINT; /* one of the bits from
+ * _MESA_NEW_NEED_EYE_COORDS.
+ */
+}
diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h
index 67a62c3d4e..641c0c3413 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -1,4 +1,4 @@
-/* $Id: state.h,v 1.7 2001/03/12 00:48:38 gareth Exp $ */
+/* $Id: state.h,v 1.8 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -46,5 +46,7 @@ _mesa_print_state( const char *msg, GLuint state );
extern void
_mesa_print_enable_flags( const char *msg, GLuint flags );
+extern void
+_mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag );
#endif