summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-11 15:33:36 +0000
committerBrian Paul <[email protected]>2005-11-11 15:33:36 +0000
commit77ee31930a1b0cc7766939415f4f04ed6a1fa4ac (patch)
tree65a2b8fdc6bea5561ea7eb5c280bdce1ceef7d54
parent0325bc6359833fc51444618d7b1e188fca693eba (diff)
Make _mesa_is_proxy_texture() non-static and use in a few more places.
Use COPY_4FV() where possible. Added some comments, clean-ups.
-rw-r--r--src/mesa/main/dlist.c9
-rw-r--r--src/mesa/main/teximage.c20
-rw-r--r--src/mesa/main/teximage.h7
-rw-r--r--src/mesa/main/texstate.c85
4 files changed, 39 insertions, 82 deletions
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 7bd11c31af5..0ce0e095a9b 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 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"),
@@ -1323,10 +1323,7 @@ static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
const GLvoid *table )
{
GET_CURRENT_CONTEXT(ctx);
- if (target == GL_PROXY_TEXTURE_1D ||
- target == GL_PROXY_TEXTURE_2D ||
- target == GL_PROXY_TEXTURE_3D ||
- target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ if (_mesa_is_proxy_texture(target)) {
/* execute immediately */
CALL_ColorTable(ctx->Exec, ( target, internalFormat, width,
format, type, table ));
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 91fee9001ff..419df0f090e 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.5
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 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"),
@@ -25,13 +25,7 @@
/**
* \file teximage.c
- * Texture images manipulation functions.
- *
- * \note Mesa's native texture data type is GLchan. Native formats are
- * GL_ALPHA, GL_LUMINANCE, GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, GL_RGBA, and
- * GL_COLOR_INDEX.
- *
- * \note Device drivers are free to implement any internal format they want.
+ * Texture image-related functions.
*/
@@ -667,8 +661,8 @@ _mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *texImage )
*
* \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise.
*/
-static GLboolean
-is_proxy_target(GLenum target)
+GLboolean
+_mesa_is_proxy_texture(GLenum target)
{
return (target == GL_PROXY_TEXTURE_1D ||
target == GL_PROXY_TEXTURE_2D ||
@@ -1259,7 +1253,7 @@ texture_error_check( GLcontext *ctx, GLenum target,
GLint width, GLint height,
GLint depth, GLint border )
{
- const GLboolean isProxy = is_proxy_target(target);
+ const GLboolean isProxy = _mesa_is_proxy_texture(target);
GLboolean sizeOK;
GLboolean colorFormat, indexFormat;
@@ -2019,7 +2013,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
texUnit = &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]);
texObj = _mesa_select_tex_object(ctx, texUnit, target);
- if (!texObj || is_proxy_target(target)) {
+ if (!texObj || _mesa_is_proxy_texture(target)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)");
return;
}
@@ -3343,7 +3337,7 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img)
return;
}
- if (is_proxy_target(target)) {
+ if (_mesa_is_proxy_texture(target)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)");
return;
}
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 45c851e5c88..410789fe046 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -5,7 +5,7 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
@@ -49,6 +49,10 @@ extern GLint
_mesa_base_tex_format( GLcontext *ctx, GLint internalFormat );
+extern GLboolean
+_mesa_is_proxy_texture(GLenum target);
+
+
extern struct gl_texture_image *
_mesa_new_texture_image( GLcontext *ctx );
@@ -56,7 +60,6 @@ _mesa_new_texture_image( GLcontext *ctx );
extern void
_mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *teximage );
-
extern void
_mesa_free_texture_image_data( GLcontext *ctx,
struct gl_texture_image *texImage );
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 7f6015f0aef..043ca3bac38 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -43,15 +43,9 @@
-#ifdef SPECIALCAST
-/* Needed for an Amiga compiler */
#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
-#else
-/* all other compilers */
-#define ENUM_TO_FLOAT(X) ((GLfloat)(X))
-#define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
-#endif
+
/**
* Default texture combine environment state. This is used to initialize
@@ -1653,32 +1647,10 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
return;
}
- switch (target) {
- case GL_TEXTURE_1D:
- case GL_PROXY_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_PROXY_TEXTURE_2D:
- maxLevels = ctx->Const.MaxTextureLevels;
- break;
- case GL_TEXTURE_3D:
- case GL_PROXY_TEXTURE_3D:
- maxLevels = ctx->Const.Max3DTextureLevels;
- break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- case GL_PROXY_TEXTURE_CUBE_MAP:
- maxLevels = ctx->Const.MaxCubeTextureLevels;
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- case GL_PROXY_TEXTURE_RECTANGLE_NV:
- maxLevels = 1;
- break;
- default:
- _mesa_problem(ctx, "switch in _mesa_GetTexLevelParameter");
+ maxLevels = _mesa_max_texture_levels(ctx, target);
+ if (maxLevels == 0) {
+ /* should not happen since <target> was just checked above */
+ _mesa_problem(ctx, "maxLevels=0 in _mesa_GetTexLevelParameter");
return;
}
@@ -1697,11 +1669,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
return;
}
- isProxy = (target == GL_PROXY_TEXTURE_1D) ||
- (target == GL_PROXY_TEXTURE_2D) ||
- (target == GL_PROXY_TEXTURE_3D) ||
- (target == GL_PROXY_TEXTURE_CUBE_MAP) ||
- (target == GL_PROXY_TEXTURE_RECTANGLE_NV);
+ isProxy = _mesa_is_proxy_texture(target);
switch (pname) {
case GL_TEXTURE_WIDTH:
@@ -2194,14 +2162,10 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
if (TEST_EQ_4V(texUnit->ObjectPlaneS, params))
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->ObjectPlaneS[0] = params[0];
- texUnit->ObjectPlaneS[1] = params[1];
- texUnit->ObjectPlaneS[2] = params[2];
- texUnit->ObjectPlaneS[3] = params[3];
+ COPY_4FV(texUnit->ObjectPlaneS, params);
}
else if (pname==GL_EYE_PLANE) {
GLfloat tmp[4];
-
/* Transform plane equation by the inverse modelview matrix */
if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
_math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
@@ -2251,10 +2215,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
if (TEST_EQ_4V(texUnit->ObjectPlaneT, params))
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->ObjectPlaneT[0] = params[0];
- texUnit->ObjectPlaneT[1] = params[1];
- texUnit->ObjectPlaneT[2] = params[2];
- texUnit->ObjectPlaneT[3] = params[3];
+ COPY_4FV(texUnit->ObjectPlaneT, params);
}
else if (pname==GL_EYE_PLANE) {
GLfloat tmp[4];
@@ -2304,10 +2265,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
if (TEST_EQ_4V(texUnit->ObjectPlaneR, params))
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->ObjectPlaneR[0] = params[0];
- texUnit->ObjectPlaneR[1] = params[1];
- texUnit->ObjectPlaneR[2] = params[2];
- texUnit->ObjectPlaneR[3] = params[3];
+ COPY_4FV(texUnit->ObjectPlaneR, params);
}
else if (pname==GL_EYE_PLANE) {
GLfloat tmp[4];
@@ -2351,10 +2309,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
if (TEST_EQ_4V(texUnit->ObjectPlaneQ, params))
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->ObjectPlaneQ[0] = params[0];
- texUnit->ObjectPlaneQ[1] = params[1];
- texUnit->ObjectPlaneQ[2] = params[2];
- texUnit->ObjectPlaneQ[3] = params[3];
+ COPY_4FV(texUnit->ObjectPlaneQ, params);
}
else if (pname==GL_EYE_PLANE) {
GLfloat tmp[4];
@@ -2915,8 +2870,6 @@ update_texture_matrices( GLcontext *ctx )
}
-
-
/**
* \note This routine refers to derived texture matrix values to
* compute the ENABLE_TEXMAT flags, but is only called on
@@ -3133,6 +3086,7 @@ void _mesa_update_texture( GLcontext *ctx, GLuint new_state )
update_texture_state( ctx );
}
+
/**********************************************************************/
/***** Initialization *****/
/**********************************************************************/
@@ -3233,9 +3187,13 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
}
-GLboolean _mesa_init_texture( GLcontext * ctx )
+/**
+ * Initialize texture state for the given context.
+ */
+GLboolean
+_mesa_init_texture(GLcontext *ctx)
{
- int i;
+ GLuint i;
assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
@@ -3262,9 +3220,14 @@ GLboolean _mesa_init_texture( GLcontext * ctx )
return GL_TRUE;
}
-void _mesa_free_texture_data( GLcontext *ctx )
+
+/**
+ * Free dynamically-allocted texture data attached to the given context.
+ */
+void
+_mesa_free_texture_data(GLcontext *ctx)
{
- int i;
+ GLuint i;
/* Free proxy texture objects */
(ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D );