Diagonal flipping with RenderCopyEx

Ivan Rubinson

As it turns out, it was impossible to render a texture flipped diagonally (both vertically and horizontally) with one RenderCopyEx call.
With help from #SDL @ freenode, we came up with a fix.
This commit is contained in:
Sam Lantinga 2013-11-13 21:50:59 -08:00
parent ee3f8b15d5
commit cb3d7d3831
2 changed files with 38 additions and 30 deletions

View file

@ -1250,22 +1250,26 @@ GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
centerx = center->x;
centery = center->y;
if (flip & SDL_FLIP_HORIZONTAL) {
minx = dstrect->w - centerx;
maxx = -centerx;
}
else {
minx = -centerx;
maxx = dstrect->w - centerx;
}
if (flip & SDL_FLIP_VERTICAL) {
miny = dstrect->h - centery;
if ((flip & SDL_FLIP_VERTICAL) && (flip & SDL_FLIP_HORIZONTAL)) {
miny = dstrect->h - centery;
maxy = -centery;
}
else {
minx = dstrect->w - centerx;
maxx = -centerx;
} else if (flip & SDL_FLIP_HORIZONTAL) {
miny = -centery;
maxy = dstrect->h - centery;
maxy = dstrect->h - centery;
minx = dstrect->w - centerx;
maxx = -centerx;
} else if (flip & SDL_FLIP_VERTICAL) {
miny = dstrect->h - centery;
maxy = -centery;
minx = -centerx;
maxx = dstrect->w - centerx;
} else {
miny = -centery;
maxy = dstrect->h - centery;
minx = -centerx;
maxx = dstrect->w - centerx;
}
minu = (GLfloat) srcrect->x / texture->w;