*/
-#if (IDX & LIGHT_TWOSIDE)
+#if IDX & LIGHT_TWOSIDE
# define NR_SIDES 2
#else
# define NR_SIDES 1
const GLuint vstride = input->stride;
const GLfloat *vertex = (GLfloat *)input->data;
- const GLuint nstride = VB->NormalPtr->stride;
- const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+ const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].data;
const GLuint nr = VB->Count;
- (void) nstride;
- (void) vstride;
-
#ifdef TRACE
fprintf(stderr, "%s\n", __FUNCTION__ );
#endif
sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
#endif
- /* Side-effects done, can we finish now?
- */
- if (stage->changed_inputs == 0)
- return;
+
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
GLfloat sum[2][3], spec[2][3];
/* spotlight attenuation */
if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
if (PV_dot_dir<light->_CosCutoff) {
continue; /* this light makes no contribution */
const GLuint vstride = input->stride;
const GLfloat *vertex = (GLfloat *) input->data;
- const GLuint nstride = VB->NormalPtr->stride;
- const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+ const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+#if IDX & LIGHT_TWOSIDE
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
- GLfloat (*color[2])[4];
+#endif
const GLuint nr = VB->Count;
fprintf(stderr, "%s\n", __FUNCTION__ );
#endif
- (void) nstride;
- (void) vstride;
-
- color[0] = Fcolor;
- color[1] = Bcolor;
-
VB->ColorPtr[0] = &store->LitColor[0];
sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
#endif
- if (stage->changed_inputs == 0)
- return;
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
GLfloat sum[2][3];
struct gl_light *light;
- if ( IDX & LIGHT_MATERIAL ) {
- update_materials( ctx, store );
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
#if IDX & LIGHT_TWOSIDE
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
#endif
- }
COPY_3V(sum[0], base[0]);
- if ( IDX & LIGHT_TWOSIDE )
- COPY_3V(sum[1], base[1]);
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(sum[1], base[1]);
+#endif
/* Add contribution from each enabled light source */
foreach (light, &ctx->Light.EnabledList) {
/* spotlight attenuation */
if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
if (PV_dot_dir<light->_CosCutoff) {
continue; /* this light makes no contribution */
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- const GLuint nstride = VB->NormalPtr->stride;
- const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+ const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
#if IDX & LIGHT_TWOSIDE
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
#endif
const struct gl_light *light = ctx->Light.EnabledList.next;
GLuint j = 0;
- GLfloat base[2][3];
+ GLfloat base[2][4];
+#if IDX & LIGHT_MATERIAL
const GLuint nr = VB->Count;
+#else
+ const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
+#endif
#ifdef TRACE
fprintf(stderr, "%s\n", __FUNCTION__ );
#endif
(void) input; /* doesn't refer to Eye or Obj */
- (void) nr;
- (void) nstride;
VB->ColorPtr[0] = &store->LitColor[0];
#if IDX & LIGHT_TWOSIDE
VB->ColorPtr[1] = &store->LitColor[1];
#endif
- if (stage->changed_inputs == 0)
- return;
+ if (nr > 1) {
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
+ }
+ else {
+ store->LitColor[0].stride = 0;
+ store->LitColor[1].stride = 0;
+ }
for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
GLfloat n_dot_VP;
- if ( IDX & LIGHT_MATERIAL )
- update_materials( ctx, store );
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+#endif
/* No attenuation, so incoporate _MatAmbient into base color.
*/
- if ( j == 0 || (IDX & LIGHT_MATERIAL) ) {
+#if !(IDX & LIGHT_MATERIAL)
+ if ( j == 0 )
+#endif
+ {
COPY_3V(base[0], light->_MatAmbient[0]);
ACC_3V(base[0], ctx->Light._BaseColor[0] );
base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
GLfloat sumA[2];
- const GLuint nstride = VB->NormalPtr->stride;
- const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+ const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
#if IDX & LIGHT_TWOSIDE
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
#endif
GLuint j = 0;
+#if IDX & LIGHT_MATERIAL
const GLuint nr = VB->Count;
+#else
+ const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
+#endif
const struct gl_light *light;
#ifdef TRACE
#endif
(void) input;
- (void) nr;
- (void) nstride;
sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
VB->ColorPtr[1] = &store->LitColor[1];
#endif
- if (stage->changed_inputs == 0)
- return;
+ if (nr > 1) {
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
+ }
+ else {
+ store->LitColor[0].stride = 0;
+ store->LitColor[1].stride = 0;
+ }
for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
GLfloat sum[2][3];
- if ( IDX & LIGHT_MATERIAL ) {
- update_materials( ctx, store );
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
#if IDX & LIGHT_TWOSIDE
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
#endif
- }
COPY_3V(sum[0], ctx->Light._BaseColor[0]);
GLuint j;
const GLuint vstride = input->stride;
const GLfloat *vertex = (GLfloat *) input->data;
- const GLuint nstride = VB->NormalPtr->stride;
- const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
+ const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
GLfloat *indexResult[2];
const GLuint nr = VB->Count;
fprintf(stderr, "%s\n", __FUNCTION__ );
#endif
- (void) nstride;
- (void) vstride;
-
VB->IndexPtr[0] = &store->LitIndex[0];
#if IDX & LIGHT_TWOSIDE
VB->IndexPtr[1] = &store->LitIndex[1];
#endif
- if (stage->changed_inputs == 0)
- return;
-
indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data;
#if IDX & LIGHT_TWOSIDE
indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data;
GLuint side = 0;
struct gl_light *light;
- if ( IDX & LIGHT_MATERIAL )
- update_materials( ctx, store );
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+#endif
diffuse[0] = specular[0] = 0.0F;
- if ( IDX & LIGHT_TWOSIDE ) {
+#if IDX & LIGHT_TWOSIDE
diffuse[1] = specular[1] = 0.0F;
- }
+#endif
/* Accumulate diffuse and specular from each light source */
foreach (light, &ctx->Light.EnabledList) {
/* spotlight attenuation */
if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
if (PV_dot_dir < light->_CosCutoff) {
continue; /* this light makes no contribution */
}