static GLboolean run_lighting( GLcontext *ctx, struct tnl_pipeline_stage *stage ) { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; GLuint idx; if (!ctx->Light.Enabled || ctx->VertexProgram._Current) return GL_TRUE; /* Make sure we can talk about position x,y and z: */ if (input->size <= 2 && input == VB->ObjPtr) { _math_trans_4f( store->Input.data, VB->ObjPtr->data, VB->ObjPtr->stride, GL_FLOAT, VB->ObjPtr->size, 0, VB->Count ); if (input->size <= 2) { /* Clean z. */ _mesa_vector4f_clean_elem(&store->Input, VB->Count, 2); } if (input->size <= 1) { /* Clean y. */ _mesa_vector4f_clean_elem(&store->Input, VB->Count, 1); } input = &store->Input; } idx = 0; if (prepare_materials( ctx, VB, store )) idx |= LIGHT_MATERIAL; if (ctx->Light.Model.TwoSide) idx |= LIGHT_TWOSIDE; /* The individual functions know about replaying side-effects * vs. full re-execution. */ store->light_func_tab[idx]( ctx, VB, stage, input ); VB->AttribPtr[_TNL_ATTRIB_COLOR0] = VB->ColorPtr[0]; VB->AttribPtr[_TNL_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0]; VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX] = VB->IndexPtr[0]; return GL_TRUE; }
static void do_import(struct vertex_buffer *VB, struct gl_client_array *to, struct gl_client_array *from) { GLuint count = VB->Count; if (!to->Ptr) { to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLfloat), 32 ); to->Type = GL_FLOAT; } /* No need to transform the same value 3000 times. */ if (!from->StrideB) { to->StrideB = 0; count = 1; } else to->StrideB = 4 * sizeof(GLfloat); _math_trans_4f((GLfloat (*)[4]) to->Ptr, from->Ptr, from->StrideB, from->Type, from->Size, 0, count); }