aboutsummaryrefslogtreecommitdiff
path: root/src/GPU3D_OpenGL43.cpp
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2019-04-29 18:24:36 +0200
committerArisotura <thetotalworm@gmail.com>2019-04-29 18:24:36 +0200
commite7be82430b183bbdc424dbb0858fa5ee4056a8de (patch)
treea2a5c72bead2ab307e5e10e3cb6f88fef3257ce1 /src/GPU3D_OpenGL43.cpp
parenteb9cfd12d4e85f224df8954cdeca79a20a604045 (diff)
texcoord wrap modes
Diffstat (limited to 'src/GPU3D_OpenGL43.cpp')
-rw-r--r--src/GPU3D_OpenGL43.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/GPU3D_OpenGL43.cpp b/src/GPU3D_OpenGL43.cpp
index 02c20b9..4292638 100644
--- a/src/GPU3D_OpenGL43.cpp
+++ b/src/GPU3D_OpenGL43.cpp
@@ -108,8 +108,35 @@ vec4 TextureLookup()
int vramaddr = int(attr & 0xFFFF) << 3;
ivec2 st = ivec2(fTexcoord);
- st.x &= (tw-1);
- st.y &= (th-1);
+ if ((attr & (1<<16)) != 0)
+ {
+ if ((attr & (1<<18)) != 0)
+ {
+ if ((st.x & tw) != 0)
+ st.x = (tw-1) - (st.x & (tw-1));
+ else
+ st.x = (st.x & (tw-1));
+ }
+ else
+ st.x &= (tw-1);
+ }
+ else
+ st.x = clamp(st.x, 0, tw-1);
+
+ if ((attr & (1<<17)) != 0)
+ {
+ if ((attr & (1<<19)) != 0)
+ {
+ if ((st.y & th) != 0)
+ st.y = (th-1) - (st.y & (th-1));
+ else
+ st.y = (st.y & (th-1));
+ }
+ else
+ st.y &= (th-1);
+ }
+ else
+ st.y = clamp(st.y, 0, th-1);
uint type = (attr >> 26) & 0x7;
if (type == 4)