/*
* Mesa 3-D graphics library
- * Version: 6.4.1
+ * Version: 6.5
*
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
#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.
*/
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;
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];
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
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.
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
}
-/* _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.
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 );
}
}
-/* 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 )
!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top))
ctx->_NeedEyeCoords = GL_TRUE;
-
/* Check if the truth-value interpretations of the bitfields have
* changed:
*/
}
-/* 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
}
+/**
+ * Initialize all lighting state for the given context.
+ */
void
_mesa_init_lighting( GLcontext *ctx )
{
}
+/**
+ * Deallocate malloc'd lighting state attached to given context.
+ */
void
_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 );
}