-
/*
* Mesa 3-D graphics library
* Version: 5.1
#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 )
{
}
-
void
_mesa_Lightf( GLenum light, GLenum pname, GLfloat param )
{
}
-
void
_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params )
{
/* 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;
/* 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;
* 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;
}
-
-
void
_mesa_ColorMaterial( GLenum face, GLenum mode )
{
}
-
-
-
void
_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
{
}
-
void
_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
{
-
/**********************************************************************/
/***** Lighting computation *****/
/**********************************************************************/
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;
-
/* 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;
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];
-
/*
* Examine current lighting parameters to determine if the optimized lighting
* function can be used.
* 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 };
-
-
static void
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;
/* 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 );
update_modelview_scale(ctx);
if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW))
- _mesa_compute_light_positions( ctx );
+ compute_light_positions( ctx );
}
}
l->Enabled = GL_FALSE;
}
+
/**
* Initialize the light model data structure.
*
lm->ColorControl = GL_SINGLE_COLOR;
}
+
/**
* Initialize the material data structure.
*
}
-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 );
/* 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;
insert_at_tail( ctx->_ShineTabList, s );
}
-
-
/* Miscellaneous */
ctx->Light._NeedEyeCoords = 0;
ctx->_NeedEyeCoords = 0;
}
-void _mesa_free_lighting_data( GLcontext *ctx )
+void
+_mesa_free_lighting_data( GLcontext *ctx )
{
struct gl_shine_tab *s, *tmps;