diff options
author | Keith Whitwell <[email protected]> | 2001-04-28 08:39:17 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-04-28 08:39:17 +0000 |
commit | 51c0c71811508b6658e0d5dcff8426b618322a73 (patch) | |
tree | 05ccb4905625b200ed1a5de00acb2295e1babec9 /src/mesa/tnl/t_vb_lighttmp.h | |
parent | 27b0758a940f19ce344f21b8db708d91933ce06d (diff) |
Support for floating point color representation in tnl module.
Diffstat (limited to 'src/mesa/tnl/t_vb_lighttmp.h')
-rw-r--r-- | src/mesa/tnl/t_vb_lighttmp.h | 274 |
1 files changed, 135 insertions, 139 deletions
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index a9df6de1d51..76d2a8c047b 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_lighttmp.h,v 1.11 2001/04/19 12:22:09 keithw Exp $ */ +/* $Id: t_vb_lighttmp.h,v 1.12 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -36,7 +36,7 @@ # define CHECK_MATERIAL(x) (flags[x] & VERT_MATERIAL) # define CHECK_END_VB(x) (flags[x] & VERT_END_VB) # if (IDX & LIGHT_COLORMATERIAL) -# define CMSTRIDE STRIDE_CHAN(CMcolor, (4 * sizeof(GLchan))) +# define CMSTRIDE STRIDE_F(CMcolor, (4 * sizeof(GLfloat))) # define CHECK_COLOR_MATERIAL(x) (flags[x] & VERT_RGBA) # define CHECK_VALIDATE(x) (flags[x] & (VERT_RGBA|VERT_MATERIAL)) # define DO_ANOTHER_NORMAL(x) \ @@ -58,7 +58,7 @@ # define CHECK_MATERIAL(x) 0 /* no materials on array paths */ # define CHECK_END_VB(XX) (XX >= nr) # if (IDX & LIGHT_COLORMATERIAL) -# define CMSTRIDE STRIDE_CHAN(CMcolor, CMstride) +# define CMSTRIDE STRIDE_F(CMcolor, CMstride) # define CHECK_COLOR_MATERIAL(x) (x < nr) /* always have colormaterial */ # define CHECK_VALIDATE(x) (x < nr) # define DO_ANOTHER_NORMAL(x) 0 /* always stop to recalc colormat */ @@ -88,7 +88,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); GLfloat (*base)[3] = ctx->Light._BaseColor; - const GLchan *sumA = ctx->Light._BaseAlpha; + const GLfloat *sumA = ctx->Light._BaseAlpha; GLuint j; @@ -97,15 +97,16 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; - GLchan (*Fspec)[4] = (GLchan (*)[4]) store->LitSecondary[0].data; - GLchan (*Bspec)[4] = (GLchan (*)[4]) store->LitSecondary[1].data; - GLuint nr = VB->Count; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; + GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].Ptr; + GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].Ptr; + GLfloat (*spec[2])[4]; + GLuint nr = VB->Count; GLuint *flags = VB->Flag; struct gl_material (*new_material)[2] = VB->Material; GLuint *new_material_mask = VB->MaterialMask; @@ -114,11 +115,18 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, (void) nstride; (void) vstride; + /* fprintf(stderr, "%s\n", __FUNCTION__ ); */ + spec[0] = Fspec; + spec[1] = Bspec; + if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *) VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *) VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -138,7 +146,6 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, j<nr ; j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal,NSTRIDE),CMSTRIDE) { - GLfloat sum[2][3], spec[2][3]; struct gl_light *light; if ( CHECK_COLOR_MATERIAL(j) ) @@ -150,12 +157,14 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, if ( CHECK_VALIDATE(j) ) _mesa_validate_all_lighting_tables( ctx ); - COPY_3V(sum[0], base[0]); - ZERO_3V(spec[0]); + COPY_3V(Fcolor[j], base[0]); + Fcolor[j][3] = sumA[0]; + ZERO_3V(Fspec[j]); if (IDX & LIGHT_TWOSIDE) { - COPY_3V(sum[1], base[1]); - ZERO_3V(spec[1]); + COPY_3V(Bcolor[j], base[1]); + Bcolor[j][3] = sumA[1]; + ZERO_3V(Bspec[j]); } /* Add contribution from each enabled light source */ @@ -217,27 +226,30 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, /* Which side gets the diffuse & specular terms? */ if (n_dot_VP < 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], attenuation, light->_MatAmbient[0]); if (!(IDX & LIGHT_TWOSIDE)) { continue; } - side = 1; + /* diffuse term */ + COPY_3V(contrib, light->_MatAmbient[1]); + ACC_SCALE_SCALAR_3V(contrib, -n_dot_VP, light->_MatDiffuse[1]); + ACC_SCALE_SCALAR_3V(Bcolor[j], attenuation, contrib ); correction = -1; - n_dot_VP = -n_dot_VP; + side = 1; } else { if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); + ACC_SCALE_SCALAR_3V( Bcolor[j], attenuation, + light->_MatAmbient[1]); } - side = 0; + /* diffuse term */ + COPY_3V(contrib, light->_MatAmbient[0]); + ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], attenuation, contrib ); correction = 1; + side = 0; } - /* diffuse term */ - COPY_3V(contrib, light->_MatAmbient[side]); - ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]); - ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib ); - /* specular term - cannibalize VP... */ if (ctx->Light.Model.LocalViewer) { GLfloat v[3]; @@ -265,21 +277,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, if (spec_coef > 1.0e-10) { spec_coef *= attenuation; - ACC_SCALE_SCALAR_3V( spec[side], spec_coef, + ACC_SCALE_SCALAR_3V( spec[side][j], spec_coef, light->_MatSpecular[side]); } } } /*loop over lights*/ - - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fspec[j], spec[0] ); - Fcolor[j][3] = sumA[0]; - - if (IDX & LIGHT_TWOSIDE) { - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bspec[j], spec[1] ); - Bcolor[j][3] = sumA[1]; - } } } @@ -293,18 +295,19 @@ static void TAG(light_rgba)( GLcontext *ctx, GLuint j; GLfloat (*base)[3] = ctx->Light._BaseColor; - const GLchan *sumA = ctx->Light._BaseAlpha; + const GLfloat *sumA = ctx->Light._BaseAlpha; GLuint vstride = input->stride; const GLfloat *vertex = (GLfloat *) input->data; GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; + GLfloat (*color[2])[4]; GLuint *flags = VB->Flag; struct gl_material (*new_material)[2] = VB->Material; @@ -316,9 +319,15 @@ static void TAG(light_rgba)( GLcontext *ctx, (void) nstride; (void) vstride; + color[0] = Fcolor; + color[1] = Bcolor; + if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -332,7 +341,6 @@ static void TAG(light_rgba)( GLcontext *ctx, j<nr ; j++,STRIDE_F(vertex,VSTRIDE), STRIDE_F(normal,NSTRIDE),CMSTRIDE) { - GLfloat sum[2][3]; struct gl_light *light; if ( CHECK_COLOR_MATERIAL(j) ) @@ -344,10 +352,14 @@ static void TAG(light_rgba)( GLcontext *ctx, if ( CHECK_VALIDATE(j) ) _mesa_validate_all_lighting_tables( ctx ); - COPY_3V(sum[0], base[0]); + COPY_3V(Fcolor[j], base[0]); + Fcolor[j][3] = sumA[0]; + + if (IDX & LIGHT_TWOSIDE) { + COPY_3V(Bcolor[j], base[1]); + Bcolor[j][3] = sumA[1]; + } - if ( IDX & LIGHT_TWOSIDE ) - COPY_3V(sum[1], base[1]); /* Add contribution from each enabled light source */ foreach (light, &ctx->Light.EnabledList) { @@ -411,7 +423,7 @@ static void TAG(light_rgba)( GLcontext *ctx, /* which side are we lighting? */ if (n_dot_VP < 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], attenuation, light->_MatAmbient[0]); if (!(IDX & LIGHT_TWOSIDE)) continue; @@ -422,7 +434,8 @@ static void TAG(light_rgba)( GLcontext *ctx, } else { if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); + ACC_SCALE_SCALAR_3V(Bcolor[j], attenuation, + light->_MatAmbient[1]); } side = 0; correction = 1; @@ -465,16 +478,9 @@ static void TAG(light_rgba)( GLcontext *ctx, light->_MatSpecular[side]); } } - - ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib ); - } - - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] ); - Fcolor[j][3] = sumA[0]; - - if (IDX & LIGHT_TWOSIDE) { - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; + + + ACC_SCALE_SCALAR_3V( color[side][j], attenuation, contrib ); } } } @@ -493,17 +499,16 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, struct light_stage_data *store = LIGHT_STAGE_DATA(stage); GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; struct gl_light *light = ctx->Light.EnabledList.next; GLuint *flags = VB->Flag; - GLchan baseubyte[2][4]; GLuint j = 0; struct gl_material (*new_material)[2] = VB->Material; GLuint *new_material_mask = VB->MaterialMask; - GLfloat base[2][3]; + GLfloat base[2][4]; GLuint nr = VB->Count; /* fprintf(stderr, "%s\n", __FUNCTION__ ); */ @@ -513,8 +518,11 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, (void) nstride; if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -535,54 +543,42 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, if ( CHECK_VALIDATE(j) ) _mesa_validate_all_lighting_tables( ctx ); - baseubyte[0][3] = ctx->Light._BaseAlpha[0]; - baseubyte[1][3] = ctx->Light._BaseAlpha[1]; - /* No attenuation, so incoporate _MatAmbient into base color. - */ - { - COPY_3V(base[0], light->_MatAmbient[0]); - ACC_3V(base[0], ctx->Light._BaseColor[0] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[0], base[0] ); + COPY_3V(base[0], light->_MatAmbient[0]); + ACC_3V(base[0], ctx->Light._BaseColor[0] ); + base[0][3] = ctx->Light._BaseAlpha[0]; - if (IDX & LIGHT_TWOSIDE) { - COPY_3V(base[1], light->_MatAmbient[1]); - ACC_3V(base[1], ctx->Light._BaseColor[1]); - UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[1], base[1]); - } + if (IDX & LIGHT_TWOSIDE) { + COPY_3V(base[1], light->_MatAmbient[1]); + ACC_3V(base[1], ctx->Light._BaseColor[1]); + base[1][3] = ctx->Light._BaseAlpha[1]; } do { - GLfloat n_dot_VP = DOT3(normal, light->_VP_inf_norm); + GLfloat n_dot_VP; - COPY_CHAN4(Fcolor[j], baseubyte[0]); - if (IDX & LIGHT_TWOSIDE) COPY_CHAN4(Bcolor[j], baseubyte[1]); + COPY_4FV(Fcolor[j], base[0]); + if (IDX & LIGHT_TWOSIDE) COPY_4FV(Bcolor[j], base[1]); - if (n_dot_VP < 0.0F) { - if (IDX & LIGHT_TWOSIDE) { - GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); - GLfloat sum[3]; - COPY_3V(sum, base[1]); - ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]); - if (n_dot_h > 0.0F) { - GLfloat spec; - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec ); - ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]); - } - UNCLAMPED_FLOAT_TO_RGB_CHAN(Bcolor[j], sum ); - } - } else { + n_dot_VP = DOT3(normal, light->_VP_inf_norm); + + if (n_dot_VP > 0.0F) { GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm); - GLfloat sum[3]; - COPY_3V(sum, base[0]); - ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], n_dot_VP, light->_MatDiffuse[0]); if (n_dot_h > 0.0F) { GLfloat spec; GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec ); - ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]); - + ACC_SCALE_SCALAR_3V( Fcolor[j], spec, light->_MatSpecular[0]); + } + } + else if (IDX & LIGHT_TWOSIDE) { + GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); + ACC_SCALE_SCALAR_3V(Bcolor[j], -n_dot_VP, light->_MatDiffuse[1]); + if (n_dot_h > 0.0F) { + GLfloat spec; + GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec ); + ACC_SCALE_SCALAR_3V( Bcolor[j], spec, light->_MatSpecular[1]); } - UNCLAMPED_FLOAT_TO_RGB_CHAN(Fcolor[j], sum ); } j++; @@ -591,11 +587,11 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, } while (DO_ANOTHER_NORMAL(j)); - for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE ) { - COPY_CHAN4(Fcolor[j], Fcolor[j-1]); + for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal,NSTRIDE)) + { + COPY_4FV(Fcolor[j], Fcolor[j-1]); if (IDX & LIGHT_TWOSIDE) - COPY_CHAN4(Bcolor[j], Bcolor[j-1]); - STRIDE_F(normal, NSTRIDE); + COPY_4FV(Bcolor[j], Bcolor[j-1]); } } while (!CHECK_END_VB(j)); @@ -610,13 +606,13 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, GLvector4f *input ) { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - const GLchan *sumA = ctx->Light._BaseAlpha; + const GLfloat *sumA = ctx->Light._BaseAlpha; GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; GLuint *flags = VB->Flag; GLuint j = 0; struct gl_material (*new_material)[2] = VB->Material; @@ -631,8 +627,11 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, (void) nstride; if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -644,8 +643,6 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, do { do { - GLfloat sum[2][3]; - if ( CHECK_COLOR_MATERIAL(j) ) _mesa_update_color_material( ctx, CMcolor ); @@ -656,49 +653,45 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, _mesa_validate_all_lighting_tables( ctx ); - COPY_3V(sum[0], ctx->Light._BaseColor[0]); - if (IDX & LIGHT_TWOSIDE) - COPY_3V(sum[1], ctx->Light._BaseColor[1]); + COPY_3V(Fcolor[j], ctx->Light._BaseColor[0]); + Fcolor[j][3] = sumA[0]; + + if (IDX & LIGHT_TWOSIDE) { + COPY_3V(Bcolor[j], ctx->Light._BaseColor[1]); + Bcolor[j][3] = sumA[1]; + } foreach (light, &ctx->Light.EnabledList) { GLfloat n_dot_h, n_dot_VP, spec; - ACC_3V(sum[0], light->_MatAmbient[0]); + ACC_3V(Fcolor[j], light->_MatAmbient[0]); if (IDX & LIGHT_TWOSIDE) - ACC_3V(sum[1], light->_MatAmbient[1]); + ACC_3V(Bcolor[j], light->_MatAmbient[1]); n_dot_VP = DOT3(normal, light->_VP_inf_norm); if (n_dot_VP > 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], n_dot_VP, light->_MatDiffuse[0]); n_dot_h = DOT3(normal, light->_h_inf_norm); if (n_dot_h > 0.0F) { struct gl_shine_tab *tab = ctx->_ShineTable[0]; GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec ); - ACC_SCALE_SCALAR_3V( sum[0], spec, + ACC_SCALE_SCALAR_3V( Fcolor[j], spec, light->_MatSpecular[0]); } } else if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]); + ACC_SCALE_SCALAR_3V(Bcolor[j], -n_dot_VP, light->_MatDiffuse[1]); n_dot_h = -DOT3(normal, light->_h_inf_norm); if (n_dot_h > 0.0F) { struct gl_shine_tab *tab = ctx->_ShineTable[1]; GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec ); - ACC_SCALE_SCALAR_3V( sum[1], spec, + ACC_SCALE_SCALAR_3V( Bcolor[j], spec, light->_MatSpecular[1]); } } } - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] ); - Fcolor[j][3] = sumA[0]; - - if (IDX & LIGHT_TWOSIDE) { - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; - } - j++; CMSTRIDE; STRIDE_F(normal, NSTRIDE); @@ -707,11 +700,11 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, /* Reuse the shading results while there is no change to * normal or material values. */ - for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE ) { - COPY_CHAN4(Fcolor[j], Fcolor[j-1]); + for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal, NSTRIDE)) + { + COPY_4FV(Fcolor[j], Fcolor[j-1]); if (IDX & LIGHT_TWOSIDE) - COPY_CHAN4(Bcolor[j], Bcolor[j-1]); - STRIDE_F(normal, NSTRIDE); + COPY_4FV(Bcolor[j], Bcolor[j-1]); } } while (!CHECK_END_VB(j)); @@ -741,7 +734,7 @@ static void TAG(light_ci)( GLcontext *ctx, const GLfloat *vertex = (GLfloat *) input->data; GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; GLuint *flags = VB->Flag; GLuint *indexResult[2]; @@ -766,8 +759,11 @@ static void TAG(light_ci)( GLcontext *ctx, indexResult[1] = VB->IndexPtr[1]->data; if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } /* loop over vertices */ |