src/texture.c

changeset 135
062703d3f5cc
parent 126
77c13e14a65f
equal deleted inserted replaced
134:42dcc8134a68 135:062703d3f5cc
166 if (surface_dimension.width == 0 || surface_dimension.height == 0) { 166 if (surface_dimension.width == 0 || surface_dimension.height == 0) {
167 asc_wprintf("Tried to calculate UV scale for texture %u with zero dimensions.", tex->tex_id); 167 asc_wprintf("Tried to calculate UV scale for texture %u with zero dimensions.", tex->tex_id);
168 return factors; 168 return factors;
169 } 169 }
170 asc_vec2f uv_scale = factors; 170 asc_vec2f uv_scale = factors;
171 uv_scale.u *= (float) surface_dimension.width; 171 // non-normalized coordinates for rectangle textures
172 uv_scale.u /= (float) tex->width; 172 if (tex->target == GL_TEXTURE_RECTANGLE) {
173 uv_scale.v *= (float) surface_dimension.height; 173 uv_scale.x *= (float) tex->width;
174 uv_scale.v /= (float) tex->height; 174 uv_scale.y *= (float) tex->height;
175 }
176 // apply scaling
177 if (surface_dimension.width != tex->width) {
178 uv_scale.u *= (float) surface_dimension.width;
179 uv_scale.u /= (float) tex->width;
180 }
181 if (surface_dimension.height != tex->height) {
182 uv_scale.v *= (float) surface_dimension.height;
183 uv_scale.v /= (float) tex->height;
184 }
185
175 return uv_scale; 186 return uv_scale;
176 } 187 }

mercurial