-/* $Id: matrix.c,v 1.30 2001/01/23 23:39:36 brianp Exp $ */
+/* $Id: matrix.c,v 1.34 2001/03/19 22:45:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
flags |= _NEW_COLOR_MATRIX; \
break; \
default: \
- gl_problem(ctx, where); \
+ _mesa_problem(ctx, where); \
} \
} while (0)
left == right ||
top == bottom)
{
- gl_error( ctx, GL_INVALID_VALUE, "glFrustum" );
+ _mesa_error( ctx, GL_INVALID_VALUE, "glFrustum" );
return;
}
- _math_matrix_frustrum( mat, left, right, bottom, top, nearval, farval );
+ _math_matrix_frustum( mat, left, right, bottom, top, nearval, farval );
}
bottom == top ||
nearval == farval)
{
- gl_error( ctx, GL_INVALID_VALUE, "gl_Ortho" );
+ _mesa_error( ctx, GL_INVALID_VALUE, "glOrtho" );
return;
}
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
break;
default:
- gl_error( ctx, GL_INVALID_ENUM, "glMatrixMode" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode" );
}
}
if (MESA_VERBOSE&VERBOSE_API)
fprintf(stderr, "glPushMatrix %s\n",
- gl_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
switch (ctx->Transform.MatrixMode) {
case GL_MODELVIEW:
if (ctx->ModelViewStackDepth >= MAX_MODELVIEW_STACK_DEPTH - 1) {
- gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
+ _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
_math_matrix_copy( &ctx->ModelViewStack[ctx->ModelViewStackDepth++],
break;
case GL_PROJECTION:
if (ctx->ProjectionStackDepth >= MAX_PROJECTION_STACK_DEPTH - 1) {
- gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
+ _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
_math_matrix_copy( &ctx->ProjectionStack[ctx->ProjectionStackDepth++],
{
GLuint t = ctx->Texture.CurrentTransformUnit;
if (ctx->TextureStackDepth[t] >= MAX_TEXTURE_STACK_DEPTH - 1) {
- gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
+ _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
_math_matrix_copy( &ctx->TextureStack[t][ctx->TextureStackDepth[t]++],
break;
case GL_COLOR:
if (ctx->ColorStackDepth >= MAX_COLOR_STACK_DEPTH - 1) {
- gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
+ _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
_math_matrix_copy( &ctx->ColorStack[ctx->ColorStackDepth++],
&ctx->ColorMatrix );
break;
default:
- gl_problem(ctx, "Bad matrix mode in gl_PushMatrix");
+ _mesa_problem(ctx, "Bad matrix mode in _mesa_PushMatrix");
}
}
if (MESA_VERBOSE&VERBOSE_API)
fprintf(stderr, "glPopMatrix %s\n",
- gl_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
switch (ctx->Transform.MatrixMode) {
case GL_MODELVIEW:
if (ctx->ModelViewStackDepth==0) {
- gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
+ _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
return;
}
_math_matrix_copy( &ctx->ModelView,
break;
case GL_PROJECTION:
if (ctx->ProjectionStackDepth==0) {
- gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
+ _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
return;
}
{
GLuint t = ctx->Texture.CurrentTransformUnit;
if (ctx->TextureStackDepth[t]==0) {
- gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
+ _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
return;
}
_math_matrix_copy(&ctx->TextureMatrix[t],
break;
case GL_COLOR:
if (ctx->ColorStackDepth==0) {
- gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
+ _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
return;
}
_math_matrix_copy(&ctx->ColorMatrix,
ctx->NewState |= _NEW_COLOR_MATRIX;
break;
default:
- gl_problem(ctx, "Bad matrix mode in gl_PopMatrix");
+ _mesa_problem(ctx, "Bad matrix mode in _mesa_PopMatrix");
}
}
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- gl_Viewport(ctx, x, y, width, height);
+ _mesa_set_viewport(ctx, x, y, width, height);
}
-
/*
* Define a new viewport and reallocate auxillary buffers if the size of
* the window (color buffer) has changed.
- *
- * XXX This is directly called by device drivers, BUT this function
- * may be renamed _mesa_Viewport (without ctx arg) in the future so
- * use of _mesa_Viewport is encouraged.
*/
void
-gl_Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height )
+_mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
{
- if (width<0 || height<0) {
- gl_error( ctx, GL_INVALID_VALUE, "glViewport" );
+ const GLfloat n = ctx->Viewport.Near;
+ const GLfloat f = ctx->Viewport.Far;
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glViewport" );
return;
}
ctx->Viewport._WindowMap.m[MAT_TX] = ctx->Viewport._WindowMap.m[MAT_SX] + x;
ctx->Viewport._WindowMap.m[MAT_SY] = (GLfloat) height / 2.0F;
ctx->Viewport._WindowMap.m[MAT_TY] = ctx->Viewport._WindowMap.m[MAT_SY] + y;
- ctx->Viewport._WindowMap.m[MAT_SZ] = 0.5 * ctx->DepthMaxF;
- ctx->Viewport._WindowMap.m[MAT_TZ] = 0.5 * ctx->DepthMaxF;
+ ctx->Viewport._WindowMap.m[MAT_SZ] = ctx->DepthMaxF * ((f - n) / 2.0);
+ ctx->Viewport._WindowMap.m[MAT_TZ] = ctx->DepthMaxF * ((f - n) / 2.0 + n);
ctx->Viewport._WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION;
ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
ctx->NewState |= _NEW_VIEWPORT;