Make RenderCopyEx rotate around center This still isn't perfect. The rotation is the wrong way around and the images are upside down.
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
diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c
index 8f6ee08..9ab4070 100644
--- a/src/render/psp/SDL_render_psp.c
+++ b/src/render/psp/SDL_render_psp.c
@@ -891,15 +891,13 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
const float width = dstrect->w - centerx;
const float height = dstrect->h - centery;
float s, c;
- float cw, sw, ch, sh;
+ float cw1, sw1, ch1, sh1, cw2, sw2, ch2, sh2;
float u0 = srcrect->x;
float v0 = srcrect->y;
float u1 = srcrect->x + srcrect->w;
float v1 = srcrect->y + srcrect->h;
-
-
if (!verts) {
return -1;
}
@@ -908,10 +906,14 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
MathSincos(degToRad(angle), &s, &c);
- cw = c * width;
- sw = s * width;
- ch = c * height;
- sh = s * height;
+ cw1 = c * width;
+ sw1 = s * width;
+ ch1 = c * height;
+ sh1 = s * height;
+ cw2 = c * -centerx;
+ sw2 = s * -centerx;
+ ch2 = c * -centery;
+ sh2 = s * -centery;
if (flip & SDL_FLIP_VERTICAL) {
Swap(&v0, &v1);
@@ -923,29 +925,29 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
verts->u = u0;
verts->v = v0;
- verts->x = x - cw + sh;
- verts->y = y - sw - ch;
+ verts->x = x + cw1 + sh1;
+ verts->y = y - sw1 + ch1;
verts->z = 0;
verts++;
verts->u = u0;
verts->v = v1;
- verts->x = x - cw - sh;
- verts->y = y - sw + ch;
+ verts->x = x + cw1 + sh2;
+ verts->y = y - sw1 + ch2;
verts->z = 0;
verts++;
verts->u = u1;
verts->v = v1;
- verts->x = x + cw - sh;
- verts->y = y + sw + ch;
+ verts->x = x + cw2 + sh2;
+ verts->y = y - sw2 + ch2;
verts->z = 0;
verts++;
verts->u = u1;
verts->v = v0;
- verts->x = x + cw + sh;
- verts->y = y + sw - ch;
+ verts->x = x + cw2 + sh1;
+ verts->y = y - sw2 + ch1;
verts->z = 0;
verts++;