summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-10 16:22:56 +0000
committerBrian Paul <[email protected]>2005-11-10 16:22:56 +0000
commit418a7dbd75bf02731bce9d373d7816bab8f3730e (patch)
treeb4144349268d69e606eb8508553615106da256bc /src
parent6297799fee30bb3a7e875c22d5f827e902f5ebbc (diff)
s/MAX_LIGHTS/ctx->Const.MaxLights/ and spruce up some comments
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/attrib.c8
-rw-r--r--src/mesa/main/light.c36
2 files changed, 26 insertions, 18 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 47103ccfb56..9c2a666e478 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.4.1
+ * Version: 6.5
*
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
@@ -50,7 +50,7 @@
#include "math/m_xform.h"
-/*
+/**
* Allocate a new attribute state node. These nodes have a
* "kind" value and a pointer to a struct of state data.
*/
@@ -147,7 +147,7 @@ _mesa_PushAttrib(GLbitfield mask)
attr->DepthTest = ctx->Depth.Test;
attr->Dither = ctx->Color.DitherFlag;
attr->Fog = ctx->Fog.Enabled;
- for (i=0;i<MAX_LIGHTS;i++) {
+ for (i = 0; i < ctx->Const.MaxLights; i++) {
attr->Light[i] = ctx->Light.Light[i].Enabled;
}
attr->Lighting = ctx->Light.Enabled;
@@ -950,7 +950,7 @@ _mesa_PopAttrib(void)
if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))
_math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
- for (i = 0; i < MAX_LIGHTS; i++) {
+ for (i = 0; i < ctx->Const.MaxLights; i++) {
GLenum lgt = (GLenum) (GL_LIGHT0 + i);
const struct gl_light *l = &light->Light[i];
GLfloat tmp[4];
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 5c41e936b96..f9b59089acd 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -946,14 +946,13 @@ _mesa_validate_all_lighting_tables( GLcontext *ctx )
if (!ctx->_ShineTable[1] || ctx->_ShineTable[1]->shininess != shininess)
validate_shine_table( ctx, 1, shininess );
- for (i = 0 ; i < MAX_LIGHTS ; i++)
+ for (i = 0; i < ctx->Const.MaxLights; i++)
if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1)
validate_spot_exp_table( &ctx->Light.Light[i] );
}
-
-/*
+/**
* Examine current lighting parameters to determine if the optimized lighting
* function can be used.
* Also, precompute some lighting values such as the products of light
@@ -981,8 +980,6 @@ _mesa_update_lighting( GLcontext *ctx )
ctx->Light._NeedEyeCoords = ((ctx->Light._Flags & LIGHT_POSITIONAL) ||
ctx->Light.Model.LocalViewer);
-
-
/* 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.
@@ -990,7 +987,6 @@ _mesa_update_lighting( GLcontext *ctx )
if (ctx->Light._NeedVertices)
ctx->Light._NeedEyeCoords = GL_TRUE;
-
/* Precompute some shading values. Although we reference
* Light.Material here, we can get away without flushing
* FLUSH_UPDATE_CURRENT, as when any outstanding material changes
@@ -1024,9 +1020,12 @@ _mesa_update_lighting( GLcontext *ctx )
}
-/* _NEW_MODELVIEW
- * _NEW_LIGHT
- * _TNL_NEW_NEED_EYE_COORDS
+/**
+ * Update state derived from light position, spot direction.
+ * Called upon:
+ * _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.
@@ -1050,9 +1049,11 @@ compute_light_positions( GLcontext *ctx )
foreach (light, &ctx->Light.EnabledList) {
if (ctx->_NeedEyeCoords) {
+ /* _Position is in eye coordinate space */
COPY_4FV( light->_Position, light->EyePosition );
}
else {
+ /* _Position is in object coordinate space */
TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv,
light->EyePosition );
}
@@ -1119,7 +1120,8 @@ update_modelview_scale( GLcontext *ctx )
}
-/* Bring uptodate any state that relies on _NeedEyeCoords.
+/**
+ * Bring up to date any state that relies on _NeedEyeCoords.
*/
void
_mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
@@ -1139,7 +1141,6 @@ _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top))
ctx->_NeedEyeCoords = GL_TRUE;
-
/* Check if the truth-value interpretations of the bitfields have
* changed:
*/
@@ -1167,7 +1168,8 @@ _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
}
-/* Drivers may need this if the hardware tnl unit doesn't support the
+/**
+ * Drivers may need this if the hardware tnl unit doesn't support the
* light-in-modelspace optimization. It's also useful for debugging.
*/
void
@@ -1258,6 +1260,9 @@ init_material( struct gl_material *m )
}
+/**
+ * Initialize all lighting state for the given context.
+ */
void
_mesa_init_lighting( GLcontext *ctx )
{
@@ -1300,6 +1305,9 @@ _mesa_init_lighting( GLcontext *ctx )
}
+/**
+ * Deallocate malloc'd lighting state attached to given context.
+ */
void
_mesa_free_lighting_data( GLcontext *ctx )
{
@@ -1307,7 +1315,7 @@ _mesa_free_lighting_data( GLcontext *ctx )
/* Free lighting shininess exponentiation table */
foreach_s( s, tmps, ctx->_ShineTabList ) {
- FREE( s );
+ _mesa_free( s );
}
- FREE( ctx->_ShineTabList );
+ _mesa_free( ctx->_ShineTabList );
}