/* XXX temporary until glext.h is updated! */
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_EXT_texture_mirror_clamp 1
+
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
+
+#endif /* GL_EXT_texture_mirror_clamp */
+
+
+
+/* XXX temporary until glext.h is updated! */
#ifndef GL_ARB_occlusion_query
#define GL_ARB_occlusion_query 1
-/* $Id: texwrap.c,v 1.6 2003/05/30 15:30:17 brianp Exp $ */
+/* $Id: texwrap.c,v 1.7 2003/09/02 19:25:18 idr Exp $ */
/*
* Test texture wrap modes.
#define GL_MIRRORED_REPEAT 0x8370
#endif
-#ifndef GL_ATI_texture_mirror_once
-#define GL_MIRROR_CLAMP_ATI 0x8742
-#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
#endif
#define BORDER_TEXTURE 1
WRAP_EXT ( GL_MIRRORED_REPEAT, "GL_ARB_texture_mirrored_repeat",
"GL_IBM_texture_mirrored_repeat",
1.4 ),
- WRAP_EXT ( GL_MIRROR_CLAMP_ATI, "GL_ATI_texture_mirror_once",
- NULL,
+ WRAP_EXT ( GL_MIRROR_CLAMP_EXT, "GL_ATI_texture_mirror_once",
+ "GL_EXT_texture_mirror_clamp",
999.0 ),
- WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_ATI, "GL_ATI_texture_mirror_once",
- NULL,
+ WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_EXT, "GL_ATI_texture_mirror_once",
+ "GL_EXT_texture_mirror_clamp",
+ 999.0 ),
+ WRAP_EXT ( GL_MIRROR_CLAMP_TO_BORDER_EXT, "GL_EXT_texture_mirror_clamp",
+ NULL,
999.0 ),
{ 0 }
};
{ OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
{ OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
{ OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
- { ON, "GL_EXT_texture_object", 0 },
{ OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
+ { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
+ { ON, "GL_EXT_texture_object", 0 },
{ OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
{ ON, "GL_EXT_vertex_array", 0 },
{ OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
ctx->Extensions.EXT_texture_env_add = GL_TRUE;
ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
+ ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
ctx->Extensions.HP_occlusion_test = GL_TRUE;
ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;
GLboolean EXT_texture_env_dot3;
GLboolean EXT_texture_filter_anisotropic;
GLboolean EXT_texture_lod_bias;
+ GLboolean EXT_texture_mirror_clamp;
GLboolean EXT_vertex_array_set;
GLboolean HP_occlusion_test;
GLboolean IBM_rasterpos_clip;
/* Texture Parameters */
/**********************************************************************/
+static GLboolean
+_mesa_validate_texture_wrap_mode(GLcontext * ctx,
+ GLenum target, GLenum eparam)
+{
+ const struct gl_extensions * const e = & ctx->Extensions;
+
+ if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
+ (eparam == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) {
+ /* any texture target */
+ return GL_TRUE;
+ }
+ else if (target != GL_TEXTURE_RECTANGLE_NV &&
+ (eparam == GL_REPEAT ||
+ (eparam == GL_MIRRORED_REPEAT &&
+ e->ARB_texture_mirrored_repeat) ||
+ (eparam == GL_MIRROR_CLAMP_EXT &&
+ (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) ||
+ (eparam == GL_MIRROR_CLAMP_TO_EDGE_EXT &&
+ (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) ||
+ (eparam == GL_MIRROR_CLAMP_TO_BORDER_EXT &&
+ (e->EXT_texture_mirror_clamp)))) {
+ /* non-rectangle texture */
+ return GL_TRUE;
+ }
+
+ _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return GL_FALSE;
+}
+
void
_mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param )
case GL_TEXTURE_WRAP_S:
if (texObj->WrapS == eparam)
return;
- if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
- (eparam == GL_CLAMP_TO_BORDER &&
- ctx->Extensions.ARB_texture_border_clamp)) {
- /* any texture target */
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->WrapS = eparam;
- }
- else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
- (eparam == GL_REPEAT ||
- (eparam == GL_MIRRORED_REPEAT &&
- ctx->Extensions.ARB_texture_mirrored_repeat) ||
- (eparam == GL_MIRROR_CLAMP_ATI &&
- ctx->Extensions.ATI_texture_mirror_once) ||
- (eparam == GL_MIRROR_CLAMP_TO_EDGE_ATI &&
- ctx->Extensions.ATI_texture_mirror_once))) {
- /* non-rectangle texture */
+ if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapS = eparam;
}
else {
- _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
return;
}
break;
case GL_TEXTURE_WRAP_T:
if (texObj->WrapT == eparam)
return;
- if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
- (eparam == GL_CLAMP_TO_BORDER &&
- ctx->Extensions.ARB_texture_border_clamp)) {
- /* any texture target */
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->WrapT = eparam;
- }
- else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
- (eparam == GL_REPEAT ||
- (eparam == GL_MIRRORED_REPEAT &&
- ctx->Extensions.ARB_texture_mirrored_repeat) ||
- (eparam == GL_MIRROR_CLAMP_ATI &&
- ctx->Extensions.ATI_texture_mirror_once) ||
- (eparam == GL_MIRROR_CLAMP_TO_EDGE_ATI &&
- ctx->Extensions.ATI_texture_mirror_once))) {
- /* non-rectangle texture */
+ if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapT = eparam;
}
else {
- _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
return;
}
break;
case GL_TEXTURE_WRAP_R:
if (texObj->WrapR == eparam)
return;
- if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
- (eparam == GL_CLAMP_TO_BORDER &&
- ctx->Extensions.ARB_texture_border_clamp)) {
- /* any texture target */
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->WrapR = eparam;
- }
- else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
- (eparam == GL_REPEAT ||
- (eparam == GL_MIRRORED_REPEAT &&
- ctx->Extensions.ARB_texture_mirrored_repeat) ||
- (eparam == GL_MIRROR_CLAMP_ATI &&
- ctx->Extensions.ATI_texture_mirror_once) ||
- (eparam == GL_MIRROR_CLAMP_TO_EDGE_ATI &&
- ctx->Extensions.ATI_texture_mirror_once))) {
- /* non-rectangle texture */
+ if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapR = eparam;
}
else {
- _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
}
break;
case GL_TEXTURE_BORDER_COLOR:
if (I1 >= (GLint) SIZE) \
I1 = SIZE - 1; \
} \
- else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \
+ else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \
U = (GLfloat) fabs(S); \
if (U >= 1.0F) \
U = (GLfloat) SIZE; \
I0 = IFLOOR(U); \
I1 = I0 + 1; \
} \
- else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) { \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_EXT) { \
U = (GLfloat) fabs(S); \
if (U >= 1.0F) \
U = (GLfloat) SIZE; \
if (I1 >= (GLint) SIZE) \
I1 = SIZE - 1; \
} \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_BORDER_EXT) { \
+ const GLfloat min = -1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ U = (GLfloat) fabs(S); \
+ if (U <= min) \
+ U = min * SIZE; \
+ else if (U >= max) \
+ U = max * SIZE; \
+ else \
+ U *= SIZE; \
+ U -= 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ } \
else { \
ASSERT(wrapMode == GL_CLAMP); \
if (S <= 0.0F) \
else \
I = IFLOOR(u * SIZE); \
} \
- else if (wrapMode == GL_MIRROR_CLAMP_ATI) { \
+ else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \
/* s limited to [0,1] */ \
/* i limited to [0,size-1] */ \
const GLfloat u = (GLfloat) fabs(S); \
else \
I = IFLOOR(u * SIZE); \
} \
- else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_ATI) { \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_EXT) { \
/* s limited to [min,max] */ \
/* i limited to [0, size-1] */ \
const GLfloat min = 1.0F / (2.0F * SIZE); \
else \
I = IFLOOR(u * SIZE); \
} \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_BORDER_EXT) { \
+ /* s limited to [min,max] */ \
+ /* i limited to [0, size-1] */ \
+ const GLfloat min = -1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ const GLfloat u = (GLfloat) fabs(S); \
+ if (u < min) \
+ I = -1; \
+ else if (u > max) \
+ I = SIZE; \
+ else \
+ I = IFLOOR(u * SIZE); \
+ } \
else { \
ASSERT(wrapMode == GL_CLAMP); \
/* s limited to [0,1] */ \