summaryrefslogtreecommitdiff
path: root/xc/extras/Mesa/src/rastpos.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/extras/Mesa/src/rastpos.c')
-rw-r--r--xc/extras/Mesa/src/rastpos.c153
1 files changed, 88 insertions, 65 deletions
diff --git a/xc/extras/Mesa/src/rastpos.c b/xc/extras/Mesa/src/rastpos.c
index 7813506e2..864f63c97 100644
--- a/xc/extras/Mesa/src/rastpos.c
+++ b/xc/extras/Mesa/src/rastpos.c
@@ -1,9 +1,10 @@
+/* $Id: rastpos.c,v 1.11.4.1 2003/03/30 04:50:21 ldelgass Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -24,9 +25,6 @@
*/
-#ifdef PC_HEADER
-#include "all.h"
-#else
#include "glheader.h"
#include "clip.h"
#include "colormac.h"
@@ -42,7 +40,6 @@
#include "math/m_matrix.h"
#include "math/m_xform.h"
-#endif
/*
@@ -91,7 +88,7 @@ userclip_point( GLcontext* ctx, const GLfloat v[] )
GLuint p;
for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipEnabled[p]) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
+ v[1] * ctx->Transform._ClipUserPlane[p][1]
+ v[2] * ctx->Transform._ClipUserPlane[p][2]
@@ -285,15 +282,15 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
_mesa_update_state( ctx );
ASSIGN_4V( v, x, y, z, w );
- TRANSFORM_POINT( eye, ctx->ModelView.m, v );
+ TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, v );
/* raster color */
if (ctx->Light.Enabled) {
GLfloat *norm, eyenorm[3];
- GLfloat *objnorm = ctx->Current.Normal;
+ GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
if (ctx->_NeedEyeCoords) {
- GLfloat *inv = ctx->ModelView.inv;
+ GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv;
TRANSFORM_NORMAL( eyenorm, objnorm, inv );
norm = eyenorm;
}
@@ -310,9 +307,10 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
else {
/* use current color or index */
if (ctx->Visual.rgbMode) {
- COPY_4FV(ctx->Current.RasterColor, ctx->Current.Color);
+ COPY_4FV(ctx->Current.RasterColor,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
COPY_4FV(ctx->Current.RasterSecondaryColor,
- ctx->Current.SecondaryColor);
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1]);
}
else {
ctx->Current.RasterIndex = ctx->Current.Index;
@@ -320,11 +318,14 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
}
/* compute raster distance */
- ctx->Current.RasterDistance = (GLfloat)
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
+ else
+ ctx->Current.RasterDistance = (GLfloat)
GL_SQRT( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
/* apply projection matrix: clip = Proj * eye */
- TRANSFORM_POINT( clip, ctx->ProjectionMatrix.m, eye );
+ TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye );
/* clip to view volume */
if (ctx->Transform.RasterPositionUnclipped) {
@@ -339,8 +340,7 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
}
/* clip to user clipping planes */
- if (ctx->Transform._AnyClip &&
- userclip_point(ctx, clip) == 0) {
+ if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) {
ctx->Current.RasterPosValid = GL_FALSE;
return;
}
@@ -361,13 +361,11 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
ctx->Current.RasterPos[3] = clip[3];
ctx->Current.RasterPosValid = GL_TRUE;
- ctx->Current.RasterFogCoord = ctx->Current.FogCoord;
-
{
GLuint texSet;
for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) {
- COPY_4FV( ctx->Current.RasterMultiTexCoord[texSet],
- ctx->Current.Texcoord[texSet] );
+ COPY_4FV( ctx->Current.RasterTexCoords[texSet],
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
}
}
@@ -378,7 +376,6 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
}
-
void
_mesa_RasterPos2d(GLdouble x, GLdouble y)
{
@@ -527,41 +524,53 @@ _mesa_RasterPos4sv(const GLshort *v)
}
-
/**********************************************************************/
-/*** GL_MESA_window_pos ***/
+/*** GL_ARB_window_pos / GL_MESA_window_pos ***/
/**********************************************************************/
-
-/*
- * This is a MESA extension function. Pretty much just like glRasterPos
- * except we don't apply the modelview or projection matrices; specify a
- * window coordinate directly.
- * Caller: context->API.WindowPos4fMESA pointer.
- */
-void
-_mesa_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+static void
+window_pos3f(GLfloat x, GLfloat y, GLfloat z)
{
GET_CURRENT_CONTEXT(ctx);
+ GLfloat z2;
+
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
FLUSH_CURRENT(ctx, 0);
+ z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near)
+ + ctx->Viewport.Near;
+
/* set raster position */
ctx->Current.RasterPos[0] = x;
ctx->Current.RasterPos[1] = y;
- ctx->Current.RasterPos[2] = CLAMP( z, 0.0F, 1.0F );
- ctx->Current.RasterPos[3] = w;
+ ctx->Current.RasterPos[2] = z2;
+ ctx->Current.RasterPos[3] = 1.0F;
ctx->Current.RasterPosValid = GL_TRUE;
- ctx->Current.RasterDistance = 0.0F;
- ctx->Current.RasterFogCoord = 0.0F;
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
+ else
+ ctx->Current.RasterDistance = 0.0;
/* raster color = current color or index */
if (ctx->Visual.rgbMode) {
- ctx->Current.RasterColor[0] = (ctx->Current.Color[0]);
- ctx->Current.RasterColor[1] = (ctx->Current.Color[1]);
- ctx->Current.RasterColor[2] = (ctx->Current.Color[2]);
- ctx->Current.RasterColor[3] = (ctx->Current.Color[3]);
+ ctx->Current.RasterColor[0]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0], 0.0F, 1.0F);
+ ctx->Current.RasterColor[1]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1], 0.0F, 1.0F);
+ ctx->Current.RasterColor[2]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2], 0.0F, 1.0F);
+ ctx->Current.RasterColor[3]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[0]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[1]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[2]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[3]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3], 0.0F, 1.0F);
}
else {
ctx->Current.RasterIndex = ctx->Current.Index;
@@ -571,8 +580,8 @@ _mesa_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
GLuint texSet;
for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) {
- COPY_4FV( ctx->Current.RasterMultiTexCoord[texSet],
- ctx->Current.Texcoord[texSet] );
+ COPY_4FV( ctx->Current.RasterTexCoords[texSet],
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
}
}
@@ -582,146 +591,160 @@ _mesa_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
}
+/* This is just to support the GL_MESA_window_pos version */
+static void
+window_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ window_pos3f(x, y, z);
+ ctx->Current.RasterPos[3] = w;
+}
void
_mesa_WindowPos2dMESA(GLdouble x, GLdouble y)
{
- _mesa_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+ window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
}
void
_mesa_WindowPos2fMESA(GLfloat x, GLfloat y)
{
- _mesa_WindowPos4fMESA(x, y, 0.0F, 1.0F);
+ window_pos4f(x, y, 0.0F, 1.0F);
}
void
_mesa_WindowPos2iMESA(GLint x, GLint y)
{
- _mesa_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+ window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
}
void
_mesa_WindowPos2sMESA(GLshort x, GLshort y)
{
- _mesa_WindowPos4fMESA(x, y, 0.0F, 1.0F);
+ window_pos4f(x, y, 0.0F, 1.0F);
}
void
_mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
{
- _mesa_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
}
void
_mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
{
- _mesa_WindowPos4fMESA(x, y, z, 1.0F);
+ window_pos4f(x, y, z, 1.0F);
}
void
_mesa_WindowPos3iMESA(GLint x, GLint y, GLint z)
{
- _mesa_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
}
void
_mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
{
- _mesa_WindowPos4fMESA(x, y, z, 1.0F);
+ window_pos4f(x, y, z, 1.0F);
}
void
_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
{
- _mesa_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+void
+_mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ window_pos4f(x, y, z, w);
}
void
_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
{
- _mesa_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
}
void
_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
{
- _mesa_WindowPos4fMESA(x, y, z, w);
+ window_pos4f(x, y, z, w);
}
void
_mesa_WindowPos2dvMESA(const GLdouble *v)
{
- _mesa_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
}
void
_mesa_WindowPos2fvMESA(const GLfloat *v)
{
- _mesa_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
+ window_pos4f(v[0], v[1], 0.0F, 1.0F);
}
void
_mesa_WindowPos2ivMESA(const GLint *v)
{
- _mesa_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
}
void
_mesa_WindowPos2svMESA(const GLshort *v)
{
- _mesa_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
+ window_pos4f(v[0], v[1], 0.0F, 1.0F);
}
void
_mesa_WindowPos3dvMESA(const GLdouble *v)
{
- _mesa_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
}
void
_mesa_WindowPos3fvMESA(const GLfloat *v)
{
- _mesa_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
+ window_pos4f(v[0], v[1], v[2], 1.0);
}
void
_mesa_WindowPos3ivMESA(const GLint *v)
{
- _mesa_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
}
void
_mesa_WindowPos3svMESA(const GLshort *v)
{
- _mesa_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
+ window_pos4f(v[0], v[1], v[2], 1.0F);
}
void
_mesa_WindowPos4dvMESA(const GLdouble *v)
{
- _mesa_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1],
(GLfloat) v[2], (GLfloat) v[3]);
}
void
_mesa_WindowPos4fvMESA(const GLfloat *v)
{
- _mesa_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
+ window_pos4f(v[0], v[1], v[2], v[3]);
}
void
_mesa_WindowPos4ivMESA(const GLint *v)
{
- _mesa_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1],
(GLfloat) v[2], (GLfloat) v[3]);
}
void
_mesa_WindowPos4svMESA(const GLshort *v)
{
- _mesa_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
+ window_pos4f(v[0], v[1], v[2], v[3]);
}