summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/imports.h5
-rw-r--r--src/mesa/main/light.c88
2 files changed, 45 insertions, 48 deletions
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index df0d6d771d..93be82382c 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -209,6 +209,11 @@ extern void _ext_mesa_free_pixelbuffer( void *pb );
#define M_PI (3.1415926536)
#endif
+/* XXX this is a bit of a hack needed for compilation within XFree86 */
+#ifndef FLT_MIN
+#define FLT_MIN (1.0e-37)
+#endif
+
/* Degrees to radians conversion: */
#define DEG2RAD (M_PI/180.0)
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index c9e0fbd73a..5d47313568 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,3 @@
-
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -26,23 +25,15 @@
#include "glheader.h"
#include "imports.h"
-#include "colormac.h"
#include "context.h"
#include "enums.h"
#include "light.h"
#include "macros.h"
#include "simple_list.h"
#include "mtypes.h"
-#include "math/m_xform.h"
#include "math/m_matrix.h"
-/* XXX this is a bit of a hack needed for compilation within XFree86 */
-#ifndef FLT_MIN
-#define FLT_MIN 1e-37
-#endif
-
-
void
_mesa_ShadeModel( GLenum mode )
{
@@ -68,7 +59,6 @@ _mesa_ShadeModel( GLenum mode )
}
-
void
_mesa_Lightf( GLenum light, GLenum pname, GLfloat param )
{
@@ -301,7 +291,6 @@ _mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
}
-
void
_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params )
{
@@ -544,9 +533,10 @@ _mesa_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname,
/* Perform a straight copy between materials.
*/
-void _mesa_copy_materials( struct gl_material *dst,
- const struct gl_material *src,
- GLuint bitmask )
+void
+_mesa_copy_materials( struct gl_material *dst,
+ const struct gl_material *src,
+ GLuint bitmask )
{
int i;
@@ -559,7 +549,8 @@ void _mesa_copy_materials( struct gl_material *dst,
/* Update derived values following a change in ctx->Light.Material
*/
-void _mesa_update_material( GLcontext *ctx, GLuint bitmask )
+void
+_mesa_update_material( GLcontext *ctx, GLuint bitmask )
{
struct gl_light *light, *list = &ctx->Light.EnabledList;
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
@@ -643,8 +634,8 @@ void _mesa_update_material( GLcontext *ctx, GLuint bitmask )
* according to the bitmask in ColorMaterialBitmask, which is
* set by glColorMaterial().
*/
-void _mesa_update_color_material( GLcontext *ctx,
- const GLfloat color[4] )
+void
+_mesa_update_color_material( GLcontext *ctx, const GLfloat color[4] )
{
GLuint bitmask = ctx->Light.ColorMaterialBitmask;
struct gl_material *mat = &ctx->Light.Material;
@@ -658,8 +649,6 @@ void _mesa_update_color_material( GLcontext *ctx,
}
-
-
void
_mesa_ColorMaterial( GLenum face, GLenum mode )
{
@@ -698,9 +687,6 @@ _mesa_ColorMaterial( GLenum face, GLenum mode )
}
-
-
-
void
_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
{
@@ -747,7 +733,6 @@ _mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
}
-
void
_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
{
@@ -806,7 +791,6 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
-
/**********************************************************************/
/***** Lighting computation *****/
/**********************************************************************/
@@ -856,7 +840,9 @@ _mesa_invalidate_spot_exp_table( struct gl_light *l )
l->_SpotExpTable[0][0] = -1;
}
-static void validate_spot_exp_table( struct gl_light *l )
+
+static void
+validate_spot_exp_table( struct gl_light *l )
{
GLint i;
GLdouble exponent = l->SpotExponent;
@@ -884,24 +870,28 @@ static void validate_spot_exp_table( struct gl_light *l )
-
/* Calculate a new shine table. Doing this here saves a branch in
* lighting, and the cost of doing it early may be partially offset
* by keeping a MRU cache of shine tables for various shine values.
*/
void
-_mesa_invalidate_shine_table( GLcontext *ctx, GLuint i )
+_mesa_invalidate_shine_table( GLcontext *ctx, GLuint side )
{
- if (ctx->_ShineTable[i])
- ctx->_ShineTable[i]->refcount--;
- ctx->_ShineTable[i] = 0;
+ ASSERT(side < 2);
+ if (ctx->_ShineTable[side])
+ ctx->_ShineTable[side]->refcount--;
+ ctx->_ShineTable[side] = 0;
}
-static void validate_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
+
+static void
+validate_shine_table( GLcontext *ctx, GLuint side, GLfloat shininess )
{
struct gl_shine_tab *list = ctx->_ShineTabList;
struct gl_shine_tab *s;
+ ASSERT(side < 2);
+
foreach(s, list)
if ( s->shininess == shininess )
break;
@@ -937,18 +927,19 @@ static void validate_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
s->shininess = shininess;
}
- if (ctx->_ShineTable[i])
- ctx->_ShineTable[i]->refcount--;
+ if (ctx->_ShineTable[side])
+ ctx->_ShineTable[side]->refcount--;
- ctx->_ShineTable[i] = s;
+ ctx->_ShineTable[side] = s;
move_to_tail( list, s );
s->refcount++;
}
+
void
_mesa_validate_all_lighting_tables( GLcontext *ctx )
{
- GLint i;
+ GLuint i;
GLfloat shininess;
shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0];
@@ -966,7 +957,6 @@ _mesa_validate_all_lighting_tables( GLcontext *ctx )
-
/*
* Examine current lighting parameters to determine if the optimized lighting
* function can be used.
@@ -1046,7 +1036,7 @@ _mesa_update_lighting( GLcontext *ctx )
* Also update on lighting space changes.
*/
static void
-_mesa_compute_light_positions( GLcontext *ctx )
+compute_light_positions( GLcontext *ctx )
{
struct gl_light *light;
static const GLfloat eye_z[3] = { 0, 0, 1 };
@@ -1117,8 +1107,6 @@ _mesa_compute_light_positions( GLcontext *ctx )
-
-
static void
update_modelview_scale( GLcontext *ctx )
{
@@ -1140,7 +1128,8 @@ update_modelview_scale( GLcontext *ctx )
/* Bring uptodate any state that relies on _NeedEyeCoords.
*/
-void _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
+void
+_mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
{
const GLuint oldneedeyecoords = ctx->_NeedEyeCoords;
@@ -1165,7 +1154,7 @@ void _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
/* Recalculate all state that depends on _NeedEyeCoords.
*/
update_modelview_scale(ctx);
- _mesa_compute_light_positions( ctx );
+ compute_light_positions( ctx );
if (ctx->Driver.LightingSpaceChange)
ctx->Driver.LightingSpaceChange( ctx );
@@ -1180,7 +1169,7 @@ void _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
update_modelview_scale(ctx);
if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW))
- _mesa_compute_light_positions( ctx );
+ compute_light_positions( ctx );
}
}
@@ -1236,6 +1225,7 @@ init_light( struct gl_light *l, GLuint n )
l->Enabled = GL_FALSE;
}
+
/**
* Initialize the light model data structure.
*
@@ -1250,6 +1240,7 @@ init_lightmodel( struct gl_lightmodel *lm )
lm->ColorControl = GL_SINGLE_COLOR;
}
+
/**
* Initialize the material data structure.
*
@@ -1274,12 +1265,13 @@ init_material( struct gl_material *m )
}
-void _mesa_init_lighting( GLcontext *ctx )
+void
+_mesa_init_lighting( GLcontext *ctx )
{
- int i;
+ GLuint i;
/* Lighting group */
- for (i=0;i<MAX_LIGHTS;i++) {
+ for (i = 0; i < MAX_LIGHTS; i++) {
init_light( &ctx->Light.Light[i], i );
}
make_empty_list( &ctx->Light.EnabledList );
@@ -1299,6 +1291,7 @@ void _mesa_init_lighting( GLcontext *ctx )
/* Lighting miscellaneous */
ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab );
make_empty_list( ctx->_ShineTabList );
+ /* Allocate 10 (arbitrary) shininess lookup tables */
for (i = 0 ; i < 10 ; i++) {
struct gl_shine_tab *s = MALLOC_STRUCT( gl_shine_tab );
s->shininess = -1;
@@ -1306,8 +1299,6 @@ void _mesa_init_lighting( GLcontext *ctx )
insert_at_tail( ctx->_ShineTabList, s );
}
-
-
/* Miscellaneous */
ctx->Light._NeedEyeCoords = 0;
ctx->_NeedEyeCoords = 0;
@@ -1315,7 +1306,8 @@ void _mesa_init_lighting( GLcontext *ctx )
}
-void _mesa_free_lighting_data( GLcontext *ctx )
+void
+_mesa_free_lighting_data( GLcontext *ctx )
{
struct gl_shine_tab *s, *tmps;