Fixed bug 2421 for D3D9 - SDL_RenderCopyEx off by one when rotating by 90 and -90

Nader Golbaz

Updated patch for direct3d renderers
This commit is contained in:
Sam Lantinga 2016-11-06 08:42:46 -08:00
parent d767a450dc
commit 4ed4997cc4
1 changed files with 16 additions and 19 deletions

View File

@ -1723,29 +1723,27 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
centerx = center->x; centerx = center->x;
centery = center->y; centery = center->y;
if (flip & SDL_FLIP_HORIZONTAL) { minx = -centerx;
minx = dstrect->w - centerx - 0.5f; maxx = dstrect->w - centerx;
maxx = -centerx - 0.5f; miny = -centery;
} maxy = dstrect->h - centery;
else {
minx = -centerx - 0.5f;
maxx = dstrect->w - centerx - 0.5f;
}
if (flip & SDL_FLIP_VERTICAL) {
miny = dstrect->h - centery - 0.5f;
maxy = -centery - 0.5f;
}
else {
miny = -centery - 0.5f;
maxy = dstrect->h - centery - 0.5f;
}
minu = (float) srcrect->x / texture->w; minu = (float) srcrect->x / texture->w;
maxu = (float) (srcrect->x + srcrect->w) / texture->w; maxu = (float) (srcrect->x + srcrect->w) / texture->w;
minv = (float) srcrect->y / texture->h; minv = (float) srcrect->y / texture->h;
maxv = (float) (srcrect->y + srcrect->h) / texture->h; maxv = (float) (srcrect->y + srcrect->h) / texture->h;
if (flip & SDL_FLIP_HORIZONTAL) {
float tmp = maxu;
maxu = minu;
minu = tmp;
}
if (flip & SDL_FLIP_VERTICAL) {
float tmp = maxv;
maxv = minv;
minv = tmp;
}
color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b); color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);
vertices[0].x = minx; vertices[0].x = minx;
@ -1781,8 +1779,7 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
/* Rotate and translate */ /* Rotate and translate */
modelMatrix = MatrixMultiply( modelMatrix = MatrixMultiply(
MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)), MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)),
MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0) MatrixTranslation(dstrect->x + center->x - 0.5f, dstrect->y + center->y - 0.5f, 0));
);
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix); IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
D3D_UpdateTextureScaleMode(data, texturedata, 0); D3D_UpdateTextureScaleMode(data, texturedata, 0);