Use normalized texture coordinates

This commit is contained in:
Sylvain
2021-03-17 09:58:49 +01:00
committed by Sylvain Becker
parent 5828cc415a
commit f73c1eff10
7 changed files with 13 additions and 19 deletions

View File

@@ -1381,12 +1381,8 @@ static int
METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
SDL_Vertex *vertices, int num_vertices, int *indices, int num_indices, float scale_x, float scale_y)
{
const float texw = (float) (texture ? texture->w : 0);
const float texh = (float) (texture ? texture->h : 0);
int count = indices ? num_indices : num_vertices;
int i;
int sz = 2 + 4 + (texture ? 2 : 0);
const size_t vertlen = sizeof (float) * sz * count;
float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first);
if (!verts) {
@@ -1395,7 +1391,7 @@ METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
cmd->data.draw.count = count;
for (i = 0; i < count; i++) {
for (int i = 0; i < count; i++) {
SDL_Vertex *v = &vertices[indices ? indices[i] : i];
*(verts++) = v->position.x * scale_x;
@@ -1407,8 +1403,8 @@ METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
*(verts++) = v->color.a * inv255f;
if (texture) {
*(verts++) = normtex(v->tex_coord.x, texw);
*(verts++) = normtex(v->tex_coord.y, texh);
*(verts++) = v->tex_coord.x;
*(verts++) = v->tex_coord.y;
}
}