mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
direct3d11: Fixed incorrect texture coordinates (thanks, Martin!).
Fixes Bugzilla #4860.
This commit is contained in:
parent
c8a2ef863e
commit
7b08eb481d
@ -1728,82 +1728,88 @@ D3D11_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture *
|
|||||||
float minx, miny, maxx, maxy;
|
float minx, miny, maxx, maxy;
|
||||||
float minu, maxu, minv, maxv;
|
float minu, maxu, minv, maxv;
|
||||||
|
|
||||||
if (flip & SDL_FLIP_HORIZONTAL) {
|
if (!verts) {
|
||||||
minu = (float) srcrect->x / texture->w;
|
return -1;
|
||||||
maxu = (float) (srcrect->x + srcrect->w) / texture->w;
|
|
||||||
} else {
|
|
||||||
minu = (float) (srcrect->x + srcrect->w) / texture->w;
|
|
||||||
maxu = (float) srcrect->x / texture->w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flip & SDL_FLIP_VERTICAL) {
|
cmd->data.draw.count = 1;
|
||||||
minv = (float) srcrect->y / texture->h;
|
|
||||||
maxv = (float) (srcrect->y + srcrect->h) / texture->h;
|
|
||||||
} else {
|
|
||||||
minv = (float) (srcrect->y + srcrect->h) / texture->h;
|
|
||||||
maxv = (float) srcrect->y / texture->h;
|
|
||||||
}
|
|
||||||
|
|
||||||
minx = -center->x;
|
minx = -center->x;
|
||||||
maxx = dstrect->w - center->x;
|
maxx = dstrect->w - center->x;
|
||||||
miny = -center->y;
|
miny = -center->y;
|
||||||
maxy = dstrect->h - center->y;
|
maxy = dstrect->h - center->y;
|
||||||
|
|
||||||
cmd->data.draw.count = 1;
|
if (flip & SDL_FLIP_HORIZONTAL) {
|
||||||
|
minu = (float) (srcrect->x + srcrect->w) / texture->w;
|
||||||
|
maxu = (float) srcrect->x / texture->w;
|
||||||
|
} else {
|
||||||
|
minu = (float) srcrect->x / texture->w;
|
||||||
|
maxu = (float) (srcrect->x + srcrect->w) / texture->w;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flip & SDL_FLIP_VERTICAL) {
|
||||||
|
minv = (float) (srcrect->y + srcrect->h) / texture->h;
|
||||||
|
maxv = (float) srcrect->y / texture->h;
|
||||||
|
} else {
|
||||||
|
minv = (float) srcrect->y / texture->h;
|
||||||
|
maxv = (float) (srcrect->y + srcrect->h) / texture->h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
verts->pos.x = minx;
|
verts->pos.x = minx;
|
||||||
verts->pos.y = miny;
|
verts->pos.y = miny;
|
||||||
verts->pos.z = 0.0f;
|
verts->pos.z = 0.0f;
|
||||||
verts->tex.x = minu;
|
|
||||||
verts->tex.y = minv;
|
|
||||||
verts->color.x = r;
|
verts->color.x = r;
|
||||||
verts->color.y = g;
|
verts->color.y = g;
|
||||||
verts->color.z = b;
|
verts->color.z = b;
|
||||||
verts->color.w = a;
|
verts->color.w = a;
|
||||||
|
verts->tex.x = minu;
|
||||||
|
verts->tex.y = minv;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
verts->pos.x = minx;
|
verts->pos.x = minx;
|
||||||
verts->pos.y = maxy;
|
verts->pos.y = maxy;
|
||||||
verts->pos.z = 0.0f;
|
verts->pos.z = 0.0f;
|
||||||
verts->tex.x = minu;
|
|
||||||
verts->tex.y = maxv;
|
|
||||||
verts->color.x = r;
|
verts->color.x = r;
|
||||||
verts->color.y = g;
|
verts->color.y = g;
|
||||||
verts->color.z = b;
|
verts->color.z = b;
|
||||||
verts->color.w = a;
|
verts->color.w = a;
|
||||||
|
verts->tex.x = minu;
|
||||||
|
verts->tex.y = maxv;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
verts->pos.x = maxx;
|
verts->pos.x = maxx;
|
||||||
verts->pos.y = miny;
|
verts->pos.y = miny;
|
||||||
verts->pos.z = 0.0f;
|
verts->pos.z = 0.0f;
|
||||||
verts->tex.x = maxu;
|
|
||||||
verts->tex.y = minv;
|
|
||||||
verts->color.x = r;
|
verts->color.x = r;
|
||||||
verts->color.y = g;
|
verts->color.y = g;
|
||||||
verts->color.z = b;
|
verts->color.z = b;
|
||||||
verts->color.w = a;
|
verts->color.w = a;
|
||||||
|
verts->tex.x = maxu;
|
||||||
|
verts->tex.y = minv;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
verts->pos.x = maxx;
|
verts->pos.x = maxx;
|
||||||
verts->pos.y = maxy;
|
verts->pos.y = maxy;
|
||||||
verts->pos.z = 0.0f;
|
verts->pos.z = 0.0f;
|
||||||
verts->tex.x = maxu;
|
|
||||||
verts->tex.y = maxv;
|
|
||||||
verts->color.x = r;
|
verts->color.x = r;
|
||||||
verts->color.y = g;
|
verts->color.y = g;
|
||||||
verts->color.z = b;
|
verts->color.z = b;
|
||||||
verts->color.w = a;
|
verts->color.w = a;
|
||||||
|
verts->tex.x = maxu;
|
||||||
|
verts->tex.y = maxv;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
verts->pos.x = dstrect->x + center->x; /* X translation */
|
verts->pos.x = dstrect->x + center->x; /* X translation */
|
||||||
verts->pos.y = dstrect->y + center->y; /* Y translation */
|
verts->pos.y = dstrect->y + center->y; /* Y translation */
|
||||||
verts->pos.z = (float)(M_PI * (float) angle / 180.0f); /* rotation */
|
verts->pos.z = (float)(M_PI * (float) angle / 180.0f); /* rotation */
|
||||||
verts->tex.x = 0.0f;
|
|
||||||
verts->tex.y = 0.0f;
|
|
||||||
verts->color.x = 0;
|
verts->color.x = 0;
|
||||||
verts->color.y = 0;
|
verts->color.y = 0;
|
||||||
verts->color.z = 0;
|
verts->color.z = 0;
|
||||||
verts->color.w = 0;
|
verts->color.w = 0;
|
||||||
|
verts->tex.x = 0.0f;
|
||||||
|
verts->tex.y = 0.0f;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user