-/* $Id: ac_import.c,v 1.6 2001/02/07 16:00:58 keithw Exp $ */
+/* $Id: ac_import.c,v 1.7 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
ASSERT(type == CHAN_TYPE);
ASSERT(stride == 4 * sizeof(GLchan) || stride == 0);
-#if CHAN_TYPE == GL_UNSIGNED_BYTE
- _math_trans_4ub( to->Ptr,
- from->Ptr,
- from->StrideB,
- from->Type,
- from->Size,
- 0,
- ac->count - ac->start);
-#elif CHAN_TYPE == GL_UNSIGNED_SHORT
- _math_trans_4us( to->Ptr,
- from->Ptr,
- from->StrideB,
- from->Type,
- from->Size,
- 0,
- ac->count - ac->start);
-#elif CHAN_TYPE == GL_FLOAT
- _math_trans_4f( to->Ptr,
- from->Ptr,
- from->StrideB,
- from->Type,
- from->Size,
- 0,
- ac->count - ac->start);
-#endif
+ _math_trans_4chan( to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
to->Size = from->Size;
to->StrideB = 4 * sizeof(GLchan);
ASSERT(type == CHAN_TYPE);
ASSERT(stride == 4 * sizeof(GLchan) || stride == 0);
-#if CHAN_TYPE == GL_UNSIGNED_BYTE
- _math_trans_4ub( to->Ptr,
- from->Ptr,
- from->StrideB,
- from->Type,
- from->Size,
- 0,
- ac->count - ac->start);
-#elif CHAN_TYPE == GL_UNSIGNED_SHORT
- _math_trans_4us( to->Ptr,
- from->Ptr,
- from->StrideB,
- from->Type,
- from->Size,
- 0,
- ac->count - ac->start);
-#elif CHAN_TYPE == GL_FLOAT
- _math_trans_4f( to->Ptr,
- from->Ptr,
- from->StrideB,
- from->Type,
- from->Size,
- 0,
- ac->count - ac->start);
-#endif
+ _math_trans_4chan( to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
to->StrideB = 4 * sizeof(GLchan);
to->Type = CHAN_TYPE;
-/* $Id: m_translate.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */
+/* $Id: m_translate.c,v 1.5 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
#include "glheader.h"
+#include "mtypes.h" /* GLchan hack */
#include "colormac.h"
#include "mem.h"
#include "mmath.h"
_math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
}
+void _math_trans_4chan( GLchan (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ _math_trans_4ub( to, ptr, stride, type, size, start, n );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ _math_trans_4us( to, ptr, stride, type, size, start, n );
+#elif CHAN_TYPE == GL_FLOAT
+ _math_trans_4f( to, ptr, stride, type, size, start, n );
+#endif
+}
+
void _math_trans_4us(GLushort (*to)[4],
CONST void *ptr,
GLuint stride,
-/* $Id: m_translate.h,v 1.4 2001/01/24 00:04:59 brianp Exp $ */
+/* $Id: m_translate.h,v 1.5 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
#define _M_TRANSLATE_H_
#include "config.h"
+#include "mtypes.h" /* hack for GLchan */
GLuint start,
GLuint n );
+extern void _math_trans_4chan( GLchan (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
extern void _math_trans_4us(GLushort (*to)[4],
CONST void *ptr,
GLuint stride,
-/* $Id: m_vector.c,v 1.3 2001/01/24 00:04:59 brianp Exp $ */
+/* $Id: m_vector.c,v 1.4 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
v->flags = flags ;
}
+void gl_vector4chan_init( GLvector4chan *v, GLuint flags, GLchan (*storage)[4] )
+{
+ v->stride = 4 * sizeof(GLchan);
+ v->data = storage;
+ v->start = (GLchan *) storage;
+ v->count = 0;
+ v->flags = flags ;
+}
+
void gl_vector4us_init( GLvector4us *v, GLuint flags, GLushort (*storage)[4] )
{
v->stride = 4 * sizeof(GLushort);
v->flags = flags | VEC_MALLOC ;
}
+void gl_vector4chan_alloc( GLvector4chan *v, GLuint flags, GLuint count,
+ GLuint alignment )
+{
+ v->stride = 4 * sizeof(GLchan);
+ v->storage = ALIGN_MALLOC( count * 4 * sizeof(GLchan), alignment );
+ v->start = (GLchan *) v->storage;
+ v->data = (GLchan (*)[4]) v->storage;
+ v->count = 0;
+ v->flags = flags | VEC_MALLOC ;
+}
+
void gl_vector4us_alloc( GLvector4us *v, GLuint flags, GLuint count,
GLuint alignment )
{
}
}
+void gl_vector4chan_free( GLvector4chan *v )
+{
+ if (v->flags & VEC_MALLOC) {
+ ALIGN_FREE( v->storage );
+ v->data = NULL;
+ v->start = NULL;
+ v->storage = NULL;
+ v->flags &= ~VEC_MALLOC;
+ }
+}
+
void gl_vector4us_free( GLvector4us *v )
{
if (v->flags & VEC_MALLOC) {
-/* $Id: m_vector.h,v 1.3 2001/01/24 00:04:59 brianp Exp $ */
+/* $Id: m_vector.h,v 1.4 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
#define _M_VECTOR_H_
#include "glheader.h"
+#include "mtypes.h" /* hack for GLchan */
#define VEC_DIRTY_0 0x1
extern void gl_vector4ub_free( GLvector4ub * );
+/* For 4 * GLchan values.
+ */
+typedef struct {
+ GLchan (*data)[4];
+ GLchan *start;
+ GLuint count;
+ GLuint stride;
+ GLuint flags;
+ void *storage;
+} GLvector4chan;
+
+extern void gl_vector4chan_init( GLvector4chan *v, GLuint flags,
+ GLchan (*storage)[4] );
+extern void gl_vector4chan_alloc( GLvector4chan *v, GLuint flags, GLuint count,
+ GLuint alignment );
+extern void gl_vector4chan_free( GLvector4chan * );
+
+
+
/* For 4 * GLushort rgba values.
*/
-/* $Id: t_array_api.c,v 1.6 2001/02/15 01:33:52 keithw Exp $ */
+/* $Id: t_array_api.c,v 1.7 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
*/
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_vector4chan_init( &tmp->Color, 0, 0 );
+ gl_vector4chan_init( &tmp->SecondaryColor, 0, 0 );
gl_vector1f_init( &tmp->FogCoord, 0, 0 );
gl_vector1ui_init( &tmp->Index, 0, 0 );
gl_vector1ub_init( &tmp->EdgeFlag, 0, 0 );
-/* $Id: t_array_import.c,v 1.8 2001/02/15 01:33:52 keithw Exp $ */
+/* $Id: t_array_import.c,v 1.9 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
}
if (required & VERT_RGBA) {
-#if CHAN_TYPE == GL_UNSIGNED_BYTE
- _math_trans_4ub( IM->Color + IM->Start,
+ _math_trans_4chan( 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
+ _math_trans_4chan( IM->SecondaryColor + IM->Start,
+ ctx->Array.SecondaryColor.Ptr,
+ ctx->Array.SecondaryColor.StrideB,
+ ctx->Array.SecondaryColor.Type,
+ ctx->Array.SecondaryColor.Size,
+ start, n );
}
if (required & VERT_FOG_COORD) {
-/* $Id: t_context.h,v 1.14 2001/02/15 01:33:52 keithw Exp $ */
+/* $Id: t_context.h,v 1.15 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
{
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
+ GLvector4chan Color;
+ GLvector4chan SecondaryColor;
GLvector1ui Index;
GLvector1ub EdgeFlag;
GLvector4f TexCoord[MAX_TEXTURE_UNITS];
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 */
-#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
+ GLvector4chan *ColorPtr[2]; /* VERT_RGBA */
+ GLvector4chan *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */
GLvector1f *FogCoordPtr; /* VERT_FOG_COORD */
GLvector1f *PointSizePtr; /* VERT_POINT_SIZE */
GLmaterial (*Material)[2]; /* VERT_MATERIAL, optional */
-/* $Id: t_imm_elt.c,v 1.3 2001/01/24 00:04:59 brianp Exp $ */
+/* $Id: t_imm_elt.c,v 1.4 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
}
+static void _tnl_trans_elt_4chan(GLubyte (*to)[4],
+ const struct gl_client_array *from,
+ GLuint *flags,
+ GLuint *elts,
+ GLuint match,
+ GLuint start,
+ GLuint n )
+{
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ _tnl_trans_elt_4ub( to, from, flags, elts, match, start, n );
+ (void)_tnl_trans_elt_4us;
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ _tnl_trans_elt_4us( to, from, flags, elts, match, start, n );
+#elif CHAN_TYPE == GL_FLOAT
+ _tnl_trans_elt_4f( to, from, flags, elts, match, start, n );
+ (void)_tnl_trans_elt_4us;
+#endif
+}
+
+
+
static void _tnl_trans_elt_3f(GLfloat (*to)[3],
const struct gl_client_array *from,
GLuint *flags,
start, count);
if (translate & VERT_RGBA) {
-#if CHAN_TYPE == GL_UNSIGNED_BYTE
- _tnl_trans_elt_4ub( IM->Color,
+ _tnl_trans_elt_4chan( IM->Color,
&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 CHAN_TYPE == GL_UNSIGNED_BYTE
- _tnl_trans_elt_4ub( IM->SecondaryColor,
- &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
+ _tnl_trans_elt_4chan( IM->SecondaryColor,
+ &ctx->Array.SecondaryColor,
+ flags, elts, (VERT_ELT|VERT_SPEC_RGB),
+ start, count);
}
if (translate & VERT_FOG_COORD)
-/* $Id: t_imm_eval.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */
+/* $Id: t_imm_eval.c,v 1.5 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
}
}
-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
+static void eval1_color( GLvector4chan *dest,
GLfloat coord[][4],
const GLuint *flags,
struct gl_1d_map *map )
-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
+static void eval2_color( GLvector4chan *dest,
GLfloat coord[][4],
GLuint *flags,
struct gl_2d_map *map )
-/* $Id: t_imm_exec.c,v 1.12 2001/02/16 00:35:35 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.13 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
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_vector4chan_init( &tmp->Color, 0, 0 );
+ gl_vector4chan_init( &tmp->SecondaryColor, 0, 0 );
gl_vector1f_init( &tmp->FogCoord, 0, 0 );
gl_vector1ui_init( &tmp->Index, 0, 0 );
gl_vector1ub_init( &tmp->EdgeFlag, 0, 0 );
-/* $Id: t_vb_light.c,v 1.8 2001/02/16 18:14:42 keithw Exp $ */
+/* $Id: t_vb_light.c,v 1.9 2001/02/20 18:28:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
GLvector4f *input );
struct light_stage_data {
-#if CHAN_TYPE == GL_UNSIGNED_BYTE
- GLvector4ub LitColor[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
+ GLvector4chan LitColor[2];
+ GLvector4chan LitSecondary[2];
GLvector1ui LitIndex[2];
light_func *light_func_tab;
};
*/
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_vector4chan_alloc( &store->LitColor[0], 0, size, 32 );
+ gl_vector4chan_alloc( &store->LitColor[1], 0, size, 32 );
+ gl_vector4chan_alloc( &store->LitSecondary[0], 0, size, 32 );
+ gl_vector4chan_alloc( &store->LitSecondary[1], 0, size, 32 );
gl_vector1ui_alloc( &store->LitIndex[0], 0, size, 32 );
gl_vector1ui_alloc( &store->LitIndex[1], 0, size, 32 );
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_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_vector4chan_free( &store->LitColor[0] );
+ gl_vector4chan_free( &store->LitColor[1] );
+ gl_vector4chan_free( &store->LitSecondary[0] );
+ gl_vector4chan_free( &store->LitSecondary[1] );
gl_vector1ui_free( &store->LitIndex[0] );
gl_vector1ui_free( &store->LitIndex[1] );
FREE( store );