more texture cube work, misc code clean-up
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 8302b34..a7d3d56 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.27 2000/05/23 15:17:13 brianp Exp $ */
+/* $Id: get.c,v 1.28 2000/05/23 17:14:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -4309,10 +4309,10 @@
 	 break;
       case GL_STRICT_SCISSOR_HINT_PGI:
       case GL_FULL_STIPPLE_HINT_PGI:
-	 *params = (GL_TRUE);
+	 *params = GL_TRUE;
 	 break;
       case GL_CONSERVE_MEMORY_HINT_PGI:
-	 *params = (GL_FALSE);
+	 *params = GL_FALSE;
 	 break;
       case GL_ALWAYS_FAST_HINT_PGI:
 	 *params = (ctx->Hint.AllowDrawWin == GL_TRUE &&
@@ -4344,7 +4344,7 @@
 	 *params = GL_DONT_CARE;
 	 break;
       case GL_BACK_NORMALS_HINT_PGI:
-	 *params = (GL_TRUE);
+	 *params = GL_TRUE;
 	 break;
       case GL_NATIVE_GRAPHICS_HANDLE_PGI:
 	 *params = 0;
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 74be554..d3d8bd7 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -385,34 +385,6 @@
 }
 
 
-/*
- * Given a texture unit and a texture target, return the corresponding
- * texture object.
- */
-static struct gl_texture_object *
-select_tex_object(struct gl_texture_unit *unit, GLenum target)
-{
-   switch (target) {
-      case GL_TEXTURE_1D:
-         return unit->CurrentD[1];
-      case GL_TEXTURE_2D:
-         return unit->CurrentD[2];
-      case GL_TEXTURE_3D:
-         return unit->CurrentD[3];
-      case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
-      case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
-      case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
-      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
-      case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
-      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
-         return unit->CurrentCubeMap;
-      default:
-         gl_problem(NULL, "bad target in select_tex_object()");
-         return NULL;
-   }
-}
-
-
 static void
 set_tex_image(struct gl_texture_object *tObj,
               GLenum target, GLint level,
@@ -507,6 +479,45 @@
 
 
 /*
+ * Given a texture unit and a texture target, return the corresponding
+ * texture object.
+ */
+struct gl_texture_object *
+_mesa_select_tex_object(GLcontext *ctx, struct gl_texture_unit *texUnit,
+                        GLenum target)
+{
+   switch (target) {
+      case GL_TEXTURE_1D:
+         return texUnit->CurrentD[1];
+      case GL_PROXY_TEXTURE_1D:
+         return ctx->Texture.Proxy1D;
+      case GL_TEXTURE_2D:
+         return texUnit->CurrentD[2];
+      case GL_PROXY_TEXTURE_2D:
+         return ctx->Texture.Proxy2D;
+      case GL_TEXTURE_3D:
+         return texUnit->CurrentD[3];
+      case GL_PROXY_TEXTURE_3D:
+         return ctx->Texture.Proxy3D;
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+         return ctx->Extensions.HaveTextureCubeMap
+                ? texUnit->CurrentCubeMap : NULL;
+      case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+         return ctx->Extensions.HaveTextureCubeMap
+                ? ctx->Texture.ProxyCubeMap : NULL;
+      default:
+         gl_problem(NULL, "bad target in _mesa_select_tex_object()");
+         return NULL;
+   }
+}
+
+
+/*
  * Return the texture image struct which corresponds to target and level
  * for the given texture unit.
  */
@@ -1349,7 +1360,7 @@
       }
 
       texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-      texObj = select_tex_object(texUnit, target);
+      texObj = _mesa_select_tex_object(ctx, texUnit, target);
       texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
 
       if (!texImage) {
@@ -1917,7 +1928,7 @@
    }
 
    texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-   texObj = select_tex_object(texUnit, target);
+   texObj = _mesa_select_tex_object(ctx, texUnit, target);
    texImage = texObj->Image[level];
    assert(texImage);
 
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 51e4720..433bdc3 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -1,4 +1,4 @@
-/* $Id: teximage.h,v 1.7 2000/05/23 15:17:13 brianp Exp $ */
+/* $Id: teximage.h,v 1.8 2000/05/23 17:14:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -47,6 +47,11 @@
 _mesa_free_texture_image( struct gl_texture_image *teximage );
 
 
+extern struct gl_texture_object *
+_mesa_select_tex_object(GLcontext *ctx, struct gl_texture_unit *texUnit,
+                        GLenum target);
+
+
 extern struct gl_texture_image *
 _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
                        GLenum target, GLint level);
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index cdd9aa4..81833a3 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -159,7 +159,9 @@
  * Examine a texture object to determine if it is complete or not.
  * The t->Complete flag will be set to GL_TRUE or GL_FALSE accordingly.
  */
-void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_texture_object *t )
+void
+_mesa_test_texobj_completeness( const GLcontext *ctx,
+                                struct gl_texture_object *t )
 {
    t->Complete = GL_TRUE;  /* be optimistic */
 
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index a4bf396..52bf621 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -1,4 +1,4 @@
-/* $Id: texobj.h,v 1.2 1999/11/11 01:22:28 brianp Exp $ */
+/* $Id: texobj.h,v 1.3 2000/05/23 17:14:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -32,9 +32,6 @@
 #include "types.h"
 
 
-#ifdef VMS
-#define gl_test_texture_object_completeness gl_test_texture_object_complete
-#endif
 
 /*
  * Internal functions
@@ -49,7 +46,9 @@
                                     struct gl_texture_object *t );
 
 
-extern void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_texture_object *t );
+extern void
+_mesa_test_texobj_completeness( const GLcontext *ctx,
+                                struct gl_texture_object *t );
 
 
 /*
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 4fe440e..0e55fc9 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.11 2000/05/23 15:17:13 brianp Exp $ */
+/* $Id: texstate.c,v 1.12 2000/05/23 17:14:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -472,13 +472,12 @@
    }
 
    dimensions = tex_image_dimensions(ctx, target);  /* 1, 2 or 3 */
-   img = _mesa_select_tex_image(ctx, texUnit, target, level);
-
    if (dimensions == 0) {
       gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
       return;
    }
 
+   img = _mesa_select_tex_image(ctx, texUnit, target, level);
    if (!img) {
       if (pname == GL_TEXTURE_COMPONENTS)
          *params = 1;
@@ -553,19 +552,10 @@
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexParameterfv");
 
-   switch (target) {
-      case GL_TEXTURE_1D:
-         obj = texUnit->CurrentD[1];
-         break;
-      case GL_TEXTURE_2D:
-         obj = texUnit->CurrentD[2];
-         break;
-      case GL_TEXTURE_3D_EXT:
-         obj = texUnit->CurrentD[3];
-         break;
-      default:
-         gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
-         return;
+   obj = _mesa_select_tex_object(ctx, texUnit, target);
+   if (!obj) {
+      gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
+      return;
    }
 
    switch (pname) {
@@ -623,19 +613,10 @@
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexParameteriv");
 
-   switch (target) {
-      case GL_TEXTURE_1D:
-         obj = texUnit->CurrentD[1];
-         break;
-      case GL_TEXTURE_2D:
-         obj = texUnit->CurrentD[2];
-         break;
-      case GL_TEXTURE_3D_EXT:
-         obj = texUnit->CurrentD[3];
-         break;
-      default:
-         gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)");
-         return;
+   obj = _mesa_select_tex_object(ctx, texUnit, target);
+   if (!obj) {
+      gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)");
+      return;
    }
 
    switch (pname) {
@@ -764,30 +745,30 @@
       case GL_T:
          if (pname==GL_TEXTURE_GEN_MODE) {
 	    GLenum mode = (GLenum) (GLint) *params;
-	    switch(mode) {
-	    case GL_OBJECT_LINEAR:
-	       texUnit->GenModeT = GL_OBJECT_LINEAR;
-	       texUnit->GenBitT = TEXGEN_OBJ_LINEAR;
-	       break;
-	    case GL_EYE_LINEAR:
-	       texUnit->GenModeT = GL_EYE_LINEAR;
-	       texUnit->GenBitT = TEXGEN_EYE_LINEAR;
-	       break;
-	    case GL_REFLECTION_MAP_NV:
-	       texUnit->GenModeT = GL_REFLECTION_MAP_NV;
-	       texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV;
-	       break;
-	    case GL_NORMAL_MAP_NV:
-	       texUnit->GenModeT = GL_NORMAL_MAP_NV;
-	       texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV;
-	       break;
-	    case GL_SPHERE_MAP:
-	       texUnit->GenModeT = GL_SPHERE_MAP;
-	       texUnit->GenBitT = TEXGEN_SPHERE_MAP;
-	       break;
-	    default:
-	       gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
-	       return;
+	    switch (mode) {
+               case GL_OBJECT_LINEAR:
+                  texUnit->GenModeT = GL_OBJECT_LINEAR;
+                  texUnit->GenBitT = TEXGEN_OBJ_LINEAR;
+                  break;
+               case GL_EYE_LINEAR:
+                  texUnit->GenModeT = GL_EYE_LINEAR;
+                  texUnit->GenBitT = TEXGEN_EYE_LINEAR;
+                  break;
+               case GL_REFLECTION_MAP_NV:
+                  texUnit->GenModeT = GL_REFLECTION_MAP_NV;
+                  texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV;
+                  break;
+               case GL_NORMAL_MAP_NV:
+                  texUnit->GenModeT = GL_NORMAL_MAP_NV;
+                  texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV;
+                  break;
+               case GL_SPHERE_MAP:
+                  texUnit->GenModeT = GL_SPHERE_MAP;
+                  texUnit->GenBitT = TEXGEN_SPHERE_MAP;
+                  break;
+               default:
+                  gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
+                  return;
 	    }
 	 }
 	 else if (pname==GL_OBJECT_PLANE) {
@@ -954,7 +935,7 @@
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGendv");
 
-   switch( coord ) {
+   switch (coord) {
       case GL_S:
          if (pname==GL_TEXTURE_GEN_MODE) {
             params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS);
@@ -1032,7 +1013,7 @@
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGenfv");
 
-   switch( coord ) {
+   switch (coord) {
       case GL_S:
          if (pname==GL_TEXTURE_GEN_MODE) {
             params[0] = ENUM_TO_FLOAT(texUnit->GenModeS);
@@ -1110,7 +1091,7 @@
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGeniv");
 
-   switch( coord ) {
+   switch (coord) {
       case GL_S:
          if (pname==GL_TEXTURE_GEN_MODE) {
             params[0] = texUnit->GenModeS;
@@ -1316,8 +1297,8 @@
    struct gl_texture_object *t, *next;
    for (t = ctx->Shared->DirtyTexObjList; t; t = next) {
       next = t->NextDirty;
-      gl_test_texture_object_completeness(ctx, t);
-      gl_set_texture_sampler(t);
+      _mesa_test_texobj_completeness(ctx, t);
+      _mesa_set_texture_sampler(t);
       t->NextDirty = NULL;
       t->Dirty = GL_FALSE;
    }