initial code for GL_ARB_texture_cube_map
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 22 May 2000 16:33:20 +0000 (16:33 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 22 May 2000 16:33:20 +0000 (16:33 +0000)
src/mesa/main/context.c
src/mesa/main/enable.c
src/mesa/main/extensions.c
src/mesa/main/get.c
src/mesa/main/teximage.c
src/mesa/main/texstate.c

index 2954b455c9f281a46cd09667cc2cf6a5271e88ae..e106b0343ed764c49f6aed5da0ce500c5c59dd54 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.65 2000/05/18 18:12:36 brianp Exp $ */
+/* $Id: context.c,v 1.66 2000/05/22 16:33:20 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -704,6 +704,7 @@ init_attrib_groups( GLcontext *ctx )
    /* Constants, may be overriden by device drivers */
    ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
    ctx->Const.MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1);
+   ctx->Const.MaxCubeTextureSize = ctx->Const.MaxTextureSize;
    ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS;
    ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
    ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
index e49528e0ae3323b0c06399302ad81bbdba3d8341..b4df44de34fd3a273145ac2f2b8713635303e68f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.19 2000/05/07 20:41:30 brianp Exp $ */
+/* $Id: enable.c,v 1.20 2000/05/22 16:33:21 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -506,6 +506,26 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          ctx->Pixel.Separable2DEnabled = state;
          break;
 
+      /* GL_ARB_texture_cube_map */
+      case GL_TEXTURE_CUBE_MAP_ARB:
+#if 0
+         if (ctx->Visual->RGBAflag) {
+           const GLuint curr = ctx->Texture.CurrentUnit;
+           const GLuint flag = TEXTURE0_CUBE << (curr * 4);
+            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+           ctx->NewState |= NEW_TEXTURE_ENABLE;
+            if (state) {
+              texUnit->Enabled |= TEXTURE0_2D;
+              ctx->Enabled |= flag;
+           }
+            else {
+               texUnit->Enabled &= ~TEXTURE0_2D;
+               ctx->Enabled &= ~flag;
+            }
+         }
+        break;
+#endif
+
       default:
         if (state) {
            gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
@@ -738,6 +758,26 @@ _mesa_IsEnabled( GLenum cap )
       case GL_SEPARABLE_2D:
          return ctx->Pixel.Separable2DEnabled;
 
+      /* GL_ARB_texture_cube_map */
+      case GL_TEXTURE_CUBE_MAP_ARB:
+#if 0
+         if (ctx->Visual->RGBAflag) {
+           const GLuint curr = ctx->Texture.CurrentUnit;
+           const GLuint flag = TEXTURE0_CUBE << (curr * 4);
+            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+           ctx->NewState |= NEW_TEXTURE_ENABLE;
+            if (state) {
+              texUnit->Enabled |= TEXTURE0_2D;
+              ctx->Enabled |= flag;
+           }
+            else {
+               texUnit->Enabled &= ~TEXTURE0_2D;
+               ctx->Enabled &= ~flag;
+            }
+         }
+        break;
+#endif
+
       default:
         gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
         return GL_FALSE;
index 6c0837de138b8e620c5db9e2bf74a112a71b8360..e8f7456705add334ef15366aa3112841456eedbc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.25 2000/05/04 13:48:49 brianp Exp $ */
+/* $Id: extensions.c,v 1.26 2000/05/22 16:33:21 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -51,6 +51,7 @@ struct extension {
 static struct { int enabled; const char *name; } default_extensions[] = {
    { DEFAULT_OFF,    "GL_ARB_imaging" },
    { DEFAULT_ON,     "GL_ARB_multitexture" },
+   { DEFAULT_OFF,    "GL_ARB_texture_cube_map" },
    { ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" },
    { ALWAYS_ENABLED, "GL_EXT_abgr" },
    { DEFAULT_ON,     "GL_EXT_blend_color" },
@@ -97,6 +98,7 @@ update_extension_flags( GLcontext *ctx )
    ctx->Extensions.HaveTextureEnvAdd = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add");
    ctx->Extensions.HaveTextureLodBias = gl_extension_is_enabled(ctx, "GL_EXT_texture_lod_bias");
    ctx->Extensions.HaveHpOcclusionTest = gl_extension_is_enabled(ctx, "GL_HP_occlusion_test");
+   ctx->Extensions.HaveTextureCubeMap = gl_extension_is_enabled(ctx, "GL_ARB_texture_cube_map");
 }
 
 
index 6bf9669b6626db5f93eb5043723efebc7e922dde..e6e4a59717cd7a5e5091652730b01a29ead9aae5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.25 2000/05/07 23:18:54 brianp Exp $ */
+/* $Id: get.c,v 1.26 2000/05/22 16:33:21 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -782,13 +782,13 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
         *params = INT_TO_BOOL(ctx->Const.SubPixelBits);
         break;
       case GL_TEXTURE_1D:
-         *params = _mesa_IsEnabled(GL_TEXTURE_1D );
+         *params = _mesa_IsEnabled(GL_TEXTURE_1D);
         break;
       case GL_TEXTURE_2D:
-         *params = _mesa_IsEnabled(GL_TEXTURE_2D );
+         *params = _mesa_IsEnabled(GL_TEXTURE_2D);
         break;
       case GL_TEXTURE_3D:
-         *params = _mesa_IsEnabled(GL_TEXTURE_3D );
+         *params = _mesa_IsEnabled(GL_TEXTURE_3D);
         break;
       case GL_TEXTURE_BINDING_1D:
          *params = INT_TO_BOOL(textureUnit->CurrentD[1]->Name);
@@ -798,7 +798,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
           break;
       case GL_TEXTURE_BINDING_3D:
          *params = INT_TO_BOOL(textureUnit->CurrentD[3]->Name);
-          break;
+         break;
       case GL_TEXTURE_ENV_COLOR:
          {
             params[0] = FLOAT_TO_BOOL(textureUnit->EnvColor[0]);
@@ -943,6 +943,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          *params = INT_TO_BOOL(ctx->Array.EdgeFlag.Stride);
          break;
 
+      /* GL_ARB_multitexture */
       case GL_MAX_TEXTURE_UNITS_ARB:
          *params = ctx->Const.MaxTextureUnits;
          break;
@@ -953,6 +954,26 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          *params = INT_TO_BOOL(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture);
          break;
 
+      /* GL_ARB_texture_cube_map */
+      case GL_TEXTURE_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = INT_TO_BOOL(textureUnit->CurrentPosX->Name);
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = INT_TO_BOOL(ctx->Const.MaxCubeTextureSize);
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         break;
+
       /* GL_PGI_misc_hints */
       case GL_STRICT_DEPTHFUNC_HINT_PGI:
         *params = ENUM_TO_BOOL(GL_NICEST);
@@ -1013,7 +1034,14 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
 
       /* GL_ARB_transpose_matrix */
       case GL_TRANSPOSE_COLOR_MATRIX_ARB:
-         /* don't have a color matrix */
+         {
+            GLfloat tm[16];
+            GLuint i;
+            gl_matrix_transposef(tm, ctx->ColorMatrix.m);
+            for (i=0;i<16;i++) {
+               params[i] = FLOAT_TO_BOOL(tm[i]);
+            }
+         }
          break;
       case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
          {
@@ -2033,6 +2061,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
          *params = 0.0;
          break;
 
+      /* GL_ARB_multitexture */
       case GL_MAX_TEXTURE_UNITS_ARB:
          *params = (GLdouble) ctx->Const.MaxTextureUnits;
          break;
@@ -2043,6 +2072,25 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
          *params = (GLdouble) (GL_TEXTURE0_ARB + ctx->Array.ActiveTexture);
          break;
 
+      /* GL_ARB_texture_cube_map */
+      case GL_TEXTURE_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = (GLdouble) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = (GLdouble) textureUnit->CurrentPosX->Name;
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = (GLdouble) ctx->Const.MaxCubeTextureSize;
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
 
       /* GL_PGI_misc_hints */
       case GL_STRICT_DEPTHFUNC_HINT_PGI:
@@ -2104,7 +2152,14 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
 
       /* GL_ARB_transpose_matrix */
       case GL_TRANSPOSE_COLOR_MATRIX_ARB:
-         /* don't have a color matrix */
+         {
+            GLfloat tm[16];
+            GLuint i;
+            gl_matrix_transposef(tm, ctx->ColorMatrix.m);
+            for (i=0;i<16;i++) {
+               params[i] = (GLdouble) tm[i];
+            }
+         }
          break;
       case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
          {
@@ -3123,6 +3178,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          *params = 0.0;
          break;
 
+      /* GL_ARB_multitexture */
       case GL_MAX_TEXTURE_UNITS_ARB:
          *params = (GLfloat) ctx->Const.MaxTextureUnits;
          break;
@@ -3133,6 +3189,26 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          *params = (GLfloat) (GL_TEXTURE0_ARB + ctx->Array.ActiveTexture);
          break;
 
+      /* GL_ARB_texture_cube_map */
+      case GL_TEXTURE_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = (GLfloat) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = (GLfloat) textureUnit->CurrentPosX->Name;
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = (GLfloat) ctx->Const.MaxCubeTextureSize;
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+
       /* GL_PGI_misc_hints */
       case GL_STRICT_DEPTHFUNC_HINT_PGI:
         *params = ENUM_TO_FLOAT(GL_NICEST);
@@ -3193,7 +3269,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
 
       /* GL_ARB_transpose_matrix */
       case GL_TRANSPOSE_COLOR_MATRIX_ARB:
-         /* don't have a color matrix */
+         gl_matrix_transposef(params, ctx->ColorMatrix.m);
          break;
       case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
          gl_matrix_transposef(params, ctx->ModelView.m);
@@ -4193,6 +4269,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          *params = 0;
          break;
 
+      /* GL_ARB_multitexture */
       case GL_MAX_TEXTURE_UNITS_ARB:
          *params = ctx->Const.MaxTextureUnits;
          break;
@@ -4203,6 +4280,26 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          *params = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
          break;
 
+      /* GL_ARB_texture_cube_map */
+      case GL_TEXTURE_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = (GLint) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = textureUnit->CurrentPosX->Name;
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+      case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap)
+            *params = ctx->Const.MaxCubeTextureSize;
+         else
+            gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+         return;
+
       /* GL_PGI_misc_hints */
       case GL_STRICT_DEPTHFUNC_HINT_PGI:
         *params = (GL_NICEST);
@@ -4263,7 +4360,14 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
         
       /* GL_ARB_transpose_matrix */
       case GL_TRANSPOSE_COLOR_MATRIX_ARB:
-         /* don't have a color matrix */
+         {
+            GLfloat tm[16];
+            GLuint i;
+            gl_matrix_transposef(tm, ctx->ColorMatrix.m);
+            for (i=0;i<16;i++) {
+               params[i] = (GLint) tm[i];
+            }
+         }
          break;
       case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
          {
index ae50558bf26c0121a69b640b66132d380ce12729..2f3c0f12c80a97f91a89a2ba8aa03866f5a96bf1 100644 (file)
@@ -385,6 +385,38 @@ set_teximage_component_sizes( struct gl_texture_image *texImage )
 }
 
 
+/*
+ * 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:
+         return unit->CurrentPosX;
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+         return unit->CurrentNegX;
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+         return unit->CurrentPosY;
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+         return unit->CurrentNegY;
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+         return unit->CurrentPosZ;
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+         return unit->CurrentNegZ;
+      default:
+         gl_problem(NULL, "bad target in select_tex_object()");
+         return NULL;
+   }
+}
+
 
 /*
  * Return new gl_texture_image struct with all fields initialized to zero.
@@ -1189,7 +1221,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
       }
 
       texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-      texObj = texUnit->CurrentD[2];
+      texObj = select_tex_object(texUnit, target);
       texImage = texObj->Image[level];
 
       if (!texImage) {
@@ -1756,7 +1788,7 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
    }
 
    texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-   texObj = texUnit->CurrentD[2];
+   texObj = select_tex_object(texUnit, target);
    texImage = texObj->Image[level];
    assert(texImage);
 
index 2993be45220a8f73605eeb56847fd8b86835605d..7d57f3ec63667f12952312edfdc346e0ecdb610d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.9 2000/03/07 17:54:58 brianp Exp $ */
+/* $Id: texstate.c,v 1.10 2000/05/22 16:33:21 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -273,6 +273,12 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
       case GL_TEXTURE_3D_EXT:
          texObj = texUnit->CurrentD[3];
          break;
+      case GL_TEXTURE_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap) {
+            texObj = texUnit->CurrentPosX;
+            break;
+         }
+         /* fallthrough */
       default:
          gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
          return;
@@ -454,7 +460,17 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
       case GL_TEXTURE_3D:
          img = texUnit->CurrentD[3]->Image[level];
          dimensions = 3; 
-        break;
+         break;
+      case GL_TEXTURE_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap) {
+            img = texUnit->CurrentPosX->Image[level];
+            dimensions = 2;
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
+            return;
+         }
+         break;
       case GL_PROXY_TEXTURE_1D:
          img = ctx->Texture.Proxy1D->Image[level];
          dimensions = 1;
@@ -467,6 +483,16 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
          img = ctx->Texture.Proxy3D->Image[level];
          dimensions = 3;
          break;
+      case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+         if (ctx->Extensions.HaveTextureCubeMap) {
+            img = ctx->Texture.ProxyCubeMap->Image[level];
+            dimensions = 2;
+         }
+         else {
+            gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
+            return;
+         }
+         break;
       default:
         gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
          return;