mirror of https://github.com/encounter/SDL.git
Make RenderCopyEx rotate around center
This still isn't perfect. The rotation is the wrong way around and the images are upside down.
This commit is contained in:
parent
2df2da11f6
commit
2b572dff88
|
@ -891,15 +891,13 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
|
||||||
const float width = dstrect->w - centerx;
|
const float width = dstrect->w - centerx;
|
||||||
const float height = dstrect->h - centery;
|
const float height = dstrect->h - centery;
|
||||||
float s, c;
|
float s, c;
|
||||||
float cw, sw, ch, sh;
|
float cw1, sw1, ch1, sh1, cw2, sw2, ch2, sh2;
|
||||||
|
|
||||||
float u0 = srcrect->x;
|
float u0 = srcrect->x;
|
||||||
float v0 = srcrect->y;
|
float v0 = srcrect->y;
|
||||||
float u1 = srcrect->x + srcrect->w;
|
float u1 = srcrect->x + srcrect->w;
|
||||||
float v1 = srcrect->y + srcrect->h;
|
float v1 = srcrect->y + srcrect->h;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!verts) {
|
if (!verts) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -908,10 +906,14 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
|
||||||
|
|
||||||
MathSincos(degToRad(angle), &s, &c);
|
MathSincos(degToRad(angle), &s, &c);
|
||||||
|
|
||||||
cw = c * width;
|
cw1 = c * width;
|
||||||
sw = s * width;
|
sw1 = s * width;
|
||||||
ch = c * height;
|
ch1 = c * height;
|
||||||
sh = s * height;
|
sh1 = s * height;
|
||||||
|
cw2 = c * -centerx;
|
||||||
|
sw2 = s * -centerx;
|
||||||
|
ch2 = c * -centery;
|
||||||
|
sh2 = s * -centery;
|
||||||
|
|
||||||
if (flip & SDL_FLIP_VERTICAL) {
|
if (flip & SDL_FLIP_VERTICAL) {
|
||||||
Swap(&v0, &v1);
|
Swap(&v0, &v1);
|
||||||
|
@ -923,29 +925,29 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
|
||||||
|
|
||||||
verts->u = u0;
|
verts->u = u0;
|
||||||
verts->v = v0;
|
verts->v = v0;
|
||||||
verts->x = x - cw + sh;
|
verts->x = x + cw1 + sh1;
|
||||||
verts->y = y - sw - ch;
|
verts->y = y - sw1 + ch1;
|
||||||
verts->z = 0;
|
verts->z = 0;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
verts->u = u0;
|
verts->u = u0;
|
||||||
verts->v = v1;
|
verts->v = v1;
|
||||||
verts->x = x - cw - sh;
|
verts->x = x + cw1 + sh2;
|
||||||
verts->y = y - sw + ch;
|
verts->y = y - sw1 + ch2;
|
||||||
verts->z = 0;
|
verts->z = 0;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
verts->u = u1;
|
verts->u = u1;
|
||||||
verts->v = v1;
|
verts->v = v1;
|
||||||
verts->x = x + cw - sh;
|
verts->x = x + cw2 + sh2;
|
||||||
verts->y = y + sw + ch;
|
verts->y = y - sw2 + ch2;
|
||||||
verts->z = 0;
|
verts->z = 0;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
verts->u = u1;
|
verts->u = u1;
|
||||||
verts->v = v0;
|
verts->v = v0;
|
||||||
verts->x = x + cw + sh;
|
verts->x = x + cw2 + sh1;
|
||||||
verts->y = y + sw - ch;
|
verts->y = y - sw2 + ch1;
|
||||||
verts->z = 0;
|
verts->z = 0;
|
||||||
verts++;
|
verts++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue