added GL_ARB_texture_mirrored_repeat
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 17 Oct 2001 13:31:07 +0000 (13:31 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 17 Oct 2001 13:31:07 +0000 (13:31 +0000)
src/mesa/main/extensions.c
src/mesa/main/glheader.h
src/mesa/main/mtypes.h
src/mesa/main/texstate.c
src/mesa/swrast/s_texture.c

index 7e96b9e1b5ea15dac23967d734f23bcba7474f33..8b7de99fd91645a68599e3549a89d5affe08d44b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.64 2001/08/13 18:09:34 brianp Exp $ */
+/* $Id: extensions.c,v 1.65 2001/10/17 13:31:07 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -65,6 +65,7 @@ static struct {
    { OFF, "GL_ARB_texture_env_add",            F(EXT_texture_env_add) },
    { OFF, "GL_ARB_texture_env_combine",        F(ARB_texture_env_combine) },
    { OFF, "GL_ARB_texture_env_dot3",           F(ARB_texture_env_dot3) },
+   { OFF, "GL_ARB_texture_mirrored_repeat",    F(ARB_texture_mirrored_repeat)},
    { ON,  "GL_ARB_transpose_matrix",           0 },
    { ON,  "GL_EXT_abgr",                       0 },
    { ON,  "GL_EXT_bgra",                       0 },
@@ -138,6 +139,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
       "GL_ARB_texture_env_add",
       "GL_ARB_texture_env_combine",
       "GL_ARB_texture_env_dot3",
+      "GL_ARB_texture_mirrored_repeat",
       "GL_EXT_blend_color",
       "GL_EXT_blend_func_separate",
       "GL_EXT_blend_logic_op",
index 41c474204098f3dc84e7f215046e32af769f1a6a..ed3f76ba6b4ad76282faf13895a5873a05141955 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: glheader.h,v 1.22 2001/07/16 15:54:23 brianp Exp $ */
+/* $Id: glheader.h,v 1.23 2001/10/17 13:31:07 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -260,4 +260,12 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
 typedef union { GLfloat f; GLint i; } fi_type;
 
 
+#ifndef GL_MIRRORED_REPEAT_ARB
+#define GL_MIRRORED_REPEAT_ARB  0x8370
+#endif
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
+#endif
+
+
 #endif /* GLHEADER_H */
index 9325934a070de33fb7b76df12ae1e79c477f6906..c670e574132f83cd5bf0b2febfab62fb478b55a5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.50 2001/07/28 19:28:49 keithw Exp $ */
+/* $Id: mtypes.h,v 1.51 2001/10/17 13:31:07 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -1202,6 +1202,7 @@ struct gl_extensions {
    GLboolean ARB_texture_cube_map;
    GLboolean ARB_texture_env_combine;
    GLboolean ARB_texture_env_dot3;
+   GLboolean ARB_texture_mirrored_repeat;
    GLboolean EXT_blend_color;
    GLboolean EXT_blend_func_separate;
    GLboolean EXT_blend_logic_op;
index 0205d30fdd915d5629cf2717da2e51c67f8a65a3..f2f021160664b5fe50989c21a49fbef4421d333f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.57 2001/09/18 23:06:14 kschultz Exp $ */
+/* $Id: texstate.c,v 1.58 2001/10/17 13:31:07 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -140,16 +140,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
                   return;
                }
                break;
-           case GL_DOT3_RGB_EXT:
-           case GL_DOT3_RGBA_EXT:
-              if (!ctx->Extensions.EXT_texture_env_dot3) {
-                  TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
-                 return;
-              }
-              break;
            case GL_DOT3_RGB_ARB:
            case GL_DOT3_RGBA_ARB:
-              if (!ctx->Extensions.ARB_texture_env_dot3) {
+              if (!ctx->Extensions.EXT_texture_env_dot3 &&
+                   !ctx->Extensions.ARB_texture_env_dot3) {
                   TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
                  return;
               }
@@ -929,7 +923,9 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
              eparam==GL_REPEAT ||
              eparam==GL_CLAMP_TO_EDGE ||
              (eparam == GL_CLAMP_TO_BORDER_ARB &&
-              ctx->Extensions.ARB_texture_border_clamp)) {
+              ctx->Extensions.ARB_texture_border_clamp) ||
+             (eparam == GL_MIRRORED_REPEAT_ARB &&
+              ctx->Extensions.ARB_texture_mirrored_repeat)) {
             texObj->WrapS = eparam;
          }
          else {
@@ -944,7 +940,9 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
              eparam==GL_REPEAT ||
              eparam==GL_CLAMP_TO_EDGE ||
              (eparam == GL_CLAMP_TO_BORDER_ARB &&
-              ctx->Extensions.ARB_texture_border_clamp)) {
+              ctx->Extensions.ARB_texture_border_clamp) ||
+             (eparam == GL_MIRRORED_REPEAT_ARB &&
+              ctx->Extensions.ARB_texture_mirrored_repeat)) {
             texObj->WrapT = eparam;
          }
          else {
@@ -959,7 +957,9 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
              eparam==GL_REPEAT ||
              eparam==GL_CLAMP_TO_EDGE ||
              (eparam == GL_CLAMP_TO_BORDER_ARB &&
-              ctx->Extensions.ARB_texture_border_clamp)) {
+              ctx->Extensions.ARB_texture_border_clamp) ||
+             (eparam == GL_MIRRORED_REPEAT_ARB &&
+              ctx->Extensions.ARB_texture_mirrored_repeat)) {
             texObj->WrapR = eparam;
          }
          else {
index 39d9a9c6129b8eb53f5f7ec4a3e18b6c20e7afa9..fcbbe73a7a4e8cdd5d2c8be319013e8e7674a99b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.39 2001/09/19 20:30:44 kschultz Exp $ */
+/* $Id: s_texture.c,v 1.40 2001/10/17 13:31:07 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
       I0 = IFLOOR(U);                                                  \
       I1 = I0 + 1;                                                     \
    }                                                                   \
+   else if (wrapMode == GL_MIRRORED_REPEAT_ARB) {                      \
+      const GLint flr = IFLOOR(S);                                     \
+      if (flr & 1)                                                     \
+         U = 1.0 - (S - (GLfloat) flr);        /* flr is odd */                \
+      else                                                             \
+         U = S - (GLfloat) flr;                /* flr is even */               \
+      I0 = IFLOOR(U);                                                  \
+      I1 = I0 + 1;                                                     \
+      if (I0 < 0)                                                      \
+         I0 = 0;                                                       \
+      if (I1 >= (GLint) SIZE)                                          \
+         I1 = SIZE - 1;                                                        \
+   }                                                                   \
    else {                                                              \
       ASSERT(wrapMode == GL_CLAMP);                                    \
       if (S <= 0.0F)                                                   \
       else                                                             \
          I = IFLOOR(S * SIZE);                                         \
    }                                                                   \
+   else if (wrapMode == GL_MIRRORED_REPEAT_ARB) {                      \
+      const GLfloat min = 1.0F / (2.0F * SIZE);                                \
+      const GLfloat max = 1.0F - min;                                  \
+      const GLint flr = IFLOOR(S);                                     \
+      GLfloat u;                                                       \
+      if (flr & 1)                                                     \
+         u = 1.0 - (S - (GLfloat) flr);        /* flr is odd */                \
+      else                                                             \
+         u = S - (GLfloat) flr;                /* flr is even */               \
+      if (u < min)                                                     \
+         I = 0;                                                                \
+      else if (u > max)                                                        \
+         I = SIZE - 1;                                                 \
+      else                                                             \
+         I = IFLOOR(u * SIZE);                                         \
+   }                                                                   \
    else {                                                              \
       ASSERT(wrapMode == GL_CLAMP);                                    \
       /* s limited to [0,1] */                                         \
@@ -2133,8 +2162,6 @@ texture_combine(const GLcontext *ctx,
             }
          }
          break;
-      case GL_DOT3_RGB_EXT:
-      case GL_DOT3_RGBA_EXT:
       case GL_DOT3_RGB_ARB:
       case GL_DOT3_RGBA_ARB:
          {