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/drivers | |
parent | 27b0758a940f19ce344f21b8db708d91933ce06d (diff) |
Support for floating point color representation in tnl module.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/common/t_dd_tritmp.h | 79 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_vbtmp.h | 42 |
2 files changed, 60 insertions, 61 deletions
diff --git a/src/mesa/drivers/common/t_dd_tritmp.h b/src/mesa/drivers/common/t_dd_tritmp.h index 963db088265..22eff7f252f 100644 --- a/src/mesa/drivers/common/t_dd_tritmp.h +++ b/src/mesa/drivers/common/t_dd_tritmp.h @@ -1,4 +1,4 @@ -/* $Id: t_dd_tritmp.h,v 1.8 2001/04/06 16:26:41 alanh Exp $ */ +/* $Id: t_dd_tritmp.h,v 1.9 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -177,23 +177,30 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } } else { - GLchan (*vbcolor)[4] = VB->ColorPtr[1]->data; - ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLchan)); + GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->Ptr; + ASSERT(VB->ColorPtr[1]->Type == GL_FLOAT); + ASSERT(VB->ColorPtr[1]->StrideB == 4*sizeof(GLfloat)); (void) vbcolor; if (!DO_FLAT) { + VERT_SAVE_RGBA( 0 ); + VERT_SAVE_RGBA( 1 ); VERT_SET_RGBA( v[0], vbcolor[e0] ); VERT_SET_RGBA( v[1], vbcolor[e1] ); } + VERT_SAVE_RGBA( 2 ); VERT_SET_RGBA( v[2], vbcolor[e2] ); if (HAVE_SPEC && VB->SecondaryColorPtr[1]) { - GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; + GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->Ptr; if (!DO_FLAT) { + VERT_SAVE_SPEC( 0 ); + VERT_SAVE_SPEC( 1 ); VERT_SET_SPEC( v[0], vbspec[e0] ); VERT_SET_SPEC( v[1], vbspec[e1] ); } + VERT_SAVE_SPEC( 2 ); VERT_SET_SPEC( v[2], vbspec[e2] ); } } @@ -288,37 +295,17 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) if (DO_TWOSIDE && facing == 1) { if (HAVE_RGBA) { - if (HAVE_BACK_COLORS) { + if (!DO_FLAT) { VERT_RESTORE_RGBA( 0 ); VERT_RESTORE_RGBA( 1 ); - VERT_RESTORE_RGBA( 2 ); - if (HAVE_SPEC) { - VERT_RESTORE_SPEC( 0 ); - VERT_RESTORE_SPEC( 1 ); - VERT_RESTORE_SPEC( 2 ); - } } - else { - GLchan (*vbcolor)[4] = VB->ColorPtr[0]->data; - ASSERT(VB->ColorPtr[0]->stride == 4*sizeof(GLchan)); - (void) vbcolor; - + VERT_RESTORE_RGBA( 2 ); + if (HAVE_SPEC) { if (!DO_FLAT) { - VERT_SET_RGBA( v[0], vbcolor[e0] ); - VERT_SET_RGBA( v[1], vbcolor[e1] ); - } - VERT_SET_RGBA( v[2], vbcolor[e2] ); - - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - GLchan (*vbspec)[4] = VB->SecondaryColorPtr[0]->data; - ASSERT(VB->SecondaryColorPtr[0]->stride == 4*sizeof(GLchan)); - - if (!DO_FLAT) { - VERT_SET_SPEC( v[0], vbspec[e0] ); - VERT_SET_SPEC( v[1], vbspec[e1] ); - } - VERT_SET_SPEC( v[2], vbspec[e2] ); + VERT_RESTORE_SPEC( 0 ); + VERT_RESTORE_SPEC( 1 ); } + VERT_RESTORE_SPEC( 2 ); } } else { @@ -398,7 +385,7 @@ static void TAG(quad)( GLcontext *ctx, if (DO_TWOSIDE && facing == 1) { if (HAVE_RGBA) { - GLchan (*vbcolor)[4] = VB->ColorPtr[1]->data; + GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->Ptr; (void)vbcolor; if (!DO_FLAT) { @@ -409,8 +396,8 @@ static void TAG(quad)( GLcontext *ctx, VERT_SET_RGBA( v[3], vbcolor[e3] ); if (HAVE_SPEC && VB->SecondaryColorPtr[facing]) { - GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; - ASSERT(VB->SecondaryColorPtr[1]->stride == 4*sizeof(GLchan)); + GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->Ptr; + ASSERT(VB->SecondaryColorPtr[1]->StrideB==4*sizeof(GLfloat)); if (!DO_FLAT) { VERT_SET_SPEC( v[0], vbspec[e0] ); @@ -521,27 +508,19 @@ static void TAG(quad)( GLcontext *ctx, if (DO_TWOSIDE && facing == 1) { if (HAVE_RGBA) { - GLchan (*vbcolor)[4] = VB->ColorPtr[0]->data; - ASSERT(VB->ColorPtr[0]->stride == 4*sizeof(GLchan)); - (void) vbcolor; - if (!DO_FLAT) { - VERT_SET_RGBA( v[0], vbcolor[e0] ); - VERT_SET_RGBA( v[1], vbcolor[e1] ); - VERT_SET_RGBA( v[2], vbcolor[e2] ); + VERT_RESTORE_RGBA( 0 ); + VERT_RESTORE_RGBA( 1 ); + VERT_RESTORE_RGBA( 2 ); } - VERT_SET_RGBA( v[3], vbcolor[e3] ); - - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - GLchan (*vbspec)[4] = VB->SecondaryColorPtr[0]->data; - ASSERT(VB->SecondaryColorPtr[0]->stride == 4*sizeof(GLchan)); - + VERT_RESTORE_RGBA( 3 ); + if (HAVE_SPEC) { if (!DO_FLAT) { - VERT_SET_SPEC( v[0], vbspec[e0] ); - VERT_SET_SPEC( v[1], vbspec[e1] ); - VERT_SET_SPEC( v[2], vbspec[e2] ); + VERT_RESTORE_SPEC( 0 ); + VERT_RESTORE_SPEC( 1 ); + VERT_RESTORE_SPEC( 2 ); } - VERT_SET_SPEC( v[3], vbspec[e3] ); + VERT_RESTORE_SPEC( 3 ); } } else { diff --git a/src/mesa/drivers/common/t_dd_vbtmp.h b/src/mesa/drivers/common/t_dd_vbtmp.h index d6425f0b962..65e00a13ada 100644 --- a/src/mesa/drivers/common/t_dd_vbtmp.h +++ b/src/mesa/drivers/common/t_dd_vbtmp.h @@ -1,4 +1,4 @@ -/* $Id: t_dd_vbtmp.h,v 1.10 2001/04/09 10:16:01 alanh Exp $ */ +/* $Id: t_dd_vbtmp.h,v 1.11 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -175,13 +175,17 @@ static void TAG(emit)( GLcontext *ctx, } if (DO_RGBA) { - col = VB->ColorPtr[0]->data; - col_stride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) + IMPORT_FLOAT_COLORS( ctx ); + col = (GLubyte (*)[4])VB->ColorPtr[0]->Ptr; + col_stride = VB->ColorPtr[0]->StrideB; } if (DO_SPEC) { - spec = VB->SecondaryColorPtr[0]->data; - spec_stride = VB->SecondaryColorPtr[0]->stride; + if (VB->SecondaryColorPtr[0]->Type != GL_UNSIGNED_BYTE) + IMPORT_FLOAT_SPEC_COLORS( ctx ); + spec = (GLubyte (*)[4])VB->SecondaryColorPtr[0]->Ptr; + spec_stride = VB->SecondaryColorPtr[0]->StrideB; } if (DO_FOG) { @@ -389,8 +393,8 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, { LOCALVARS struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte (*col)[4] = VB->ColorPtr[0]->data; - GLuint col_stride = VB->ColorPtr[0]->stride; + GLubyte (*col)[4]; + GLuint col_stride; GLfloat (*coord)[4] = VB->ProjectedClipPtr->data; GLuint coord_stride = VB->ProjectedClipPtr->stride; GLfloat *v = (GLfloat *)dest; @@ -402,6 +406,16 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, ASSERT(stride == 4); + if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) + IMPORT_FLOAT_COLORS( ctx ); + + col = (GLubyte (*)[4])VB->ColorPtr[0]->Ptr; + col_stride = VB->ColorPtr[0]->StrideB; + ASSERT(VB->ColorPtr[0]->Type == GL_UNSIGNED_BYTE); + +/* fprintf(stderr, "%s stride %d importable %d\n", */ +/* __FUNCTION__, col_stride, VB->importable_data); */ + /* Pack what's left into a 4-dword vertex. Color is in a different * place, and there is no 'w' coordinate. */ @@ -461,11 +475,17 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, { LOCALVARS struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte (*col)[4] = VB->ColorPtr[0]->data; - GLuint col_stride = VB->ColorPtr[0]->stride; + GLubyte (*col)[4]; + GLuint col_stride; GLfloat *v = (GLfloat *)dest; int i; + if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) + IMPORT_FLOAT_COLORS( ctx ); + + col = VB->ColorPtr[0]->data; + col_stride = VB->ColorPtr[0]->stride; + if (start) STRIDE_4UB(col, col_stride * start); @@ -579,8 +599,8 @@ static void TAG(interp)( GLcontext *ctx, const GLfloat *s = GET_VIEWPORT_MAT(); VERTEX *dst = (VERTEX *)(ddverts + (edst << shift)); - VERTEX *in = (VERTEX *)(ddverts + (eout << shift)); - VERTEX *out = (VERTEX *)(ddverts + (ein << shift)); + VERTEX *in = (VERTEX *)(ddverts + (ein << shift)); + VERTEX *out = (VERTEX *)(ddverts + (eout << shift)); (void)s; |