direct3d11: Fixed incorrect texture coordinates (thanks, Martin!). Fixes Bugzilla #4860.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 720622d..f7b8995 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -1728,82 +1728,88 @@ D3D11_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture *
float minx, miny, maxx, maxy;
float minu, maxu, minv, maxv;
+ if (!verts) {
+ return -1;
+ }
+
+ cmd->data.draw.count = 1;
+
+ minx = -center->x;
+ maxx = dstrect->w - center->x;
+ miny = -center->y;
+ maxy = dstrect->h - center->y;
+
if (flip & SDL_FLIP_HORIZONTAL) {
- minu = (float) srcrect->x / texture->w;
- maxu = (float) (srcrect->x + srcrect->w) / texture->w;
- } else {
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 / 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;
+ } else {
+ minv = (float) srcrect->y / texture->h;
+ maxv = (float) (srcrect->y + srcrect->h) / texture->h;
}
- minx = -center->x;
- maxx = dstrect->w - center->x;
- miny = -center->y;
- maxy = dstrect->h - center->y;
- cmd->data.draw.count = 1;
verts->pos.x = minx;
verts->pos.y = miny;
verts->pos.z = 0.0f;
- verts->tex.x = minu;
- verts->tex.y = minv;
verts->color.x = r;
verts->color.y = g;
verts->color.z = b;
verts->color.w = a;
+ verts->tex.x = minu;
+ verts->tex.y = minv;
verts++;
verts->pos.x = minx;
verts->pos.y = maxy;
verts->pos.z = 0.0f;
- verts->tex.x = minu;
- verts->tex.y = maxv;
verts->color.x = r;
verts->color.y = g;
verts->color.z = b;
verts->color.w = a;
+ verts->tex.x = minu;
+ verts->tex.y = maxv;
verts++;
verts->pos.x = maxx;
verts->pos.y = miny;
verts->pos.z = 0.0f;
- verts->tex.x = maxu;
- verts->tex.y = minv;
verts->color.x = r;
verts->color.y = g;
verts->color.z = b;
verts->color.w = a;
+ verts->tex.x = maxu;
+ verts->tex.y = minv;
verts++;
verts->pos.x = maxx;
verts->pos.y = maxy;
verts->pos.z = 0.0f;
- verts->tex.x = maxu;
- verts->tex.y = maxv;
verts->color.x = r;
verts->color.y = g;
verts->color.z = b;
verts->color.w = a;
+ verts->tex.x = maxu;
+ verts->tex.y = maxv;
verts++;
verts->pos.x = dstrect->x + center->x; /* X translation */
verts->pos.y = dstrect->y + center->y; /* Y translation */
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.y = 0;
verts->color.z = 0;
verts->color.w = 0;
+ verts->tex.x = 0.0f;
+ verts->tex.y = 0.0f;
verts++;
return 0;