summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-01-24 00:04:58 +0000
committerBrian Paul <[email protected]>2001-01-24 00:04:58 +0000
commit74b493a5e61237de081a438e774e5d8139d4c6b7 (patch)
treea8bc94a65bacc67b9b1473f91a2bd84cd2b25937 /src/mesa/tnl
parent125fddc31dc9959901d9f1ece693b09f04426d48 (diff)
Lots of GLchan datatype changes.
Added GLvector4us datatype in math/m_vector.[ch] Added _math_trans_4us() in math/m_translate.[ch] Choose GLvector4ub, GLvector4us, GLvector4f at compile time based on CHAN_BITS. Made Driver.ClearColor() and Driver.ClearIndex() optional driver functions. Changed args to Driver.ClearColor(), updated drivers. Reordered files in Makefile.X11
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_array_api.c12
-rw-r--r--src/mesa/tnl/t_array_import.c40
-rw-r--r--src/mesa/tnl/t_context.h25
-rw-r--r--src/mesa/tnl/t_imm_api.c132
-rw-r--r--src/mesa/tnl/t_imm_elt.c177
-rw-r--r--src/mesa/tnl/t_imm_eval.c30
-rw-r--r--src/mesa/tnl/t_imm_exec.c16
-rw-r--r--src/mesa/tnl/t_imm_fixup.c41
-rw-r--r--src/mesa/tnl/t_vb_light.c41
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h14
10 files changed, 322 insertions, 206 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c
index 908328513d8..b3ef1dbeed0 100644
--- a/src/mesa/tnl/t_array_api.c
+++ b/src/mesa/tnl/t_array_api.c
@@ -1,10 +1,10 @@
-/* $Id: t_array_api.c,v 1.3 2001/01/14 06:14:21 keithw Exp $ */
+/* $Id: t_array_api.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -336,8 +336,16 @@ void _tnl_array_init( GLcontext *ctx )
*/
gl_vector4f_init( &tmp->Obj, 0, 0 );
gl_vector3f_init( &tmp->Normal, 0, 0 );
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
gl_vector4ub_init( &tmp->Color, 0, 0 );
gl_vector4ub_init( &tmp->SecondaryColor, 0, 0 );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ gl_vector4us_init( &tmp->Color, 0, 0 );
+ gl_vector4us_init( &tmp->SecondaryColor, 0, 0 );
+#elif CHAN_TYPE == GL_FLOAT
+ gl_vector4f_init( &tmp->Color, 0, 0 );
+ gl_vector4f_init( &tmp->SecondaryColor, 0, 0 );
+#endif
gl_vector1f_init( &tmp->FogCoord, 0, 0 );
gl_vector1ui_init( &tmp->Index, 0, 0 );
gl_vector1ub_init( &tmp->EdgeFlag, 0, 0 );
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c
index 0379bd402b3..b88391c8522 100644
--- a/src/mesa/tnl/t_array_import.c
+++ b/src/mesa/tnl/t_array_import.c
@@ -1,4 +1,4 @@
-/* $Id: t_array_import.c,v 1.6 2001/01/08 21:56:00 keithw Exp $ */
+/* $Id: t_array_import.c,v 1.7 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -107,10 +107,10 @@ static void _tnl_import_color( GLcontext *ctx,
&is_writeable);
inputs->Color.data = tmp->Ptr;
- inputs->Color.start = (GLubyte *)tmp->Ptr;
+ inputs->Color.start = (GLchan *)tmp->Ptr;
inputs->Color.stride = tmp->StrideB;
inputs->Color.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
- if (inputs->Color.stride != 4*sizeof(GLubyte))
+ if (inputs->Color.stride != 4*sizeof(GLchan))
inputs->Color.flags |= VEC_BAD_STRIDE;
if (!is_writeable)
inputs->Color.flags |= VEC_NOT_WRITEABLE;
@@ -132,7 +132,7 @@ static void _tnl_import_secondarycolor( GLcontext *ctx,
&is_writeable);
inputs->SecondaryColor.data = tmp->Ptr;
- inputs->SecondaryColor.start = (GLubyte *)tmp->Ptr;
+ inputs->SecondaryColor.start = (GLchan *)tmp->Ptr;
inputs->SecondaryColor.stride = tmp->StrideB;
inputs->SecondaryColor.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
if (inputs->SecondaryColor.stride != 4*sizeof(GLubyte))
@@ -464,21 +464,53 @@ void _tnl_fill_immediate_drawarrays( GLcontext *ctx, struct immediate *IM,
}
if (required & VERT_RGBA) {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
_math_trans_4ub( IM->Color + IM->Start,
ctx->Array.Color.Ptr,
ctx->Array.Color.StrideB,
ctx->Array.Color.Type,
ctx->Array.Color.Size,
start, n );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ _math_trans_4us( IM->Color + IM->Start,
+ ctx->Array.Color.Ptr,
+ ctx->Array.Color.StrideB,
+ ctx->Array.Color.Type,
+ ctx->Array.Color.Size,
+ start, n );
+#elif CHAN_TYPE == GL_FLOAT
+ _math_trans_4f( IM->Color + IM->Start,
+ ctx->Array.Color.Ptr,
+ ctx->Array.Color.StrideB,
+ ctx->Array.Color.Type,
+ ctx->Array.Color.Size,
+ start, n );
+#endif
}
if (required & VERT_SPEC_RGB) {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
_math_trans_4ub( IM->SecondaryColor + IM->Start,
ctx->Array.SecondaryColor.Ptr,
ctx->Array.SecondaryColor.StrideB,
ctx->Array.SecondaryColor.Type,
ctx->Array.SecondaryColor.Size,
start, n );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ _math_trans_4us( IM->SecondaryColor + IM->Start,
+ ctx->Array.SecondaryColor.Ptr,
+ ctx->Array.SecondaryColor.StrideB,
+ ctx->Array.SecondaryColor.Type,
+ ctx->Array.SecondaryColor.Size,
+ start, n );
+#elif CHAN_TYPE == GL_FLOAT
+ _math_trans_4f( IM->SecondaryColor + IM->Start,
+ ctx->Array.SecondaryColor.Ptr,
+ ctx->Array.SecondaryColor.StrideB,
+ ctx->Array.SecondaryColor.Type,
+ ctx->Array.SecondaryColor.Size,
+ start, n );
+#endif
}
if (required & VERT_FOG_COORD) {
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 41be51e4e25..d3414be29ba 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -1,4 +1,4 @@
-/* $Id: t_context.h,v 1.11 2001/01/14 06:14:21 keithw Exp $ */
+/* $Id: t_context.h,v 1.12 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -205,7 +205,7 @@ struct immediate
GLuint Elt[IMM_SIZE];
GLubyte EdgeFlag[IMM_SIZE];
GLuint Index[IMM_SIZE];
- GLubyte SecondaryColor[IMM_SIZE][4];
+ GLchan SecondaryColor[IMM_SIZE][4];
GLfloat FogCoord[IMM_SIZE];
};
@@ -214,12 +214,20 @@ struct vertex_arrays
{
GLvector4f Obj;
GLvector3f Normal;
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
GLvector4ub Color;
+ GLvector4ub SecondaryColor;
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ GLvector4us Color;
+ GLvector4us SecondaryColor;
+#elif CHAN_TYPE == GL_FLOAT
+ GLvector4f Color;
+ GLvector4f SecondaryColor;
+#endif
GLvector1ui Index;
GLvector1ub EdgeFlag;
GLvector4f TexCoord[MAX_TEXTURE_UNITS];
GLvector1ui Elt;
- GLvector4ub SecondaryColor;
GLvector1f FogCoord;
};
@@ -260,8 +268,17 @@ typedef struct vertex_buffer
GLboolean *EdgeFlag; /* VERT_EDGE */
GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */
GLvector1ui *IndexPtr[2]; /* VERT_INDEX */
+
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
GLvector4ub *ColorPtr[2]; /* VERT_RGBA */
- GLvector4ub *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */
+ GLvector4ub *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ GLvector4us *ColorPtr[2]; /* VERT_RGBA */
+ GLvector4us *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */
+#elif CHAN_TYPE == GL_FLOAT
+ GLvector4f *ColorPtr[2]; /* VERT_RGBA */
+ GLvector4f *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */
+#endif
GLvector1f *FogCoordPtr; /* VERT_FOG_COORD */
GLvector1f *PointSizePtr; /* VERT_POINT_SIZE */
GLmaterial (*Material)[2]; /* VERT_MATERIAL, optional */
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c
index 0e00e59cdb7..0ba46b9b7c8 100644
--- a/src/mesa/tnl/t_imm_api.c
+++ b/src/mesa/tnl/t_imm_api.c
@@ -382,22 +382,13 @@ _tnl_End(void)
static void
_tnl_Color3f( GLfloat red, GLfloat green, GLfloat blue )
{
-#if CHAN_BITS == 8
- GLubyte col[4];
+ GLchan col[4];
GET_IMMEDIATE;
- UNCLAMPED_FLOAT_TO_UBYTE(col[0], red);
- UNCLAMPED_FLOAT_TO_UBYTE(col[1], green);
- UNCLAMPED_FLOAT_TO_UBYTE(col[2], blue);
+ UNCLAMPED_FLOAT_TO_CHAN(col[0], red);
+ UNCLAMPED_FLOAT_TO_CHAN(col[1], green);
+ UNCLAMPED_FLOAT_TO_CHAN(col[2], blue);
col[3] = CHAN_MAX;
COLORV( IM, col );
-#else
- GET_IMMEDIATE;
- COLOR(IM,
- UNCLAMPED_FLOAT_TO_CHAN(red),
- UNCLAMPED_FLOAT_TO_CHAN(green),
- UNCLAMPED_FLOAT_TO_CHAN(blue),
- CHAN_MAX);
-#endif
}
@@ -423,61 +414,37 @@ _tnl_Color3ub( GLubyte red, GLubyte green, GLubyte blue )
static void
_tnl_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
{
-#if CHAN_BITS == 8
- GLubyte col[4];
+ GLchan col[4];
GET_IMMEDIATE;
- UNCLAMPED_FLOAT_TO_UBYTE(col[0], red);
- UNCLAMPED_FLOAT_TO_UBYTE(col[1], green);
- UNCLAMPED_FLOAT_TO_UBYTE(col[2], blue);
- UNCLAMPED_FLOAT_TO_UBYTE(col[3], alpha);
+ UNCLAMPED_FLOAT_TO_CHAN(col[0], red);
+ UNCLAMPED_FLOAT_TO_CHAN(col[1], green);
+ UNCLAMPED_FLOAT_TO_CHAN(col[2], blue);
+ UNCLAMPED_FLOAT_TO_CHAN(col[3], alpha);
COLORV( IM, col );
-#else
- GET_IMMEDIATE;
- COLOR(IM,
- UNCLAMPED_FLOAT_TO_CHAN(red),
- UNCLAMPED_FLOAT_TO_CHAN(green),
- UNCLAMPED_FLOAT_TO_CHAN(blue),
- UNCLAMPED_FLOAT_TO_CHAN(alpha));
-#endif
}
static void
_tnl_Color4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
{
-#if CHAN_BITS == 8
- GET_IMMEDIATE;
- COLOR( IM, red, green, blue, alpha );
-#else
GET_IMMEDIATE;
COLOR(IM,
UBYTE_TO_CHAN(red),
UBYTE_TO_CHAN(green),
UBYTE_TO_CHAN(blue),
UBYTE_TO_CHAN(alpha));
-#endif
}
static void
_tnl_Color3fv( const GLfloat *v )
{
-#if CHAN_BITS == 8
- GLubyte col[4];
+ GLchan col[4];
GET_IMMEDIATE;
- UNCLAMPED_FLOAT_TO_UBYTE(col[0], v[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(col[1], v[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(col[2], v[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[0], v[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[1], v[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[2], v[2]);
col[3] = CHAN_MAX;
COLORV( IM, col );
-#else
- GET_IMMEDIATE;
- COLOR(IM,
- UNCLAMPED_FLOAT_TO_CHAN(v[0]),
- UNCLAMPED_FLOAT_TO_CHAN(v[1]),
- UNCLAMPED_FLOAT_TO_CHAN(v[2]),
- CHAN_MAX);
-
-#endif
}
@@ -485,38 +452,24 @@ _tnl_Color3fv( const GLfloat *v )
static void
_tnl_Color3ubv( const GLubyte *v )
{
-#if CHAN_BITS == 8
- GET_IMMEDIATE;
- COLOR( IM, v[0], v[1], v[2], CHAN_MAX );
-#else
GET_IMMEDIATE;
COLOR(IM,
UBYTE_TO_CHAN(v[0]),
UBYTE_TO_CHAN(v[1]),
UBYTE_TO_CHAN(v[2]),
- CHAN_MAX);
-#endif
+ CHAN_MAX );
}
static void
_tnl_Color4fv( const GLfloat *v )
{
-#if CHAN_BITS == 8
- GLubyte col[4];
+ GLchan col[4];
GET_IMMEDIATE;
- UNCLAMPED_FLOAT_TO_UBYTE(col[0], v[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(col[1], v[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(col[2], v[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(col[3], v[3]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[0], v[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[1], v[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[2], v[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[3], v[3]);
COLORV( IM, col );
-#else
- GET_IMMEDIATE;
- COLOR(IM,
- UNCLAMPED_FLOAT_TO_CHAN(v[0]),
- UNCLAMPED_FLOAT_TO_CHAN(v[1]),
- UNCLAMPED_FLOAT_TO_CHAN(v[2]),
- UNCLAMPED_FLOAT_TO_CHAN(v[3]));
-#endif
}
@@ -524,17 +477,12 @@ _tnl_Color4fv( const GLfloat *v )
static void
_tnl_Color4ubv( const GLubyte *v)
{
-#if CHAN_BITS == 8
- GET_IMMEDIATE;
- COLORV( IM, v );
-#else
GET_IMMEDIATE;
COLOR(IM,
UBYTE_TO_CHAN(v[0]),
UBYTE_TO_CHAN(v[1]),
UBYTE_TO_CHAN(v[2]),
UBYTE_TO_CHAN(v[3]));
-#endif
}
@@ -564,20 +512,12 @@ _tnl_Color4ubv( const GLubyte *v)
static void
_tnl_SecondaryColor3fEXT( GLfloat red, GLfloat green, GLfloat blue )
{
-#if CHAN_BITS == 8
- GLubyte col[3];
+ GLchan col[3];
GET_IMMEDIATE;
- UNCLAMPED_FLOAT_TO_UBYTE(col[0], red);
- UNCLAMPED_FLOAT_TO_UBYTE(col[1], green);
- UNCLAMPED_FLOAT_TO_UBYTE(col[2], blue);
+ UNCLAMPED_FLOAT_TO_CHAN(col[0], red);
+ UNCLAMPED_FLOAT_TO_CHAN(col[1], green);
+ UNCLAMPED_FLOAT_TO_CHAN(col[2], blue);
SECONDARY_COLORV( IM, col );
-#else
- GET_IMMEDIATE;
- SECONDARY_COLOR(IM,
- UNCLAMPED_FLOAT_TO_CHAN(red),
- UNCLAMPED_FLOAT_TO_CHAN(green),
- UNCLAMPED_FLOAT_TO_CHAN(blue));
-#endif
}
@@ -585,16 +525,11 @@ _tnl_SecondaryColor3fEXT( GLfloat red, GLfloat green, GLfloat blue )
static void
_tnl_SecondaryColor3ubEXT( GLubyte red, GLubyte green, GLubyte blue )
{
-#if CHAN_BITS == 8
- GET_IMMEDIATE;
- SECONDARY_COLOR( IM, red, green, blue );
-#else
GET_IMMEDIATE;
SECONDARY_COLOR(IM,
UBYTE_TO_CHAN(red),
UBYTE_TO_CHAN(green),
UBYTE_TO_CHAN(blue));
-#endif
}
@@ -603,20 +538,12 @@ _tnl_SecondaryColor3ubEXT( GLubyte red, GLubyte green, GLubyte blue )
static void
_tnl_SecondaryColor3fvEXT( const GLfloat *v )
{
-#if CHAN_BITS == 8
- GLubyte col[3];
+ GLchan col[3];
GET_IMMEDIATE;
- UNCLAMPED_FLOAT_TO_UBYTE(col[0], v[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(col[1], v[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(col[2], v[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[0], v[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[1], v[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(col[2], v[2]);
SECONDARY_COLORV( IM, col );
-#else
- GET_IMMEDIATE;
- SECONDARY_COLOR(IM,
- UNCLAMPED_FLOAT_TO_CHAN(v[0]),
- UNCLAMPED_FLOAT_TO_CHAN(v[1]),
- UNCLAMPED_FLOAT_TO_CHAN(v[2]));
-#endif
}
@@ -624,16 +551,11 @@ _tnl_SecondaryColor3fvEXT( const GLfloat *v )
static void
_tnl_SecondaryColor3ubvEXT( const GLubyte *v )
{
-#if CHAN_BITS == 8
- GET_IMMEDIATE;
- SECONDARY_COLOR( IM, v[0], v[1], v[2] );
-#else
GET_IMMEDIATE;
SECONDARY_COLOR(IM,
UBYTE_TO_CHAN(v[0]),
UBYTE_TO_CHAN(v[1]),
UBYTE_TO_CHAN(v[2]));
-#endif
}
diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c
index ec79c7e52be..83a76294b6c 100644
--- a/src/mesa/tnl/t_imm_elt.c
+++ b/src/mesa/tnl/t_imm_elt.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_elt.c,v 1.2 2001/01/02 22:02:53 brianp Exp $ */
+/* $Id: t_imm_elt.c,v 1.3 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -68,13 +68,22 @@ typedef void (*trans_elt_1ub_func)(GLubyte *to,
GLuint n );
typedef void (*trans_elt_4ub_func)(GLubyte (*to)[4],
- CONST void *ptr,
- GLuint stride,
- GLuint *flags,
- GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n );
+ CONST void *ptr,
+ GLuint stride,
+ GLuint *flags,
+ GLuint *elts,
+ GLuint match,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_elt_4us_func)(GLushort (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint *flags,
+ GLuint *elts,
+ GLuint match,
+ GLuint start,
+ GLuint n );
typedef void (*trans_elt_4f_func)(GLfloat (*to)[4],
CONST void *ptr,
@@ -102,6 +111,7 @@ static trans_elt_1ui_func _tnl_trans_elt_1ui_tab[MAX_TYPES];
static trans_elt_1ub_func _tnl_trans_elt_1ub_tab[MAX_TYPES];
static trans_elt_3f_func _tnl_trans_elt_3f_tab[MAX_TYPES];
static trans_elt_4ub_func _tnl_trans_elt_4ub_tab[5][MAX_TYPES];
+static trans_elt_4us_func _tnl_trans_elt_4us_tab[5][MAX_TYPES];
static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
@@ -141,6 +151,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
+#define TRX_US(us, f,n) us = BYTE_TO_USHORT( PTR_ELT(f,n) )
#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
@@ -154,6 +165,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define INIT init_trans_3_GLbyte_elt
#define DEST_4F trans_3_GLbyte_4f_elt
#define DEST_4UB trans_3_GLbyte_4ub_elt
+#define DEST_4US trans_3_GLbyte_4us_elt
#define DEST_3F trans_3_GLbyte_3f_elt
#include "math/m_trans_tmp.h"
@@ -173,6 +185,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#undef TRX_3F
#undef TRX_4F
#undef TRX_UB
+#undef TRX_US
#undef TRX_UI
#undef SRC_IDX
@@ -183,6 +196,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define TRX_3F(f,n) /* unused */
#define TRX_4F(f,n) /* unused */
#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
+#define TRX_US(us, f,n) us = PTR_ELT(f,n)
#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
/* 4ub->4ub handled in special case below.
@@ -191,6 +205,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define SZ 3
#define INIT init_trans_3_GLubyte_elt
#define DEST_4UB trans_3_GLubyte_4ub_elt
+#define DEST_4US trans_3_GLubyte_4us_elt
#include "math/m_trans_tmp.h"
@@ -205,6 +220,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#undef TRX_3F
#undef TRX_4F
#undef TRX_UB
+#undef TRX_US
#undef TRX_UI
@@ -215,6 +231,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
+#define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n))
#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
@@ -222,12 +239,14 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define INIT init_trans_4_GLshort_elt
#define DEST_4F trans_4_GLshort_4f_elt
#define DEST_4UB trans_4_GLshort_4ub_elt
+#define DEST_4US trans_4_GLshort_4us_elt
#include "math/m_trans_tmp.h"
#define SZ 3
#define INIT init_trans_3_GLshort_elt
#define DEST_4F trans_3_GLshort_4f_elt
#define DEST_4UB trans_3_GLshort_4ub_elt
+#define DEST_4US trans_3_GLshort_4us_elt
#define DEST_3F trans_3_GLshort_3f_elt
#include "math/m_trans_tmp.h"
@@ -249,6 +268,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#undef TRX_3F
#undef TRX_4F
#undef TRX_UB
+#undef TRX_US
#undef TRX_UI
@@ -259,6 +279,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
+#define TRX_US(us,f,n) us = PTR_ELT(f,n)
#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
@@ -266,12 +287,14 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define INIT init_trans_4_GLushort_elt
#define DEST_4F trans_4_GLushort_4f_elt
#define DEST_4UB trans_4_GLushort_4ub_elt
+#define DEST_4US trans_4_GLushort_4us_elt
#include "math/m_trans_tmp.h"
#define SZ 3
#define INIT init_trans_3_GLushort_elt
#define DEST_4F trans_3_GLushort_4f_elt
#define DEST_4UB trans_3_GLushort_4ub_elt
+#define DEST_4US trans_3_GLushort_4us_elt
#define DEST_3F trans_3_GLushort_3f_elt
#include "math/m_trans_tmp.h"
@@ -292,6 +315,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#undef TRX_3F
#undef TRX_4F
#undef TRX_UB
+#undef TRX_US
#undef TRX_UI
@@ -302,6 +326,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
+#define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n))
#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
@@ -309,12 +334,14 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define INIT init_trans_4_GLint_elt
#define DEST_4F trans_4_GLint_4f_elt
#define DEST_4UB trans_4_GLint_4ub_elt
+#define DEST_4US trans_4_GLint_4us_elt
#include "math/m_trans_tmp.h"
#define SZ 3
#define INIT init_trans_3_GLint_elt
#define DEST_4F trans_3_GLint_4f_elt
#define DEST_4UB trans_3_GLint_4ub_elt
+#define DEST_4US trans_3_GLint_4us_elt
#define DEST_3F trans_3_GLint_3f_elt
#include "math/m_trans_tmp.h"
@@ -336,6 +363,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#undef TRX_3F
#undef TRX_4F
#undef TRX_UB
+#undef TRX_US
#undef TRX_UI
@@ -346,6 +374,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define TRX_3F(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) )
#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
+#define TRX_US(us, f,n) us = (GLushort) (PTR_ELT(f,n) >> 16)
#define TRX_UI(f,n) PTR_ELT(f,n)
@@ -353,12 +382,14 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define INIT init_trans_4_GLuint_elt
#define DEST_4F trans_4_GLuint_4f_elt
#define DEST_4UB trans_4_GLuint_4ub_elt
+#define DEST_4US trans_4_GLuint_4us_elt
#include "math/m_trans_tmp.h"
#define SZ 3
#define INIT init_trans_3_GLuint_elt
#define DEST_4F trans_3_GLuint_4f_elt
#define DEST_4UB trans_3_GLuint_4ub_elt
+#define DEST_4US trans_3_GLuint_4us_elt
#define DEST_3F trans_3_GLuint_3f_elt
#include "math/m_trans_tmp.h"
@@ -379,6 +410,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#undef TRX_3F
#undef TRX_4F
#undef TRX_UB
+#undef TRX_US
#undef TRX_UI
@@ -388,7 +420,8 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define SRC_IDX TYPE_IDX(GL_DOUBLE)
#define TRX_3F(f,n) PTR_ELT(f,n)
#define TRX_4F(f,n) PTR_ELT(f,n)
-#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_CHAN(ub, PTR_ELT(f,n))
+#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
+#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n))
#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
#define TRX_1F(f,n) PTR_ELT(f,n)
@@ -397,12 +430,14 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define INIT init_trans_4_GLdouble_elt
#define DEST_4F trans_4_GLdouble_4f_elt
#define DEST_4UB trans_4_GLdouble_4ub_elt
+#define DEST_4US trans_4_GLdouble_4us_elt
#include "math/m_trans_tmp.h"
#define SZ 3
#define INIT init_trans_3_GLdouble_elt
#define DEST_4F trans_3_GLdouble_4f_elt
#define DEST_4UB trans_3_GLdouble_4ub_elt
+#define DEST_4US trans_3_GLdouble_4us_elt
#define DEST_3F trans_3_GLdouble_3f_elt
#include "math/m_trans_tmp.h"
@@ -429,6 +464,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define SZ 4
#define INIT init_trans_4_GLfloat_elt
#define DEST_4UB trans_4_GLfloat_4ub_elt
+#define DEST_4US trans_4_GLfloat_4us_elt
#define DEST_4F trans_4_GLfloat_4f_elt
#include "math/m_trans_tmp.h"
@@ -436,6 +472,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#define INIT init_trans_3_GLfloat_elt
#define DEST_4F trans_3_GLfloat_4f_elt
#define DEST_4UB trans_3_GLfloat_4ub_elt
+#define DEST_4US trans_3_GLfloat_4us_elt
#define DEST_3F trans_3_GLfloat_3f_elt
#include "math/m_trans_tmp.h"
@@ -457,13 +494,14 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
#undef TRX_3F
#undef TRX_4F
#undef TRX_UB
+#undef TRX_US
#undef TRX_UI
static void trans_4_GLubyte_4ub(GLubyte (*t)[4],
- CONST void *Ptr,
- GLuint stride,
- ARGS )
+ CONST void *Ptr,
+ GLuint stride,
+ ARGS )
{
const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
const GLubyte *first = f;
@@ -498,6 +536,7 @@ static void init_translate_elt(void)
MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
+ MEMSET( TAB(_4us), 0, sizeof(TAB(_4us)) );
MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub;
@@ -598,43 +637,62 @@ static void _tnl_trans_elt_1ub(GLubyte *to,
GLuint n )
{
_tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to,
- from->Ptr,
- from->StrideB,
- flags,
- elts,
- match,
- start,
- n );
+ from->Ptr,
+ from->StrideB,
+ flags,
+ elts,
+ match,
+ start,
+ n );
}
static void _tnl_trans_elt_4ub(GLubyte (*to)[4],
- const struct gl_client_array *from,
- GLuint *flags,
- GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n )
+ const struct gl_client_array *from,
+ GLuint *flags,
+ GLuint *elts,
+ GLuint match,
+ GLuint start,
+ GLuint n )
{
_tnl_trans_elt_4ub_tab[from->Size][TYPE_IDX(from->Type)]( to,
- from->Ptr,
- from->StrideB,
- flags,
- elts,
- match,
- start,
- n );
+ from->Ptr,
+ from->StrideB,
+ flags,
+ elts,
+ match,
+ start,
+ n );
+
+}
+
+static void _tnl_trans_elt_4us(GLushort (*to)[4],
+ const struct gl_client_array *from,
+ GLuint *flags,
+ GLuint *elts,
+ GLuint match,
+ GLuint start,
+ GLuint n )
+{
+ _tnl_trans_elt_4us_tab[from->Size][TYPE_IDX(from->Type)]( to,
+ from->Ptr,
+ from->StrideB,
+ flags,
+ elts,
+ match,
+ start,
+ n );
}
static void _tnl_trans_elt_4f(GLfloat (*to)[4],
- const struct gl_client_array *from,
- GLuint *flags,
- GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n )
+ const struct gl_client_array *from,
+ GLuint *flags,
+ GLuint *elts,
+ GLuint match,
+ GLuint start,
+ GLuint n )
{
_tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to,
from->Ptr,
@@ -710,18 +768,43 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
flags, elts, (VERT_ELT|VERT_EDGE),
start, count);
- if (translate & VERT_RGBA)
+ if (translate & VERT_RGBA) {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
_tnl_trans_elt_4ub( IM->Color,
- &ctx->Array.Color,
- flags, elts, (VERT_ELT|VERT_RGBA),
- start, count);
-
+ &ctx->Array.Color,
+ flags, elts, (VERT_ELT|VERT_RGBA),
+ start, count);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ _tnl_trans_elt_4us( IM->Color,
+ &ctx->Array.Color,
+ flags, elts, (VERT_ELT|VERT_RGBA),
+ start, count);
+#elif CHAN_TYPE == GL_FLOAT
+ _tnl_trans_elt_4f( IM->Color,
+ &ctx->Array.Color,
+ flags, elts, (VERT_ELT|VERT_RGBA),
+ start, count);
+#endif
+ }
- if (translate & VERT_SPEC_RGB)
+ if (translate & VERT_SPEC_RGB) {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
_tnl_trans_elt_4ub( IM->SecondaryColor,
- &ctx->Array.SecondaryColor,
- flags, elts, (VERT_ELT|VERT_SPEC_RGB),
- start, count);
+ &ctx->Array.SecondaryColor,
+ flags, elts, (VERT_ELT|VERT_SPEC_RGB),
+ start, count);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ _tnl_trans_elt_4us( IM->SecondaryColor,
+ &ctx->Array.SecondaryColor,
+ flags, elts, (VERT_ELT|VERT_SPEC_RGB),
+ start, count);
+#elif CHAN_TYPE == GL_FLOAT
+ _tnl_trans_elt_4f( IM->SecondaryColor,
+ &ctx->Array.SecondaryColor,
+ flags, elts, (VERT_ELT|VERT_SPEC_RGB),
+ start, count);
+#endif
+ }
if (translate & VERT_FOG_COORD)
_tnl_trans_elt_1f( IM->FogCoord,
diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c
index 235baa38b8b..a7c5b7db039 100644
--- a/src/mesa/tnl/t_imm_eval.c
+++ b/src/mesa/tnl/t_imm_eval.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_eval.c,v 1.3 2001/01/03 15:59:30 brianp Exp $ */
+/* $Id: t_imm_eval.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -144,14 +144,21 @@ static void eval1_norm( GLvector3f *dest,
}
}
-static void eval1_color( GLvector4ub *dest,
+static void eval1_color(
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ GLvector4ub *dest,
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ GLvector4us *dest,
+#elif CHAN_TYPE == GL_FLOAT
+ GLvector4f *dest,
+#endif
GLfloat coord[][4],
const GLuint *flags,
struct gl_1d_map *map )
{
const GLfloat u1 = map->u1;
const GLfloat du = map->du;
- GLubyte (*to)[4] = dest->data;
+ GLchan (*to)[4] = dest->data;
GLuint i;
for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) {
@@ -276,7 +283,14 @@ static void eval2_1ui( GLvector1ui *dest,
-static void eval2_color( GLvector4ub *dest,
+static void eval2_color(
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ GLvector4ub *dest,
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ GLvector4us *dest,
+#elif CHAN_TYPE == GL_FLOAT
+ GLvector4f *dest,
+#endif
GLfloat coord[][4],
GLuint *flags,
struct gl_2d_map *map )
@@ -285,7 +299,7 @@ static void eval2_color( GLvector4ub *dest,
const GLfloat du = map->du;
const GLfloat v1 = map->v1;
const GLfloat dv = map->dv;
- GLubyte (*to)[4] = dest->data;
+ GLchan (*to)[4] = dest->data;
GLuint i;
for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) {
@@ -312,7 +326,7 @@ static void copy_3f( GLfloat to[][3], GLfloat from[][3], GLuint count )
MEMCPY( to, from, (count) * sizeof(to[0]));
}
-static void copy_4ub( GLubyte to[][4], GLubyte from[][4], GLuint count )
+static void copy_4chan( GLchan to[][4], GLchan from[][4], GLuint count )
{
MEMCPY( to, from, (count) * sizeof(to[0]));
}
@@ -472,10 +486,10 @@ void _tnl_eval_vb( GLcontext *ctx,
if (req & VERT_RGBA)
{
if (!all_eval)
- copy_4ub( store->Color, tmp->Color.data, count );
+ copy_4chan( store->Color, tmp->Color.data, count );
tmp->Color.data = store->Color;
- tmp->Color.start = (GLubyte *)store->Color;
+ tmp->Color.start = (GLchan *) store->Color;
if (ctx->Eval.Map1Color4 && any_eval1)
eval1_color( &tmp->Color, coord, flags, &ctx->EvalMap.Map1Color4 );
diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c
index 4d3f874ce4d..5889592a1a6 100644
--- a/src/mesa/tnl/t_imm_exec.c
+++ b/src/mesa/tnl/t_imm_exec.c
@@ -1,10 +1,10 @@
-/* $Id: t_imm_exec.c,v 1.8 2001/01/14 06:14:21 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.9 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -253,7 +253,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM )
if (inputs & VERT_SPEC_RGB) {
tmp->SecondaryColor.data = IM->SecondaryColor + start;
- tmp->SecondaryColor.start = (GLubyte *)(IM->SecondaryColor + start);
+ tmp->SecondaryColor.start = (GLchan *)(IM->SecondaryColor + start);
tmp->SecondaryColor.count = count;
VB->SecondaryColorPtr[0] = &tmp->SecondaryColor;
}
@@ -264,7 +264,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM )
if (inputs & VERT_RGBA) {
tmp->Color.data = IM->Color + start;
- tmp->Color.start = (GLubyte *)(IM->Color + start);
+ tmp->Color.start = (GLchan *)(IM->Color + start);
tmp->Color.count = count;
VB->ColorPtr[0] = &tmp->Color;
}
@@ -486,8 +486,16 @@ void _tnl_imm_init( GLcontext *ctx )
gl_vector4f_init( &tmp->Obj, 0, 0 );
gl_vector3f_init( &tmp->Normal, 0, 0 );
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
gl_vector4ub_init( &tmp->Color, 0, 0 );
gl_vector4ub_init( &tmp->SecondaryColor, 0, 0 );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ gl_vector4us_init( &tmp->Color, 0, 0 );
+ gl_vector4us_init( &tmp->SecondaryColor, 0, 0 );
+#elif CHAN_TYPE == GL_FLOAT
+ gl_vector4f_init( &tmp->Color, 0, 0 );
+ gl_vector4f_init( &tmp->SecondaryColor, 0, 0 );
+#endif
gl_vector1f_init( &tmp->FogCoord, 0, 0 );
gl_vector1ui_init( &tmp->Index, 0, 0 );
gl_vector1ub_init( &tmp->EdgeFlag, 0, 0 );
diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c
index d4489160dd2..44bd4c4c338 100644
--- a/src/mesa/tnl/t_imm_fixup.c
+++ b/src/mesa/tnl/t_imm_fixup.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_fixup.c,v 1.3 2001/01/08 21:56:00 keithw Exp $ */
+/* $Id: t_imm_fixup.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,6 +34,7 @@
#include "context.h"
#include "enums.h"
#include "dlist.h"
+#include "colormac.h"
#include "macros.h"
#include "mem.h"
#include "mmath.h"
@@ -124,13 +125,13 @@ fixup_1ub( GLubyte *data, GLuint flag[], GLuint start, GLuint match )
static void
-fixup_4ub( GLubyte data[][4], GLuint flag[], GLuint start, GLuint match )
+fixup_4chan( GLchan data[][4], GLuint flag[], GLuint start, GLuint match )
{
GLuint i = start;
for (;;) {
if ((flag[++i] & match) == 0) {
- COPY_4UBV(data[i], data[i-1]);
+ COPY_CHAN4(data[i], data[i-1]);
if (flag[i] & VERT_END_VB) break;
}
}
@@ -197,14 +198,14 @@ fixup_first_1ub( GLubyte data[], GLuint flag[], GLuint match,
static void
-fixup_first_4ub( GLubyte data[][4], GLuint flag[], GLuint match,
- GLuint start, GLubyte dflt[4] )
+fixup_first_4chan( GLchan data[][4], GLuint flag[], GLuint match,
+ GLuint start, GLchan dflt[4] )
{
GLuint i = start-1;
match |= VERT_END_VB;
while ((flag[++i]&match) == 0)
- COPY_4UBV(data[i], dflt);
+ COPY_CHAN4(data[i], dflt);
}
@@ -250,11 +251,11 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
}
if (copy & VERT_RGBA) {
- COPY_4UBV( IM->Color[start], ctx->Current.Color);
+ COPY_CHAN4( IM->Color[start], ctx->Current.Color);
}
if (copy & VERT_SPEC_RGB)
- COPY_4UBV( IM->SecondaryColor[start], ctx->Current.SecondaryColor);
+ COPY_CHAN4( IM->SecondaryColor[start], ctx->Current.SecondaryColor);
if (copy & VERT_FOG_COORD)
IM->FogCoord[start] = ctx->Current.FogCoord;
@@ -308,17 +309,17 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
if (fixup & VERT_RGBA) {
if (orflag & VERT_RGBA)
- fixup_4ub( IM->Color, IM->Flag, start, VERT_RGBA );
+ fixup_4chan( IM->Color, IM->Flag, start, VERT_RGBA );
else
- fixup_first_4ub( IM->Color, IM->Flag, VERT_END_VB, start, IM->Color[start] );
+ fixup_first_4chan( IM->Color, IM->Flag, VERT_END_VB, start, IM->Color[start] );
}
if (fixup & VERT_SPEC_RGB) {
if (orflag & VERT_SPEC_RGB)
- fixup_4ub( IM->SecondaryColor, IM->Flag, start, VERT_SPEC_RGB );
+ fixup_4chan( IM->SecondaryColor, IM->Flag, start, VERT_SPEC_RGB );
else
- fixup_first_4ub( IM->SecondaryColor, IM->Flag, VERT_END_VB, start,
- IM->SecondaryColor[start] );
+ fixup_first_4chan( IM->SecondaryColor, IM->Flag, VERT_END_VB, start,
+ IM->SecondaryColor[start] );
}
if (fixup & VERT_FOG_COORD) {
@@ -393,7 +394,7 @@ static void copy_vertices( GLcontext *ctx,
COPY_4FV( next->Obj[dst], prev->Obj[src] );
COPY_3FV( next->Normal[dst], prev->Normal[src] );
- COPY_4UBV( next->Color[dst], prev->Color[src] );
+ COPY_CHAN4( next->Color[dst], prev->Color[src] );
if (prev->OrFlag & VERT_TEX_ANY) {
GLuint i;
@@ -409,7 +410,7 @@ static void copy_vertices( GLcontext *ctx,
next->Elt[dst] = prev->Elt[src];
next->EdgeFlag[dst] = prev->EdgeFlag[src];
next->Index[dst] = prev->Index[src];
- COPY_4UBV( next->SecondaryColor[dst], prev->SecondaryColor[src] );
+ COPY_CHAN4( next->SecondaryColor[dst], prev->SecondaryColor[src] );
next->FogCoord[dst] = prev->FogCoord[src];
next->Flag[dst] = (prev->CopyOrFlag & VERT_FIXUP);
next->CopyOrFlag |= prev->Flag[src]; /* redundant for current_im */
@@ -535,12 +536,12 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM )
ctx->Current.Index );
if (fixup & VERT_RGBA)
- fixup_first_4ub(IM->Color, IM->Flag, VERT_RGBA, start,
- ctx->Current.Color );
+ fixup_first_4chan(IM->Color, IM->Flag, VERT_RGBA, start,
+ ctx->Current.Color );
if (fixup & VERT_SPEC_RGB)
- fixup_first_4ub(IM->SecondaryColor, IM->Flag, VERT_SPEC_RGB, start,
- ctx->Current.SecondaryColor );
+ fixup_first_4chan(IM->SecondaryColor, IM->Flag, VERT_SPEC_RGB, start,
+ ctx->Current.SecondaryColor );
if (fixup & VERT_FOG_COORD)
fixup_first_1f(IM->FogCoord, IM->Flag, VERT_FOG_COORD, start,
@@ -783,7 +784,7 @@ void _tnl_fixup_purged_eval( GLcontext *ctx,
fixup_1ui( store->Index, flags, 0, VERT_INDEX|fixup_fence );
if (fixup & VERT_RGBA)
- fixup_4ub( store->Color, flags, 0, VERT_RGBA|fixup_fence );
+ fixup_4chan( store->Color, flags, 0, VERT_RGBA|fixup_fence );
if (fixup & VERT_NORM)
fixup_3f( store->Normal, flags, 0, VERT_NORM|fixup_fence );
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 60a87ef8abd..a4f7cfa3c31 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_light.c,v 1.4 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: t_vb_light.c,v 1.5 2001/01/24 00:04:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,10 +49,17 @@ typedef void (*light_func)( GLcontext *ctx,
GLvector4f *input );
struct light_stage_data {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
GLvector4ub LitColor[2];
- GLvector1ui LitIndex[2];
GLvector4ub LitSecondary[2];
-
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ GLvector4us LitColor[2];
+ GLvector4us LitSecondary[2];
+#elif CHAN_TYPE == GL_FLOAT
+ GLvector4f LitColor[2];
+ GLvector4f LitSecondary[2];
+#endif
+ GLvector1ui LitIndex[2];
light_func *light_func_tab;
};
@@ -216,10 +223,22 @@ static GLboolean run_init_lighting( GLcontext *ctx,
*/
init_lighting();
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
gl_vector4ub_alloc( &store->LitColor[0], 0, size, 32 );
gl_vector4ub_alloc( &store->LitColor[1], 0, size, 32 );
gl_vector4ub_alloc( &store->LitSecondary[0], 0, size, 32 );
gl_vector4ub_alloc( &store->LitSecondary[1], 0, size, 32 );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ gl_vector4us_alloc( &store->LitColor[0], 0, size, 32 );
+ gl_vector4us_alloc( &store->LitColor[1], 0, size, 32 );
+ gl_vector4us_alloc( &store->LitSecondary[0], 0, size, 32 );
+ gl_vector4us_alloc( &store->LitSecondary[1], 0, size, 32 );
+#elif CHAN_TYPE == GL_FLOAT
+ gl_vector4f_alloc( &store->LitColor[0], 0, size, 32 );
+ gl_vector4f_alloc( &store->LitColor[1], 0, size, 32 );
+ gl_vector4f_alloc( &store->LitSecondary[0], 0, size, 32 );
+ gl_vector4f_alloc( &store->LitSecondary[1], 0, size, 32 );
+#endif
gl_vector1ui_alloc( &store->LitIndex[0], 0, size, 32 );
gl_vector1ui_alloc( &store->LitIndex[1], 0, size, 32 );
@@ -259,12 +278,24 @@ static void dtr( struct gl_pipeline_stage *stage )
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
if (store) {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
gl_vector4ub_free( &store->LitColor[0] );
gl_vector4ub_free( &store->LitColor[1] );
- gl_vector1ui_free( &store->LitIndex[0] );
- gl_vector1ui_free( &store->LitIndex[1] );
gl_vector4ub_free( &store->LitSecondary[0] );
gl_vector4ub_free( &store->LitSecondary[1] );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ gl_vector4us_free( &store->LitColor[0] );
+ gl_vector4us_free( &store->LitColor[1] );
+ gl_vector4us_free( &store->LitSecondary[0] );
+ gl_vector4us_free( &store->LitSecondary[1] );
+#elif CHAN_TYPE == GL_FLOAT
+ gl_vector4f_free( &store->LitColor[0] );
+ gl_vector4f_free( &store->LitColor[1] );
+ gl_vector4f_free( &store->LitSecondary[0] );
+ gl_vector4f_free( &store->LitSecondary[1] );
+#endif
+ gl_vector1ui_free( &store->LitIndex[0] );
+ gl_vector1ui_free( &store->LitIndex[1] );
FREE( store );
stage->private = 0;
}
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index 575c568c06f..1fe896c6068 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.3 2001/01/17 02:49:39 keithw Exp $ */
+/* $Id: t_vb_lighttmp.h,v 1.4 2001/01/24 00:05:00 brianp 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_4UB(CMcolor, (4 * sizeof(GLubyte)))
+# define CMSTRIDE STRIDE_4CHAN(CMcolor, (4 * sizeof(GLchan)))
# 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_4UB(CMcolor, CMstride)
+# define CMSTRIDE STRIDE_4CHAN(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 */
@@ -307,7 +307,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
- GLubyte (*CMcolor)[4];
+ GLchan (*CMcolor)[4];
GLuint CMstride;
GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data;
@@ -508,7 +508,7 @@ 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;
- GLubyte (*CMcolor)[4];
+ GLchan (*CMcolor)[4];
GLuint CMstride;
GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data;
GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data;
@@ -636,7 +636,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
const GLchan *sumA = ctx->Light._BaseAlpha;
GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
- GLubyte (*CMcolor)[4];
+ GLchan (*CMcolor)[4];
GLuint CMstride;
GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data;
GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data;
@@ -770,7 +770,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;
- GLubyte (*CMcolor)[4];
+ GLchan (*CMcolor)[4];
GLuint CMstride;
GLuint *flags = VB->Flag;
GLuint *indexResult[2];