src/texture.c

changeset 135
062703d3f5cc
parent 126
77c13e14a65f
--- a/src/texture.c	Sun Jun 01 14:33:58 2025 +0200
+++ b/src/texture.c	Sun Jun 01 14:53:59 2025 +0200
@@ -168,9 +168,20 @@
         return factors;
     }
     asc_vec2f uv_scale = factors;
-    uv_scale.u *= (float) surface_dimension.width;
-    uv_scale.u /= (float) tex->width;
-    uv_scale.v *= (float) surface_dimension.height;
-    uv_scale.v /= (float) tex->height;
+    // non-normalized coordinates for rectangle textures
+    if (tex->target == GL_TEXTURE_RECTANGLE) {
+        uv_scale.x *= (float) tex->width;
+        uv_scale.y *= (float) tex->height;
+    }
+    // apply scaling
+    if (surface_dimension.width != tex->width) {
+        uv_scale.u *= (float) surface_dimension.width;
+        uv_scale.u /= (float) tex->width;
+    }
+    if (surface_dimension.height != tex->height) {
+        uv_scale.v *= (float) surface_dimension.height;
+        uv_scale.v /= (float) tex->height;
+    }
+
     return uv_scale;
 }

mercurial