diff options
author | Keith Whitwell <[email protected]> | 2001-02-15 01:33:52 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-02-15 01:33:52 +0000 |
commit | c6b2a92613a5110dbf387721af8ec505744183b9 (patch) | |
tree | 00358af747ddad95ba79c8649b39329e48b2cfd1 /src/mesa/main/light.c | |
parent | 4e52e192b2507a001817c8172713016cef69206b (diff) |
Fix propogation of material values in VB's that don't reach the lighting
stage. (Materials now treated more like colors, etc.).
Continue whipping the dd templates into shape.
Remove old NormalLength code; may come back as a driver helper, but not
useful for, eg. hardware t&l drivers.
Diffstat (limited to 'src/mesa/main/light.c')
-rw-r--r-- | src/mesa/main/light.c | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 50bd041f190..155792af52b 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,4 +1,4 @@ -/* $Id: light.c,v 1.36 2001/02/13 23:55:30 brianp Exp $ */ +/* $Id: light.c,v 1.37 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -535,6 +535,54 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, } +/* Perform a straight copy between pairs of materials. + */ +void gl_copy_material_pairs( struct gl_material dst[2], + const struct gl_material src[2], + GLuint bitmask ) +{ + if (bitmask & FRONT_EMISSION_BIT) { + COPY_4FV( dst[0].Emission, src[0].Emission ); + } + if (bitmask & BACK_EMISSION_BIT) { + COPY_4FV( dst[1].Emission, src[1].Emission ); + } + if (bitmask & FRONT_AMBIENT_BIT) { + COPY_4FV( dst[0].Ambient, src[0].Ambient ); + } + if (bitmask & BACK_AMBIENT_BIT) { + COPY_4FV( dst[1].Ambient, src[1].Ambient ); + } + if (bitmask & FRONT_DIFFUSE_BIT) { + COPY_4FV( dst[0].Diffuse, src[0].Diffuse ); + } + if (bitmask & BACK_DIFFUSE_BIT) { + COPY_4FV( dst[1].Diffuse, src[1].Diffuse ); + } + if (bitmask & FRONT_SPECULAR_BIT) { + COPY_4FV( dst[0].Specular, src[0].Specular ); + } + if (bitmask & BACK_SPECULAR_BIT) { + COPY_4FV( dst[1].Specular, src[1].Specular ); + } + if (bitmask & FRONT_SHININESS_BIT) { + dst[0].Shininess = src[0].Shininess; + } + if (bitmask & BACK_SHININESS_BIT) { + dst[1].Shininess = src[1].Shininess; + } + if (bitmask & FRONT_INDEXES_BIT) { + dst[0].AmbientIndex = src[0].AmbientIndex; + dst[0].DiffuseIndex = src[0].DiffuseIndex; + dst[0].SpecularIndex = src[0].SpecularIndex; + } + if (bitmask & BACK_INDEXES_BIT) { + dst[1].AmbientIndex = src[1].AmbientIndex; + dst[1].DiffuseIndex = src[1].DiffuseIndex; + dst[1].SpecularIndex = src[1].SpecularIndex; + } +} + /* * Check if the global material has to be updated with info that was @@ -545,11 +593,7 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, * * src[0] is front material, src[1] is back material * - * KW: Added code here to keep the precomputed variables uptodate. - * This means we can use the faster shade functions when using - * GL_COLOR_MATERIAL, and we can also now use the precomputed - * values in the slower shading functions, which further offsets - * the cost of doing this here. + * Additionally keeps the precomputed lighting state uptodate. */ void gl_update_material( GLcontext *ctx, const struct gl_material src[2], @@ -610,9 +654,6 @@ void gl_update_material( GLcontext *ctx, if (bitmask & FRONT_DIFFUSE_BIT) { struct gl_material *mat = &ctx->Light.Material[0]; COPY_4FV( mat->Diffuse, src[0].Diffuse ); -/* fprintf(stderr, "FRONT_DIFFUSE %f %f %f %f\n", */ -/* mat->Diffuse[0], mat->Diffuse[1], */ -/* mat->Diffuse[2], mat->Diffuse[3]); */ foreach (light, list) { SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse ); } @@ -621,9 +662,6 @@ void gl_update_material( GLcontext *ctx, if (bitmask & BACK_DIFFUSE_BIT) { struct gl_material *mat = &ctx->Light.Material[1]; COPY_4FV( mat->Diffuse, src[1].Diffuse ); -/* fprintf(stderr, "BACK_DIFFUSE %f %f %f %f\n", */ -/* mat->Diffuse[0], mat->Diffuse[1], */ -/* mat->Diffuse[2], mat->Diffuse[3]); */ foreach (light, list) { SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse ); } @@ -647,7 +685,6 @@ void gl_update_material( GLcontext *ctx, } if (bitmask & FRONT_SHININESS_BIT) { -/* fprintf(stderr, "FRONT_SHININESS_BIT %f\n", src[0].Shininess); */ ctx->Light.Material[0].Shininess = src[0].Shininess; gl_invalidate_shine_table( ctx, 0 ); } @@ -692,6 +729,9 @@ void gl_update_material( GLcontext *ctx, + + + /* * Update the current materials from the given rgba color * according to the bitmask in ColorMaterialBitmask, which is |