From 708566af7214e15bfbfce9515ffd3f063c6bea34 Mon Sep 17 00:00:00 2001 From: jnmartin84 Date: Sat, 12 Jul 2025 12:07:04 -0400 Subject: [PATCH] initial support for GL_MIRRORED_REPEAT --- GL/private.h | 4 +++- GL/state.c | 2 +- GL/texture.c | 12 ++++++++++++ include/GL/gl.h | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/GL/private.h b/GL/private.h index b890b05..5ba1834 100644 --- a/GL/private.h +++ b/GL/private.h @@ -153,7 +153,9 @@ typedef struct { //50 GLenum internalFormat; //54 - GLubyte padding[10]; // Pad to 64-bytes + GLubyte uv_flip; + // 55 + GLubyte padding[9]; // Pad to 64-bytes } __attribute__((aligned(32))) TextureObject; typedef struct { diff --git a/GL/state.c b/GL/state.c index 88aaad0..4d70b38 100644 --- a/GL/state.c +++ b/GL/state.c @@ -390,7 +390,7 @@ void _glUpdatePVRTextureContext(PolyContext *context, GLshort textureUnit) { } context->txr.env = tx1->env; - context->txr.uv_flip = GPU_UVFLIP_NONE; + context->txr.uv_flip = tx1->uv_flip; context->txr.uv_clamp = tx1->uv_clamp; } } diff --git a/GL/texture.c b/GL/texture.c index 2f34ab7..f6cbc35 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -17,6 +17,9 @@ #define CLAMP_U (1<<1) #define CLAMP_V (1<<0) +#define MIRROR_U (1<<1) +#define MIRROR_V (1<<0) + static TextureObject* TEXTURE_UNITS[MAX_GLDC_TEXTURE_UNITS] = {NULL, NULL}; static NamedArray TEXTURE_OBJECTS; GLubyte ACTIVE_TEXTURE = 0; @@ -505,6 +508,7 @@ static void _glInitializeTextureObject(TextureObject* txr, unsigned int id) { txr->width = txr->height = 0; txr->mipmap = 0; txr->uv_clamp = 0; + txr->uv_flip = 0; txr->env = GPU_TXRENV_MODULATEALPHA; txr->data = NULL; txr->mipmapCount = 0; @@ -1899,6 +1903,10 @@ void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) { case GL_REPEAT: active->uv_clamp &= ~CLAMP_U; break; + + case GL_MIRRORED_REPEAT: + active->uv_flip |= MIRROR_U; + break; } break; @@ -1913,6 +1921,10 @@ void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) { case GL_REPEAT: active->uv_clamp &= ~CLAMP_V; break; + + case GL_MIRRORED_REPEAT: + active->uv_flip |= MIRROR_V; + break; } break; diff --git a/include/GL/gl.h b/include/GL/gl.h index f6c7f4a..e67a88d 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -116,6 +116,7 @@ __BEGIN_DECLS #define GL_TEXTURE_WRAP_T 0x2803 #define GL_TEXTURE_MAG_FILTER 0x2800 #define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_MIRRORED_REPEAT 0x2902 #define GL_REPEAT 0x2901 #define GL_CLAMP 0x2900