diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/api_arrayelt.c | 6 | ||||
-rw-r--r-- | src/mesa/main/arbprogram.c | 10 | ||||
-rw-r--r-- | src/mesa/main/arbprogram.h | 6 | ||||
-rw-r--r-- | src/mesa/main/context.c | 1 | ||||
-rw-r--r-- | src/mesa/main/get.c | 12 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | src/mesa/main/rastpos.c | 188 | ||||
-rw-r--r-- | src/mesa/main/state.c | 4 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 78 | ||||
-rw-r--r-- | src/mesa/main/varray.h | 8 |
10 files changed, 195 insertions, 120 deletions
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index 8d64b1edc38..f8269fe61ca 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -1,10 +1,8 @@ -/* $Id: api_arrayelt.c,v 1.12 2003/01/14 04:55:45 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 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"), @@ -277,7 +275,7 @@ static void _ae_update_state( GLcontext *ctx ) AEarray *aa = actx->arrays; GLuint i; - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) + for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) if (ctx->Array.TexCoord[i].Enabled) { ta->unit = i; ta->array = &ctx->Array.TexCoord[i]; diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index 99118cf60d5..384504e15e6 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -241,14 +241,6 @@ _mesa_VertexAttrib4NuivARB(GLuint index, const GLuint *v) void -_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, - GLboolean normalized, GLsizei stride, - const GLvoid *pointer) -{ -} - - -void _mesa_EnableVertexAttribArrayARB(GLuint index) { GET_CURRENT_CONTEXT(ctx); @@ -280,7 +272,7 @@ _mesa_DisableVertexAttribArrayARB(GLuint index) ctx->Array.VertexAttrib[index].Enabled = GL_FALSE; ctx->Array._Enabled &= ~_NEW_ARRAY_ATTRIB(index); - ctx->Array.NewState &= ~_NEW_ARRAY_ATTRIB(index); + ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index); } diff --git a/src/mesa/main/arbprogram.h b/src/mesa/main/arbprogram.h index 5a4436a9487..a4030902a17 100644 --- a/src/mesa/main/arbprogram.h +++ b/src/mesa/main/arbprogram.h @@ -136,12 +136,6 @@ _mesa_VertexAttrib4NuivARB(GLuint index, const GLuint *v); extern void -_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, - GLboolean normalized, GLsizei stride, - const GLvoid *pointer); - - -extern void _mesa_EnableVertexAttribArrayARB(GLuint index); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index c5fb8148b9e..aaba851165d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1008,6 +1008,7 @@ init_attrib_groups( GLcontext *ctx ) ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES; ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; + ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits)); /* Initialize matrix stacks */ init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH, diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index dd1c0016a98..7d61d49b855 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1002,7 +1002,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: CHECK_EXTENSION_B(ARB_multitexture, pname); - *params = INT_TO_BOOL(ctx->Const.MaxTextureUnits); + *params = INT_TO_BOOL(MIN2(ctx->Const.MaxTextureImageUnits, + ctx->Const.MaxTextureCoordUnits)); break; case GL_ACTIVE_TEXTURE_ARB: CHECK_EXTENSION_B(ARB_multitexture, pname); @@ -2501,7 +2502,8 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: CHECK_EXTENSION_D(ARB_multitexture, pname); - *params = (GLdouble) ctx->Const.MaxTextureUnits; + *params = (GLdouble) MIN2(ctx->Const.MaxTextureImageUnits, + ctx->Const.MaxTextureCoordUnits); break; case GL_ACTIVE_TEXTURE_ARB: CHECK_EXTENSION_D(ARB_multitexture, pname); @@ -4000,7 +4002,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: CHECK_EXTENSION_F(ARB_multitexture, pname); - *params = (GLfloat) ctx->Const.MaxTextureUnits; + *params = (GLfloat) MIN2(ctx->Const.MaxTextureImageUnits, + ctx->Const.MaxTextureCoordUnits); break; case GL_ACTIVE_TEXTURE_ARB: CHECK_EXTENSION_F(ARB_multitexture, pname); @@ -5472,7 +5475,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: CHECK_EXTENSION_I(ARB_multitexture, pname); - *params = ctx->Const.MaxTextureUnits; + *params = MIN2(ctx->Const.MaxTextureImageUnits, + ctx->Const.MaxTextureCoordUnits); break; case GL_ACTIVE_TEXTURE_ARB: CHECK_EXTENSION_I(ARB_multitexture, pname); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b906ef42692..2b7fe01a12e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1390,9 +1390,9 @@ struct gl_constants { GLint Max3DTextureLevels; GLint MaxCubeTextureLevels; /* GL_ARB_texture_cube_map */ GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */ - GLuint MaxTextureUnits; GLuint MaxTextureCoordUnits; GLuint MaxTextureImageUnits; + GLuint MaxTextureUnits; /* = MAX(CoordUnits, ImageUnits) */ GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */ GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */ GLuint MaxArrayLockSize; diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index 5c019bd00ba..3c48a3afece 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -39,11 +39,10 @@ #include "math/m_xform.h" -/* +/** * Clip a point against the view volume. - * Input: v - vertex-vector describing the point to clip - * Return: 0 = outside view volume - * 1 = inside view volume + * \param v vertex-vector describing the point to clip + * \return 0 = outside view volume, 1 = inside view volume */ static GLuint viewclip_point( const GLfloat v[] ) @@ -73,14 +72,13 @@ viewclip_point_z( const GLfloat v[] ) -/* +/** * Clip a point against the user clipping planes. - * Input: v - vertex-vector describing the point to clip. - * Return: 0 = point was clipped - * 1 = point not clipped + * \param v vertex-vector describing the point to clip. + * \return 0 = point was clipped, 1 = point not clipped */ static GLuint -userclip_point( GLcontext* ctx, const GLfloat v[] ) +userclip_point( GLcontext *ctx, const GLfloat v[] ) { GLuint p; @@ -100,7 +98,8 @@ userclip_point( GLcontext* ctx, const GLfloat v[] ) } -/* This has been split off to allow the normal shade routines to +/** + * This has been split off to allow the normal shade routines to * get a little closer to the vertex buffer, and to use the * GLvector objects directly. * Input: ctx - the context @@ -262,11 +261,12 @@ shade_rastpos(GLcontext *ctx, } *Rindex = (GLuint) (GLint) ind; } - } -/* - * Caller: context->API.RasterPos4f + +/** + * All glRasterPos command call this function to update the current + * raster position. */ static void raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) @@ -278,100 +278,107 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) if (ctx->NewState) _mesa_update_state( ctx ); - ASSIGN_4V( v, x, y, z, w ); - TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, v ); + if (ctx->VertexProgram.Enabled) { + /* XXX implement this */ + _mesa_problem(ctx, "Vertex programs not implemented for glRasterPos"); + return; + } + else { + ASSIGN_4V( v, x, y, z, w ); + TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, v ); + + /* raster color */ + if (ctx->Light.Enabled) { + GLfloat *norm, eyenorm[3]; + GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; + + if (ctx->_NeedEyeCoords) { + GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv; + TRANSFORM_NORMAL( eyenorm, objnorm, inv ); + norm = eyenorm; + } + else { + norm = objnorm; + } - /* raster color */ - if (ctx->Light.Enabled) { - GLfloat *norm, eyenorm[3]; - GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; + shade_rastpos( ctx, v, norm, + ctx->Current.RasterColor, + ctx->Current.RasterSecondaryColor, + &ctx->Current.RasterIndex ); - if (ctx->_NeedEyeCoords) { - GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv; - TRANSFORM_NORMAL( eyenorm, objnorm, inv ); - norm = eyenorm; } else { - norm = objnorm; + /* use current color or index */ + if (ctx->Visual.rgbMode) { + COPY_4FV(ctx->Current.RasterColor, + ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); + COPY_4FV(ctx->Current.RasterSecondaryColor, + ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); + } + else { + ctx->Current.RasterIndex = ctx->Current.Index; + } } - shade_rastpos( ctx, v, norm, - ctx->Current.RasterColor, - ctx->Current.RasterSecondaryColor, - &ctx->Current.RasterIndex ); - - } - else { - /* use current color or index */ - if (ctx->Visual.rgbMode) { - COPY_4FV(ctx->Current.RasterColor, - ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); - COPY_4FV(ctx->Current.RasterSecondaryColor, - ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); + /* compute raster distance */ + if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) + ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; + else + ctx->Current.RasterDistance = + SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); + + /* apply projection matrix: clip = Proj * eye */ + TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye ); + + /* clip to view volume */ + if (ctx->Transform.RasterPositionUnclipped) { + /* GL_IBM_rasterpos_clip: only clip against Z */ + if (viewclip_point_z(clip) == 0) { + ctx->Current.RasterPosValid = GL_FALSE; + return; + } } - else { - ctx->Current.RasterIndex = ctx->Current.Index; + else if (viewclip_point(clip) == 0) { + /* Normal OpenGL behaviour */ + ctx->Current.RasterPosValid = GL_FALSE; + return; } - } - /* compute raster distance */ - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) - ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - else - ctx->Current.RasterDistance = - SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); - - /* apply projection matrix: clip = Proj * eye */ - TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye ); - - /* clip to view volume */ - if (ctx->Transform.RasterPositionUnclipped) { - /* GL_IBM_rasterpos_clip: only clip against Z */ - if (viewclip_point_z(clip) == 0) { + /* clip to user clipping planes */ + if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) { ctx->Current.RasterPosValid = GL_FALSE; return; } - } - else if (viewclip_point(clip) == 0) { - /* Normal OpenGL behaviour */ - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - - /* clip to user clipping planes */ - if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - /* ndc = clip / W */ - ASSERT( clip[3]!=0.0 ); - d = 1.0F / clip[3]; - ndc[0] = clip[0] * d; - ndc[1] = clip[1] * d; - ndc[2] = clip[2] * d; - - ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] + - ctx->Viewport._WindowMap.m[MAT_TX]); - ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] + - ctx->Viewport._WindowMap.m[MAT_TY]); - ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] + - ctx->Viewport._WindowMap.m[MAT_TZ]) / ctx->DepthMaxF; - ctx->Current.RasterPos[3] = clip[3]; - ctx->Current.RasterPosValid = GL_TRUE; + /* ndc = clip / W */ + ASSERT( clip[3]!=0.0 ); + d = 1.0F / clip[3]; + ndc[0] = clip[0] * d; + ndc[1] = clip[1] * d; + ndc[2] = clip[2] * d; + + ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] + + ctx->Viewport._WindowMap.m[MAT_TX]); + ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] + + ctx->Viewport._WindowMap.m[MAT_TY]); + ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] + + ctx->Viewport._WindowMap.m[MAT_TZ]) / ctx->DepthMaxF; + ctx->Current.RasterPos[3] = clip[3]; + ctx->Current.RasterPosValid = GL_TRUE; - { - GLuint texSet; - for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) { - COPY_4FV( ctx->Current.RasterTexCoords[texSet], - ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); + { + GLuint texSet; + for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) { + COPY_4FV( ctx->Current.RasterTexCoords[texSet], + ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); + } } + } if (ctx->RenderMode==GL_SELECT) { _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); } - } @@ -527,6 +534,11 @@ _mesa_RasterPos4sv(const GLshort *v) /*** GL_ARB_window_pos / GL_MESA_window_pos ***/ /**********************************************************************/ + +/** + * All glWindowPosMESA and glWindowPosARB commands call this function to + * update the current raster position. + */ static void window_pos3f(GLfloat x, GLfloat y, GLfloat z) { @@ -578,7 +590,7 @@ window_pos3f(GLfloat x, GLfloat y, GLfloat z) /* raster texcoord = current texcoord */ { GLuint texSet; - for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) { + for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) { COPY_4FV( ctx->Current.RasterTexCoords[texSet], ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); } diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index f14c3f9d53e..8030c9e94b6 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -867,7 +867,7 @@ update_texture_matrices( GLcontext *ctx ) ctx->Texture._TexMatEnabled = 0; - for (i=0; i < ctx->Const.MaxTextureUnits; i++) { + for (i=0; i < ctx->Const.MaxTextureCoordUnits; i++) { if (ctx->TextureMatrixStack[i].Top->flags & MAT_DIRTY) { _math_matrix_analyse( ctx->TextureMatrixStack[i].Top ); @@ -903,6 +903,8 @@ update_texture_state( GLcontext *ctx ) ctx->Texture._TexGenEnabled = 0; /* Update texture unit state. + * XXX this loop should probably be broken into separate loops for + * texture coord units and texture image units. */ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 889584780f5..5752a42577f 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,5 +1,3 @@ -/* $Id: varray.c,v 1.48 2003/03/01 01:50:22 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -438,8 +436,9 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr) } -void _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) +void +_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -500,6 +499,73 @@ void _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, void +_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, + GLboolean normalized, + GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= ctx->Const.MaxVertexProgramAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); + return; + } + + if (size < 1 || size > 4) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)"); + return; + } + + if (stride < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)"); + return; + } + + if (type == GL_UNSIGNED_BYTE && size != 4) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size!=4)"); + return; + } + + /* check for valid 'type' and compute StrideB right away */ + switch (type) { + case GL_UNSIGNED_BYTE: + ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLubyte); + break; + case GL_SHORT: + ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLshort); + break; + case GL_FLOAT: + ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLfloat); + break; + case GL_DOUBLE: + ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLdouble); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" ); + return; + } + + if (stride) + ctx->Array.VertexAttrib[index].StrideB = stride; + + ctx->Array.VertexAttrib[index].Stride = stride; + ctx->Array.VertexAttrib[index].Size = size; + ctx->Array.VertexAttrib[index].Type = type; + ctx->Array.VertexAttrib[index].Normalized = normalized; + ctx->Array.VertexAttrib[index].Ptr = (void *) ptr; + + ctx->NewState |= _NEW_ARRAY; + ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index); + + /* XXX fix + if (ctx->Driver.VertexAttribPointer) + ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr ); + */ +} + + + +void _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr) { @@ -706,14 +772,14 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, (GLubyte *) pointer + i * coffset ); } - for (i = factor; i < (GLint) ctx->Const.MaxTextureUnits; i++) { + for (i = factor; i < (GLint) ctx->Const.MaxTextureCoordUnits; i++) { _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) ); _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); } } else { GLint i; - for (i = 0; i < (GLint) ctx->Const.MaxTextureUnits; i++) { + for (i = 0; i < (GLint) ctx->Const.MaxTextureCoordUnits; i++) { _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) ); _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); } diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index cf114cda8a9..7515fc26623 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -1,4 +1,4 @@ -/* $Id: varray.h,v 1.14 2002/06/30 15:47:01 brianp Exp $ */ +/* $Id: varray.h,v 1.15 2003/05/01 22:44:03 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -108,6 +108,12 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, extern void +_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, + const GLvoid *pointer); + + +extern void _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); |