X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=inline;f=src%2Fmesa%2Fmain%2Fmatrix.c;h=3c5968c853f607f85c03935c5eb93ddadec5df07;hb=0d61f879a1f2e6bb37368731a29d5267e1c25195;hp=105d4a327fbd02a5e430a8625342f6609a3ac0b8;hpb=0072acd447dc6be652e63752e50215c3105322c8;p=mesa.git diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index 105d4a327fb..3c5968c853f 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -40,6 +40,7 @@ #include "context.h" #include "enums.h" #include "macros.h" +#include "mfeatures.h" #include "matrix.h" #include "mtypes.h" #include "math/m_matrix.h" @@ -139,8 +140,8 @@ _mesa_Ortho( GLdouble left, GLdouble right, * \sa glMatrixMode(). * * Flushes the vertices, validates the parameter and updates - * __struct gl_contextRec::CurrentStack and gl_transform_attrib::MatrixMode with the - * specified matrix stack. + * __struct gl_contextRec::CurrentStack and gl_transform_attrib::MatrixMode + * with the specified matrix stack. */ void GLAPIENTRY _mesa_MatrixMode( GLenum mode ) @@ -169,7 +170,8 @@ _mesa_MatrixMode( GLenum mode ) */ #if 0 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glMatrixMode(invalid tex unit %d)", + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMatrixMode(invalid tex unit %d)", ctx->Texture.CurrentUnit); return; } @@ -177,22 +179,6 @@ _mesa_MatrixMode( GLenum mode ) ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack)); ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit]; break; - case GL_MATRIX0_NV: - case GL_MATRIX1_NV: - case GL_MATRIX2_NV: - case GL_MATRIX3_NV: - case GL_MATRIX4_NV: - case GL_MATRIX5_NV: - case GL_MATRIX6_NV: - case GL_MATRIX7_NV: - if (ctx->Extensions.NV_vertex_program) { - ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); - return; - } - break; case GL_MATRIX0_ARB: case GL_MATRIX1_ARB: case GL_MATRIX2_ARB: @@ -201,8 +187,9 @@ _mesa_MatrixMode( GLenum mode ) case GL_MATRIX5_ARB: case GL_MATRIX6_ARB: case GL_MATRIX7_ARB: - if (ctx->Extensions.ARB_vertex_program || - ctx->Extensions.ARB_fragment_program) { + if (ctx->API == API_OPENGL + && (ctx->Extensions.ARB_vertex_program || + ctx->Extensions.ARB_fragment_program)) { const GLuint m = mode - GL_MATRIX0_ARB; if (m > ctx->Const.MaxProgramMatrices) { _mesa_error(ctx, GL_INVALID_ENUM, @@ -231,8 +218,8 @@ _mesa_MatrixMode( GLenum mode ) * \sa glPushMatrix(). * * Verifies the current matrix stack is not full, and duplicates the top-most - * matrix in the stack. Marks __struct gl_contextRec::NewState with the stack dirty - * flag. + * matrix in the stack. + * Marks __struct gl_contextRec::NewState with the stack dirty flag. */ void GLAPIENTRY _mesa_PushMatrix( void ) @@ -271,8 +258,8 @@ _mesa_PushMatrix( void ) * \sa glPopMatrix(). * * Flushes the vertices, verifies the current matrix stack is not empty, and - * moves the stack head down. Marks __struct gl_contextRec::NewState with the dirty - * stack flag. + * moves the stack head down. + * Marks __struct gl_contextRec::NewState with the dirty stack flag. */ void GLAPIENTRY _mesa_PopMatrix( void ) @@ -308,9 +295,9 @@ _mesa_PopMatrix( void ) * * \sa glLoadIdentity(). * - * Flushes the vertices and calls _math_matrix_set_identity() with the top-most - * matrix in the current stack. Marks __struct gl_contextRec::NewState with the stack - * dirty flag. + * Flushes the vertices and calls _math_matrix_set_identity() with the + * top-most matrix in the current stack. + * Marks __struct gl_contextRec::NewState with the stack dirty flag. */ void GLAPIENTRY _mesa_LoadIdentity( void ) @@ -333,9 +320,9 @@ _mesa_LoadIdentity( void ) * * \sa glLoadMatrixf(). * - * Flushes the vertices and calls _math_matrix_loadf() with the top-most matrix - * in the current stack and the given matrix. Marks __struct gl_contextRec::NewState - * with the dirty stack flag. + * Flushes the vertices and calls _math_matrix_loadf() with the top-most + * matrix in the current stack and the given matrix. + * Marks __struct gl_contextRec::NewState with the dirty stack flag. */ void GLAPIENTRY _mesa_LoadMatrixf( const GLfloat *m ) @@ -457,7 +444,6 @@ _mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) } -#if _HAVE_FULL_GL void GLAPIENTRY _mesa_LoadMatrixd( const GLdouble *m ) { @@ -500,10 +486,8 @@ _mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) { _mesa_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); } -#endif -#if _HAVE_FULL_GL void GLAPIENTRY _mesa_LoadTransposeMatrixfARB( const GLfloat *m ) { @@ -542,7 +526,6 @@ _mesa_MultTransposeMatrixdARB( const GLdouble *m ) _math_transposefd(tm, m); _mesa_MultMatrixf(tm); } -#endif @@ -559,8 +542,8 @@ _mesa_MultTransposeMatrixdARB( const GLdouble *m ) * Calls _math_matrix_analyse() with the top-matrix of the projection matrix * stack, and recomputes user clip positions if necessary. * - * \note This routine references __struct gl_contextRec::Tranform attribute values to - * compute userclip positions in clip space, but is only called on + * \note This routine references __struct gl_contextRec::Tranform attribute + * values to compute userclip positions in clip space, but is only called on * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values up to * date across changes to the __struct gl_contextRec::Transform attributes. */ @@ -569,7 +552,6 @@ update_projection( struct gl_context *ctx ) { _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); -#if FEATURE_userclip /* Recompute clip plane positions in clipspace. This is also done * in _mesa_ClipPlane(). */ @@ -583,7 +565,6 @@ update_projection( struct gl_context *ctx ) } } } -#endif } @@ -593,8 +574,8 @@ update_projection( struct gl_context *ctx ) * \param ctx GL context. * * Multiplies the top matrices of the projection and model view stacks into - * __struct gl_contextRec::_ModelProjectMatrix via _math_matrix_mul_matrix() and - * analyzes the resulting matrix via _math_matrix_analyse(). + * __struct gl_contextRec::_ModelProjectMatrix via _math_matrix_mul_matrix() + * and analyzes the resulting matrix via _math_matrix_analyse(). */ static void calculate_model_project_matrix( struct gl_context *ctx ) @@ -623,7 +604,7 @@ void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state ) if (new_state & _NEW_MODELVIEW) { _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - /* Bring cull position uptodate. + /* Bring cull position up to date. */ TRANSFORM_POINT3( ctx->Transform.CullObjPos, ctx->ModelviewMatrixStack.Top->inv, @@ -634,7 +615,7 @@ void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state ) if (new_state & _NEW_PROJECTION) update_projection( ctx ); - /* Keep ModelviewProject uptodate always to allow tnl + /* Keep ModelviewProject up to date always to allow tnl * implementations that go model->clip even when eye is required. */ calculate_model_project_matrix(ctx); @@ -656,8 +637,7 @@ void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state ) * \param dirtyFlag dirty flag. * * Allocates an array of \p maxDepth elements for the matrix stack and calls - * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to - * initialize it. + * _math_matrix_ctr() for each element to initialize it. */ static void init_matrix_stack( struct gl_matrix_stack *stack, @@ -669,10 +649,9 @@ init_matrix_stack( struct gl_matrix_stack *stack, stack->MaxDepth = maxDepth; stack->DirtyFlag = dirtyFlag; /* The stack */ - stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix)); + stack->Stack = calloc(maxDepth, sizeof(GLmatrix)); for (i = 0; i < maxDepth; i++) { _math_matrix_ctr(&stack->Stack[i]); - _math_matrix_alloc_inv(&stack->Stack[i]); } stack->Top = stack->Stack; } @@ -692,7 +671,7 @@ free_matrix_stack( struct gl_matrix_stack *stack ) for (i = 0; i < stack->MaxDepth; i++) { _math_matrix_dtr(&stack->Stack[i]); } - FREE(stack->Stack); + free(stack->Stack); stack->Stack = stack->Top = NULL; } @@ -767,14 +746,14 @@ void _mesa_free_matrix_data( struct gl_context *ctx ) */ void _mesa_init_transform( struct gl_context *ctx ) { - GLint i; + GLuint i; /* Transformation group */ ctx->Transform.MatrixMode = GL_MODELVIEW; ctx->Transform.Normalize = GL_FALSE; ctx->Transform.RescaleNormals = GL_FALSE; ctx->Transform.RasterPositionUnclipped = GL_FALSE; - for (i=0;iConst.MaxClipPlanes;i++) { ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 ); } ctx->Transform.ClipPlanesEnabled = 0;