Lighting now emits colors as CHAN_TYPE, as it used to. This will require
minor adjustments in the dri drivers for twosided lighting to work again.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $Id: t_dd_tritmp.h,v 1.11 2001/06/01 12:07:15 keithw Exp $ */
|
||||
/* $Id: t_dd_tritmp.h,v 1.12 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -177,9 +177,9 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
|
||||
}
|
||||
}
|
||||
else {
|
||||
GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->Ptr;
|
||||
ASSERT(VB->ColorPtr[1]->Type == GL_FLOAT);
|
||||
ASSERT(VB->ColorPtr[1]->StrideB == 4*sizeof(GLfloat));
|
||||
GLchan (*vbcolor)[4] = VB->ColorPtr[1]->Ptr;
|
||||
ASSERT(VB->ColorPtr[1]->Type == CHAN_TYPE);
|
||||
ASSERT(VB->ColorPtr[1]->StrideB == 4*sizeof(GLchan));
|
||||
(void) vbcolor;
|
||||
|
||||
if (!DO_FLAT) {
|
||||
@@ -192,7 +192,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
|
||||
VERT_SET_RGBA( v[2], vbcolor[e2] );
|
||||
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
|
||||
GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->Ptr;
|
||||
GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->Ptr;
|
||||
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_SPEC( 0 );
|
||||
@@ -385,7 +385,7 @@ static void TAG(quad)( GLcontext *ctx,
|
||||
if (DO_TWOSIDE && facing == 1)
|
||||
{
|
||||
if (HAVE_RGBA) {
|
||||
GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->Ptr;
|
||||
GLchan (*vbcolor)[4] = VB->ColorPtr[1]->Ptr;
|
||||
(void)vbcolor;
|
||||
|
||||
if (HAVE_BACK_COLORS) {
|
||||
@@ -426,7 +426,7 @@ static void TAG(quad)( GLcontext *ctx,
|
||||
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
|
||||
GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->Ptr;
|
||||
ASSERT(VB->SecondaryColorPtr[1]->StrideB==4*sizeof(GLfloat));
|
||||
ASSERT(VB->SecondaryColorPtr[1]->StrideB==4*sizeof(GLchan));
|
||||
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_SPEC( 0 );
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: s_context.c,v 1.23 2001/07/13 20:07:37 brianp Exp $ */
|
||||
/* $Id: s_context.c,v 1.24 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -529,7 +529,7 @@ _swrast_GetDeviceDriverReference( GLcontext *ctx )
|
||||
return &swrast->Driver;
|
||||
}
|
||||
|
||||
#define SWRAST_DEBUG_VERTICES 1
|
||||
#define SWRAST_DEBUG_VERTICES 0
|
||||
|
||||
void
|
||||
_swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
|
||||
@@ -540,8 +540,6 @@ _swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
|
||||
fprintf(stderr, "win %f %f %f %f\n",
|
||||
v->win[0], v->win[1], v->win[2], v->win[3]);
|
||||
|
||||
return;
|
||||
|
||||
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
|
||||
fprintf(stderr, "texcoord[%d] %f %f %f %f\n", i,
|
||||
v->texcoord[i][0], v->texcoord[i][1],
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ss_context.c,v 1.14 2001/07/12 22:09:21 keithw Exp $ */
|
||||
/* $Id: ss_context.c,v 1.15 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -78,11 +78,19 @@ _swsetup_CreateContext( GLcontext *ctx )
|
||||
void
|
||||
_swsetup_DestroyContext( GLcontext *ctx )
|
||||
{
|
||||
if (SWSETUP_CONTEXT(ctx)) {
|
||||
if (SWSETUP_CONTEXT(ctx)->verts)
|
||||
ALIGN_FREE(SWSETUP_CONTEXT(ctx)->verts);
|
||||
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
|
||||
|
||||
FREE(SWSETUP_CONTEXT(ctx));
|
||||
if (swsetup) {
|
||||
if (swsetup->verts)
|
||||
ALIGN_FREE(swsetup->verts);
|
||||
|
||||
if (swsetup->ChanSecondaryColor.Ptr)
|
||||
ALIGN_FREE(swsetup->ChanSecondaryColor.Ptr);
|
||||
|
||||
if (swsetup->ChanColor.Ptr)
|
||||
ALIGN_FREE(swsetup->ChanColor.Ptr);
|
||||
|
||||
FREE(swsetup);
|
||||
ctx->swsetup_context = 0;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ss_context.h,v 1.8 2001/07/12 22:09:21 keithw Exp $ */
|
||||
/* $Id: ss_context.h,v 1.9 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -40,6 +40,12 @@ typedef struct {
|
||||
GLenum render_prim;
|
||||
GLuint SetupIndex;
|
||||
|
||||
/* Temporaries for translating away float colors:
|
||||
*/
|
||||
struct gl_client_array ChanColor;
|
||||
struct gl_client_array ChanSecondaryColor;
|
||||
|
||||
|
||||
struct {
|
||||
void (*Start)( GLcontext * );
|
||||
void (*Finish)( GLcontext * );
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ss_triangle.c,v 1.14 2001/07/12 22:09:21 keithw Exp $ */
|
||||
/* $Id: ss_triangle.c,v 1.15 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -141,8 +141,8 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
#define SS_COLOR(a,b) UNCLAMPED_FLOAT_TO_RGBA_CHAN(a,b)
|
||||
#define SS_SPEC(a,b) UNCLAMPED_FLOAT_TO_RGB_CHAN(a,b)
|
||||
#define SS_COLOR(a,b) COPY_CHAN4(a,b)
|
||||
#define SS_SPEC(a,b) COPY_3V(a,b)
|
||||
#define SS_IND(a,b) (a = b)
|
||||
|
||||
#define IND (0)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ss_tritmp.h,v 1.13 2001/07/12 22:09:21 keithw Exp $ */
|
||||
/* $Id: ss_tritmp.h,v 1.14 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -61,12 +61,12 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
|
||||
if (facing == 1) {
|
||||
if (IND & SS_TWOSIDE_BIT) {
|
||||
if (IND & SS_RGBA_BIT) {
|
||||
GLfloat (*vbcolor)[4] = (GLfloat (*)[4])VB->ColorPtr[1]->Ptr;
|
||||
GLchan (*vbcolor)[4] = (GLchan (*)[4])VB->ColorPtr[1]->Ptr;
|
||||
SS_COLOR(v[0]->color, vbcolor[e0]);
|
||||
SS_COLOR(v[1]->color, vbcolor[e1]);
|
||||
SS_COLOR(v[2]->color, vbcolor[e2]);
|
||||
if (VB->SecondaryColorPtr[1]) {
|
||||
GLfloat (*vbspec)[4] = (GLfloat (*)[4])VB->SecondaryColorPtr[1]->Ptr;
|
||||
GLchan (*vbspec)[4] = (GLchan (*)[4])VB->SecondaryColorPtr[1]->Ptr;
|
||||
SS_SPEC(v[0]->specular, vbspec[e0]);
|
||||
SS_SPEC(v[1]->specular, vbspec[e1]);
|
||||
SS_SPEC(v[2]->specular, vbspec[e2]);
|
||||
@@ -136,12 +136,12 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
|
||||
if (IND & SS_TWOSIDE_BIT) {
|
||||
if (facing == 1) {
|
||||
if (IND & SS_RGBA_BIT) {
|
||||
GLfloat (*vbcolor)[4] = (GLfloat (*)[4])VB->ColorPtr[0]->Ptr;
|
||||
GLchan (*vbcolor)[4] = (GLchan (*)[4])VB->ColorPtr[0]->Ptr;
|
||||
SS_COLOR(v[0]->color, vbcolor[e0]);
|
||||
SS_COLOR(v[1]->color, vbcolor[e1]);
|
||||
SS_COLOR(v[2]->color, vbcolor[e2]);
|
||||
if (VB->SecondaryColorPtr[0]) {
|
||||
GLfloat (*vbspec)[4] = (GLfloat (*)[4])VB->SecondaryColorPtr[0]->Ptr;
|
||||
GLchan (*vbspec)[4] = (GLchan (*)[4])VB->SecondaryColorPtr[0]->Ptr;
|
||||
SS_SPEC(v[0]->specular, vbspec[e0]);
|
||||
SS_SPEC(v[1]->specular, vbspec[e1]);
|
||||
SS_SPEC(v[2]->specular, vbspec[e2]);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ss_vb.c,v 1.13 2001/07/12 22:09:21 keithw Exp $ */
|
||||
/* $Id: ss_vb.c,v 1.14 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -30,15 +30,60 @@
|
||||
#include "glheader.h"
|
||||
#include "colormac.h"
|
||||
#include "macros.h"
|
||||
#include "mem.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include "tnl/t_context.h"
|
||||
|
||||
#include "math/m_vector.h"
|
||||
#include "math/m_translate.h"
|
||||
|
||||
#include "ss_context.h"
|
||||
#include "ss_vb.h"
|
||||
|
||||
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(GLchan), 32 );
|
||||
to->Type = CHAN_TYPE;
|
||||
}
|
||||
|
||||
/* No need to transform the same value 3000 times.
|
||||
*/
|
||||
if (!from->StrideB) {
|
||||
to->StrideB = 0;
|
||||
count = 1;
|
||||
}
|
||||
else
|
||||
to->StrideB = 4 * sizeof(GLchan);
|
||||
|
||||
_math_trans_4chan( (GLchan (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
count);
|
||||
}
|
||||
|
||||
static void import_float_colors( GLcontext *ctx )
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
struct gl_client_array *to = &SWSETUP_CONTEXT(ctx)->ChanColor;
|
||||
do_import( VB, to, VB->ColorPtr[0] );
|
||||
VB->ColorPtr[0] = to;
|
||||
}
|
||||
|
||||
static void import_float_spec_colors( GLcontext *ctx )
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
struct gl_client_array *to = &SWSETUP_CONTEXT(ctx)->ChanSecondaryColor;
|
||||
do_import( VB, to, VB->SecondaryColorPtr[0] );
|
||||
VB->SecondaryColorPtr[0] = to;
|
||||
}
|
||||
|
||||
|
||||
/* Provides a RasterSetup function which prebuilds vertices for the
|
||||
@@ -182,7 +227,7 @@ static copy_pv_func copy_pv_tab[MAX_SETUPFUNC];
|
||||
* Additional setup and interp for back color and edgeflag.
|
||||
***********************************************************************/
|
||||
|
||||
#define GET_COLOR(ptr, idx) (((GLfloat (*)[4])((ptr)->Ptr))[idx])
|
||||
#define GET_COLOR(ptr, idx) (((GLchan (*)[4])((ptr)->Ptr))[idx])
|
||||
|
||||
static void interp_extras( GLcontext *ctx,
|
||||
GLfloat t,
|
||||
@@ -192,13 +237,13 @@ static void interp_extras( GLcontext *ctx,
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
if (VB->ColorPtr[1]) {
|
||||
INTERP_4F( t,
|
||||
INTERP_4CHAN( t,
|
||||
GET_COLOR(VB->ColorPtr[1], dst),
|
||||
GET_COLOR(VB->ColorPtr[1], out),
|
||||
GET_COLOR(VB->ColorPtr[1], in) );
|
||||
|
||||
if (VB->SecondaryColorPtr[1]) {
|
||||
INTERP_3F( t,
|
||||
INTERP_3CHAN( t,
|
||||
GET_COLOR(VB->SecondaryColorPtr[1], dst),
|
||||
GET_COLOR(VB->SecondaryColorPtr[1], out),
|
||||
GET_COLOR(VB->SecondaryColorPtr[1], in) );
|
||||
@@ -224,11 +269,11 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
if (VB->ColorPtr[1]) {
|
||||
COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
|
||||
COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst),
|
||||
GET_COLOR(VB->ColorPtr[1], src) );
|
||||
|
||||
if (VB->SecondaryColorPtr[1]) {
|
||||
COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
|
||||
COPY_3V( GET_COLOR(VB->SecondaryColorPtr[1], dst),
|
||||
GET_COLOR(VB->SecondaryColorPtr[1], src) );
|
||||
}
|
||||
}
|
||||
@@ -239,6 +284,9 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
|
||||
copy_pv_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, dst, src);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialization
|
||||
***********************************************************************/
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ss_vbtmp.h,v 1.16 2001/07/12 22:09:21 keithw Exp $ */
|
||||
/* $Id: ss_vbtmp.h,v 1.17 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -36,8 +36,8 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
|
||||
SWvertex *v;
|
||||
GLfloat *proj; /* projected clip coordinates */
|
||||
GLfloat *tc[MAX_TEXTURE_UNITS];
|
||||
GLfloat *color;
|
||||
GLfloat *spec;
|
||||
GLchan *color;
|
||||
GLchan *spec;
|
||||
GLuint *index;
|
||||
GLfloat *fog;
|
||||
GLfloat *pointSize;
|
||||
@@ -81,10 +81,16 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
|
||||
fog_stride = VB->FogCoordPtr->stride;
|
||||
}
|
||||
if (IND & COLOR) {
|
||||
if (VB->ColorPtr[0]->Type != CHAN_TYPE)
|
||||
import_float_colors( ctx );
|
||||
|
||||
color = VB->ColorPtr[0]->Ptr;
|
||||
color_stride = VB->ColorPtr[0]->StrideB;
|
||||
}
|
||||
if (IND & SPEC) {
|
||||
if (VB->SecondaryColorPtr[0]->Type != CHAN_TYPE)
|
||||
import_float_spec_colors( ctx );
|
||||
|
||||
spec = VB->SecondaryColorPtr[0]->Ptr;
|
||||
spec_stride = VB->SecondaryColorPtr[0]->StrideB;
|
||||
}
|
||||
@@ -123,17 +129,13 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
|
||||
}
|
||||
|
||||
if (IND & COLOR) {
|
||||
UNCLAMPED_FLOAT_TO_RGBA_CHAN(v->color, color);
|
||||
STRIDE_F(color, color_stride);
|
||||
/* COPY_CHAN4(v->color, color); */
|
||||
/* STRIDE_CHAN(color, color_stride); */
|
||||
COPY_CHAN4(v->color, color);
|
||||
STRIDE_CHAN(color, color_stride);
|
||||
}
|
||||
|
||||
if (IND & SPEC) {
|
||||
UNCLAMPED_FLOAT_TO_RGB_CHAN(v->specular, spec);
|
||||
STRIDE_F(spec, spec_stride);
|
||||
/* COPY_CHAN4(v->specular, spec); */
|
||||
/* STRIDE_CHAN(spec, spec_stride); */
|
||||
COPY_CHAN4(v->specular, spec);
|
||||
STRIDE_CHAN(spec, spec_stride);
|
||||
}
|
||||
|
||||
if (IND & FOG) {
|
||||
@@ -150,7 +152,6 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
|
||||
v->pointSize = pointSize[0];
|
||||
STRIDE_F(pointSize, pointSize_stride);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,10 +181,6 @@ static void TAG(interp)( GLcontext *ctx,
|
||||
dst->win[3] = oow;
|
||||
}
|
||||
|
||||
/* fprintf(stderr, "%s edst %d win %f %f %f %f\n", */
|
||||
/* __FUNCTION__, edst, */
|
||||
/* dst->win[0], dst->win[1], dst->win[2], dst->win[3]); */
|
||||
|
||||
if (IND & TEX0) {
|
||||
INTERP_4F( t, dst->texcoord[0], out->texcoord[0], in->texcoord[0] );
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: t_vb_light.c,v 1.14 2001/04/28 08:39:18 keithw Exp $ */
|
||||
/* $Id: t_vb_light.c,v 1.15 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "simple_list.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#include "math/m_translate.h"
|
||||
|
||||
#include "t_context.h"
|
||||
#include "t_pipeline.h"
|
||||
|
||||
@@ -49,14 +51,51 @@ typedef void (*light_func)( GLcontext *ctx,
|
||||
GLvector4f *input );
|
||||
|
||||
struct light_stage_data {
|
||||
struct gl_client_array FloatColor;
|
||||
struct gl_client_array LitColor[2];
|
||||
struct gl_client_array LitSecondary[2];
|
||||
GLvector1ui LitIndex[2];
|
||||
light_func *light_func_tab;
|
||||
};
|
||||
|
||||
|
||||
#define LIGHT_STAGE_DATA(stage) ((struct light_stage_data *)(stage->privatePtr))
|
||||
|
||||
|
||||
static void import_color_material( GLcontext *ctx,
|
||||
struct gl_pipeline_stage *stage )
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
struct gl_client_array *to = &LIGHT_STAGE_DATA(stage)->FloatColor;
|
||||
struct gl_client_array *from = VB->ColorPtr[0];
|
||||
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);
|
||||
|
||||
VB->ColorPtr[0] = to;
|
||||
}
|
||||
|
||||
|
||||
/* Tables for all the shading functions.
|
||||
*/
|
||||
static light_func _tnl_light_tab[MAX_LIGHT_FUNC];
|
||||
@@ -201,21 +240,17 @@ static GLboolean run_validate_lighting( GLcontext *ctx,
|
||||
return stage->run( ctx, stage );
|
||||
}
|
||||
|
||||
static void alloc_4f( struct gl_client_array *a, GLuint sz )
|
||||
static void alloc_4chan( struct gl_client_array *a, GLuint sz )
|
||||
{
|
||||
a->Ptr = ALIGN_MALLOC( sz * sizeof(GLfloat) * 4, 32 );
|
||||
a->Ptr = ALIGN_MALLOC( sz * sizeof(GLchan) * 4, 32 );
|
||||
a->Size = 4;
|
||||
a->Type = GL_FLOAT;
|
||||
a->Type = CHAN_TYPE;
|
||||
a->Stride = 0;
|
||||
a->StrideB = sizeof(GLfloat) * 4;
|
||||
a->StrideB = sizeof(GLchan) * 4;
|
||||
a->Enabled = 0;
|
||||
a->Flags = 0;
|
||||
}
|
||||
|
||||
static void free_4f( struct gl_client_array *a )
|
||||
{
|
||||
ALIGN_FREE( a->Ptr );
|
||||
}
|
||||
|
||||
/* Called the first time stage->run is called. In effect, don't
|
||||
* allocate data until the first time the stage is run.
|
||||
@@ -236,10 +271,12 @@ static GLboolean run_init_lighting( GLcontext *ctx,
|
||||
*/
|
||||
init_lighting();
|
||||
|
||||
alloc_4f( &store->LitColor[0], size );
|
||||
alloc_4f( &store->LitColor[1], size );
|
||||
alloc_4f( &store->LitSecondary[0], size );
|
||||
alloc_4f( &store->LitSecondary[1], size );
|
||||
store->FloatColor.Ptr = 0;
|
||||
|
||||
alloc_4chan( &store->LitColor[0], size );
|
||||
alloc_4chan( &store->LitColor[1], size );
|
||||
alloc_4chan( &store->LitSecondary[0], size );
|
||||
alloc_4chan( &store->LitSecondary[1], size );
|
||||
|
||||
_mesa_vector1ui_alloc( &store->LitIndex[0], 0, size, 32 );
|
||||
_mesa_vector1ui_alloc( &store->LitIndex[1], 0, size, 32 );
|
||||
@@ -280,10 +317,14 @@ static void dtr( struct gl_pipeline_stage *stage )
|
||||
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
|
||||
|
||||
if (store) {
|
||||
free_4f( &store->LitColor[0] );
|
||||
free_4f( &store->LitColor[1] );
|
||||
free_4f( &store->LitSecondary[0] );
|
||||
free_4f( &store->LitSecondary[1] );
|
||||
ALIGN_FREE( store->LitColor[0].Ptr );
|
||||
ALIGN_FREE( store->LitColor[1].Ptr );
|
||||
ALIGN_FREE( store->LitSecondary[0].Ptr );
|
||||
ALIGN_FREE( store->LitSecondary[1].Ptr );
|
||||
|
||||
if (store->FloatColor.Ptr)
|
||||
ALIGN_FREE( store->FloatColor.Ptr );
|
||||
|
||||
_mesa_vector1ui_free( &store->LitIndex[0] );
|
||||
_mesa_vector1ui_free( &store->LitIndex[1] );
|
||||
FREE( store );
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: t_vb_lighttmp.h,v 1.12 2001/04/28 08:39:18 keithw Exp $ */
|
||||
/* $Id: t_vb_lighttmp.h,v 1.13 2001/07/17 19:39:32 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
@@ -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 GLfloat *sumA = ctx->Light._BaseAlpha;
|
||||
GLchan sumA[2];
|
||||
|
||||
GLuint j;
|
||||
|
||||
@@ -100,11 +100,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
|
||||
GLfloat *CMcolor;
|
||||
GLuint CMstride;
|
||||
|
||||
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];
|
||||
GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
|
||||
GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
|
||||
GLchan (*Fspec)[4] = (GLchan (*)[4]) store->LitSecondary[0].Ptr;
|
||||
GLchan (*Bspec)[4] = (GLchan (*)[4]) store->LitSecondary[1].Ptr;
|
||||
GLchan (*spec[2])[4];
|
||||
|
||||
GLuint nr = VB->Count;
|
||||
GLuint *flags = VB->Flag;
|
||||
@@ -116,6 +116,9 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
|
||||
(void) vstride;
|
||||
|
||||
|
||||
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light._BaseAlpha[0]);
|
||||
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light._BaseAlpha[1]);
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__ ); */
|
||||
|
||||
spec[0] = Fspec;
|
||||
@@ -123,7 +126,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
|
||||
|
||||
if (IDX & LIGHT_COLORMATERIAL) {
|
||||
if (VB->ColorPtr[0]->Type != GL_FLOAT)
|
||||
VB->import_data( ctx, VERT_RGBA, ~0 );
|
||||
import_color_material( ctx, stage );
|
||||
|
||||
CMcolor = (GLfloat *) VB->ColorPtr[0]->Ptr;
|
||||
CMstride = VB->ColorPtr[0]->StrideB;
|
||||
@@ -146,6 +149,7 @@ 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) )
|
||||
@@ -157,14 +161,12 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
|
||||
if ( CHECK_VALIDATE(j) )
|
||||
_mesa_validate_all_lighting_tables( ctx );
|
||||
|
||||
COPY_3V(Fcolor[j], base[0]);
|
||||
Fcolor[j][3] = sumA[0];
|
||||
ZERO_3V(Fspec[j]);
|
||||
COPY_3V(sum[0], base[0]);
|
||||
ZERO_3V(spec[0]);
|
||||
|
||||
if (IDX & LIGHT_TWOSIDE) {
|
||||
COPY_3V(Bcolor[j], base[1]);
|
||||
Bcolor[j][3] = sumA[1];
|
||||
ZERO_3V(Bspec[j]);
|
||||
COPY_3V(sum[1], base[1]);
|
||||
ZERO_3V(spec[1]);
|
||||
}
|
||||
|
||||
/* Add contribution from each enabled light source */
|
||||
@@ -226,30 +228,27 @@ 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(Fcolor[j], attenuation, light->_MatAmbient[0]);
|
||||
ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
|
||||
if (!(IDX & LIGHT_TWOSIDE)) {
|
||||
continue;
|
||||
}
|
||||
/* 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;
|
||||
side = 1;
|
||||
correction = -1;
|
||||
n_dot_VP = -n_dot_VP;
|
||||
}
|
||||
else {
|
||||
if (IDX & LIGHT_TWOSIDE) {
|
||||
ACC_SCALE_SCALAR_3V( Bcolor[j], attenuation,
|
||||
light->_MatAmbient[1]);
|
||||
ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
|
||||
}
|
||||
/* 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;
|
||||
correction = 1;
|
||||
}
|
||||
|
||||
/* 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];
|
||||
@@ -277,11 +276,21 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
|
||||
|
||||
if (spec_coef > 1.0e-10) {
|
||||
spec_coef *= attenuation;
|
||||
ACC_SCALE_SCALAR_3V( spec[side][j], spec_coef,
|
||||
ACC_SCALE_SCALAR_3V( spec[side], 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +304,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
|
||||
GLuint j;
|
||||
|
||||
GLfloat (*base)[3] = ctx->Light._BaseColor;
|
||||
const GLfloat *sumA = ctx->Light._BaseAlpha;
|
||||
GLchan sumA[2];
|
||||
|
||||
GLuint vstride = input->stride;
|
||||
const GLfloat *vertex = (GLfloat *) input->data;
|
||||
@@ -305,9 +314,9 @@ static void TAG(light_rgba)( GLcontext *ctx,
|
||||
GLfloat *CMcolor;
|
||||
GLuint CMstride;
|
||||
|
||||
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr;
|
||||
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr;
|
||||
GLfloat (*color[2])[4];
|
||||
GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
|
||||
GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
|
||||
GLchan (*color[2])[4];
|
||||
GLuint *flags = VB->Flag;
|
||||
|
||||
struct gl_material (*new_material)[2] = VB->Material;
|
||||
@@ -322,9 +331,12 @@ static void TAG(light_rgba)( GLcontext *ctx,
|
||||
color[0] = Fcolor;
|
||||
color[1] = Bcolor;
|
||||
|
||||
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light._BaseAlpha[0]);
|
||||
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light._BaseAlpha[1]);
|
||||
|
||||
if (IDX & LIGHT_COLORMATERIAL) {
|
||||
if (VB->ColorPtr[0]->Type != GL_FLOAT)
|
||||
VB->import_data( ctx, VERT_RGBA, ~0 );
|
||||
import_color_material( ctx, stage );
|
||||
|
||||
CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
|
||||
CMstride = VB->ColorPtr[0]->StrideB;
|
||||
@@ -341,6 +353,7 @@ 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) )
|
||||
@@ -352,14 +365,10 @@ static void TAG(light_rgba)( GLcontext *ctx,
|
||||
if ( CHECK_VALIDATE(j) )
|
||||
_mesa_validate_all_lighting_tables( ctx );
|
||||
|
||||
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];
|
||||
}
|
||||
COPY_3V(sum[0], base[0]);
|
||||
|
||||
if ( IDX & LIGHT_TWOSIDE )
|
||||
COPY_3V(sum[1], base[1]);
|
||||
|
||||
/* Add contribution from each enabled light source */
|
||||
foreach (light, &ctx->Light.EnabledList) {
|
||||
@@ -423,7 +432,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
|
||||
|
||||
/* which side are we lighting? */
|
||||
if (n_dot_VP < 0.0F) {
|
||||
ACC_SCALE_SCALAR_3V(Fcolor[j], attenuation, light->_MatAmbient[0]);
|
||||
ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
|
||||
|
||||
if (!(IDX & LIGHT_TWOSIDE))
|
||||
continue;
|
||||
@@ -434,8 +443,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
|
||||
}
|
||||
else {
|
||||
if (IDX & LIGHT_TWOSIDE) {
|
||||
ACC_SCALE_SCALAR_3V(Bcolor[j], attenuation,
|
||||
light->_MatAmbient[1]);
|
||||
ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
|
||||
}
|
||||
side = 0;
|
||||
correction = 1;
|
||||
@@ -479,8 +487,15 @@ static void TAG(light_rgba)( GLcontext *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib );
|
||||
}
|
||||
|
||||
ACC_SCALE_SCALAR_3V( color[side][j], 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -501,14 +516,15 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
|
||||
const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
|
||||
GLfloat *CMcolor;
|
||||
GLuint CMstride;
|
||||
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr;
|
||||
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr;
|
||||
GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
|
||||
GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
|
||||
struct gl_light *light = ctx->Light.EnabledList.next;
|
||||
GLuint *flags = VB->Flag;
|
||||
GLchan basechan[2][4];
|
||||
GLuint j = 0;
|
||||
struct gl_material (*new_material)[2] = VB->Material;
|
||||
GLuint *new_material_mask = VB->MaterialMask;
|
||||
GLfloat base[2][4];
|
||||
GLfloat base[2][3];
|
||||
GLuint nr = VB->Count;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__ ); */
|
||||
@@ -519,7 +535,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
|
||||
|
||||
if (IDX & LIGHT_COLORMATERIAL) {
|
||||
if (VB->ColorPtr[0]->Type != GL_FLOAT)
|
||||
VB->import_data( ctx, VERT_RGBA, ~0 );
|
||||
import_color_material( ctx, stage );
|
||||
|
||||
CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
|
||||
CMstride = VB->ColorPtr[0]->StrideB;
|
||||
@@ -544,41 +560,51 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
|
||||
_mesa_validate_all_lighting_tables( ctx );
|
||||
|
||||
|
||||
/* No attenuation, so incoporate _MatAmbient into base color.
|
||||
*/
|
||||
COPY_3V(base[0], light->_MatAmbient[0]);
|
||||
ACC_3V(base[0], ctx->Light._BaseColor[0] );
|
||||
base[0][3] = ctx->Light._BaseAlpha[0];
|
||||
UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[0], base[0] );
|
||||
UNCLAMPED_FLOAT_TO_CHAN(basechan[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]);
|
||||
base[1][3] = ctx->Light._BaseAlpha[1];
|
||||
UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[1], base[1]);
|
||||
UNCLAMPED_FLOAT_TO_CHAN(basechan[1][3], ctx->Light._BaseAlpha[1]);
|
||||
}
|
||||
|
||||
do {
|
||||
GLfloat n_dot_VP;
|
||||
GLfloat n_dot_VP = DOT3(normal, light->_VP_inf_norm);
|
||||
|
||||
COPY_4FV(Fcolor[j], base[0]);
|
||||
if (IDX & LIGHT_TWOSIDE) COPY_4FV(Bcolor[j], base[1]);
|
||||
|
||||
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);
|
||||
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( Fcolor[j], spec, light->_MatSpecular[0]);
|
||||
}
|
||||
}
|
||||
else if (IDX & LIGHT_TWOSIDE) {
|
||||
if (n_dot_VP < 0.0F) {
|
||||
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]);
|
||||
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( Bcolor[j], spec, light->_MatSpecular[1]);
|
||||
ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
|
||||
}
|
||||
UNCLAMPED_FLOAT_TO_RGB_CHAN(Bcolor[j], sum );
|
||||
}
|
||||
COPY_CHAN4(Fcolor[j], basechan[0]);
|
||||
} else {
|
||||
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]);
|
||||
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]);
|
||||
|
||||
}
|
||||
UNCLAMPED_FLOAT_TO_RGB_CHAN(Fcolor[j], sum );
|
||||
if (IDX & LIGHT_TWOSIDE) COPY_CHAN4(Bcolor[j], basechan[1]);
|
||||
}
|
||||
|
||||
j++;
|
||||
@@ -589,9 +615,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
|
||||
|
||||
for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal,NSTRIDE))
|
||||
{
|
||||
COPY_4FV(Fcolor[j], Fcolor[j-1]);
|
||||
COPY_CHAN4(Fcolor[j], Fcolor[j-1]);
|
||||
if (IDX & LIGHT_TWOSIDE)
|
||||
COPY_4FV(Bcolor[j], Bcolor[j-1]);
|
||||
COPY_CHAN4(Bcolor[j], Bcolor[j-1]);
|
||||
}
|
||||
|
||||
} while (!CHECK_END_VB(j));
|
||||
@@ -606,13 +632,13 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
|
||||
GLvector4f *input )
|
||||
{
|
||||
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
|
||||
const GLfloat *sumA = ctx->Light._BaseAlpha;
|
||||
GLchan sumA[2];
|
||||
GLuint nstride = VB->NormalPtr->stride;
|
||||
const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
|
||||
GLfloat *CMcolor;
|
||||
GLuint CMstride;
|
||||
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr;
|
||||
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr;
|
||||
GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr;
|
||||
GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr;
|
||||
GLuint *flags = VB->Flag;
|
||||
GLuint j = 0;
|
||||
struct gl_material (*new_material)[2] = VB->Material;
|
||||
@@ -626,9 +652,12 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
|
||||
(void) nr;
|
||||
(void) nstride;
|
||||
|
||||
UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light._BaseAlpha[0]);
|
||||
UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light._BaseAlpha[1]);
|
||||
|
||||
if (IDX & LIGHT_COLORMATERIAL) {
|
||||
if (VB->ColorPtr[0]->Type != GL_FLOAT)
|
||||
VB->import_data( ctx, VERT_RGBA, ~0 );
|
||||
import_color_material( ctx, stage );
|
||||
|
||||
CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
|
||||
CMstride = VB->ColorPtr[0]->StrideB;
|
||||
@@ -643,6 +672,8 @@ 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 );
|
||||
|
||||
@@ -653,45 +684,49 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
|
||||
_mesa_validate_all_lighting_tables( ctx );
|
||||
|
||||
|
||||
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];
|
||||
}
|
||||
COPY_3V(sum[0], ctx->Light._BaseColor[0]);
|
||||
if (IDX & LIGHT_TWOSIDE)
|
||||
COPY_3V(sum[1], ctx->Light._BaseColor[1]);
|
||||
|
||||
foreach (light, &ctx->Light.EnabledList) {
|
||||
GLfloat n_dot_h, n_dot_VP, spec;
|
||||
|
||||
ACC_3V(Fcolor[j], light->_MatAmbient[0]);
|
||||
ACC_3V(sum[0], light->_MatAmbient[0]);
|
||||
if (IDX & LIGHT_TWOSIDE)
|
||||
ACC_3V(Bcolor[j], light->_MatAmbient[1]);
|
||||
ACC_3V(sum[1], light->_MatAmbient[1]);
|
||||
|
||||
n_dot_VP = DOT3(normal, light->_VP_inf_norm);
|
||||
|
||||
if (n_dot_VP > 0.0F) {
|
||||
ACC_SCALE_SCALAR_3V(Fcolor[j], n_dot_VP, light->_MatDiffuse[0]);
|
||||
ACC_SCALE_SCALAR_3V(sum[0], 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( Fcolor[j], spec,
|
||||
ACC_SCALE_SCALAR_3V( sum[0], spec,
|
||||
light->_MatSpecular[0]);
|
||||
}
|
||||
}
|
||||
else if (IDX & LIGHT_TWOSIDE) {
|
||||
ACC_SCALE_SCALAR_3V(Bcolor[j], -n_dot_VP, light->_MatDiffuse[1]);
|
||||
ACC_SCALE_SCALAR_3V(sum[1], -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( Bcolor[j], spec,
|
||||
ACC_SCALE_SCALAR_3V( sum[1], 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);
|
||||
@@ -702,9 +737,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
|
||||
*/
|
||||
for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal, NSTRIDE))
|
||||
{
|
||||
COPY_4FV(Fcolor[j], Fcolor[j-1]);
|
||||
COPY_CHAN4(Fcolor[j], Fcolor[j-1]);
|
||||
if (IDX & LIGHT_TWOSIDE)
|
||||
COPY_4FV(Bcolor[j], Bcolor[j-1]);
|
||||
COPY_CHAN4(Bcolor[j], Bcolor[j-1]);
|
||||
}
|
||||
|
||||
} while (!CHECK_END_VB(j));
|
||||
@@ -760,7 +795,7 @@ static void TAG(light_ci)( GLcontext *ctx,
|
||||
|
||||
if (IDX & LIGHT_COLORMATERIAL) {
|
||||
if (VB->ColorPtr[0]->Type != GL_FLOAT)
|
||||
VB->import_data( ctx, VERT_RGBA, ~0 );
|
||||
import_color_material( ctx, stage );
|
||||
|
||||
CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr;
|
||||
CMstride = VB->ColorPtr[0]->StrideB;
|
||||
|
Reference in New Issue
Block a user