summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texparam.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2011-10-03 12:46:23 -0700
committerIan Romanick <[email protected]>2012-08-23 10:15:29 -0700
commitd53101a9f31e1cba553c80dbafd23c748dd58a1d (patch)
treed86f0a904e62dbc02f380ce711fa73b3a75e3b55 /src/mesa/main/texparam.c
parent2abf555496b8f5a7319542756508dd2f2e8ed07c (diff)
mesa: Refactor validate_texture_wrap_mode to use a switch-statement
This makes the next couple changes a little easier. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/mesa/main/texparam.c')
-rw-r--r--src/mesa/main/texparam.c77
1 files changed, 42 insertions, 35 deletions
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 41b9f97bf0f..a0c508caa3a 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -29,7 +29,7 @@
* glTexParameter-related functions
*/
-
+#include <stdbool.h>
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/context.h"
@@ -56,43 +56,50 @@ static GLboolean
validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap)
{
const struct gl_extensions * const e = & ctx->Extensions;
+ bool supported;
- if (target == GL_TEXTURE_RECTANGLE_NV) {
- if (wrap == GL_CLAMP || wrap == GL_CLAMP_TO_EDGE ||
- (wrap == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp))
- return GL_TRUE;
- }
- else if (target == GL_TEXTURE_EXTERNAL_OES) {
- if (wrap == GL_CLAMP_TO_EDGE)
- return GL_TRUE;
- }
- else {
- switch (wrap) {
- case GL_CLAMP:
- case GL_REPEAT:
- case GL_CLAMP_TO_EDGE:
- case GL_MIRRORED_REPEAT:
- return GL_TRUE;
- case GL_CLAMP_TO_BORDER:
- if (e->ARB_texture_border_clamp)
- return GL_TRUE;
- break;
- case GL_MIRROR_CLAMP_EXT:
- case GL_MIRROR_CLAMP_TO_EDGE_EXT:
- if (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)
- return GL_TRUE;
- break;
- case GL_MIRROR_CLAMP_TO_BORDER_EXT:
- if (e->EXT_texture_mirror_clamp)
- return GL_TRUE;
- break;
- default:
- break;
- }
+ switch (wrap) {
+ case GL_CLAMP:
+ supported = (target != GL_TEXTURE_EXTERNAL_OES);
+ break;
+
+ case GL_CLAMP_TO_EDGE:
+ supported = true;
+ break;
+
+ case GL_CLAMP_TO_BORDER:
+ supported = e->ARB_texture_border_clamp
+ && (target != GL_TEXTURE_EXTERNAL_OES);
+ break;
+
+ case GL_REPEAT:
+ case GL_MIRRORED_REPEAT:
+ supported = (target != GL_TEXTURE_RECTANGLE_NV)
+ && (target != GL_TEXTURE_EXTERNAL_OES);
+ break;
+
+ case GL_MIRROR_CLAMP_EXT:
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ supported = (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)
+ && (target != GL_TEXTURE_RECTANGLE_NV)
+ && (target != GL_TEXTURE_EXTERNAL_OES);
+ break;
+
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ supported = e->EXT_texture_mirror_clamp
+ && (target != GL_TEXTURE_RECTANGLE_NV)
+ && (target != GL_TEXTURE_EXTERNAL_OES);
+ break;
+
+ default:
+ supported = false;
+ break;
}
- _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap );
- return GL_FALSE;
+ if (!supported)
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap );
+
+ return supported;
}