fixed scaling to be accurate
This commit is contained in:
parent
51638079c7
commit
a2c86d9f7c
2 changed files with 6 additions and 15 deletions
20
src/Draw.cpp
20
src/Draw.cpp
|
@ -119,7 +119,7 @@ bool MakeSurface(SDL_RWops *fp, int surf_no)
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_QueryTexture(texture, NULL, NULL, &w, &h);
|
SDL_QueryTexture(texture, NULL, NULL, &w, &h);
|
||||||
|
|
||||||
SDL_Texture *textureAccessible = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, w, h);
|
SDL_Texture *textureAccessible = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, w * gWindowScale, h * gWindowScale);
|
||||||
|
|
||||||
if (!textureAccessible)
|
if (!textureAccessible)
|
||||||
{
|
{
|
||||||
|
@ -135,7 +135,6 @@ bool MakeSurface(SDL_RWops *fp, int surf_no)
|
||||||
|
|
||||||
//Set surface's metadata
|
//Set surface's metadata
|
||||||
surf[surf_no].texture = textureAccessible;
|
surf[surf_no].texture = textureAccessible;
|
||||||
surf[surf_no].scale = true;
|
|
||||||
|
|
||||||
//Free surface and texture
|
//Free surface and texture
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
|
@ -216,9 +215,6 @@ bool MakeSurface_Generic(int bxsize, int bysize, int surf_no)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetTextureBlendMode(surf[surf_no].texture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(surf[surf_no].texture, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
//Set metadata
|
|
||||||
surf[surf_no].scale = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,13 +254,11 @@ void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, int surf_no) //Transpare
|
||||||
//Get SDL_Rects
|
//Get SDL_Rects
|
||||||
SDL_Rect clipRect = RectToSDLRect(rcView);
|
SDL_Rect clipRect = RectToSDLRect(rcView);
|
||||||
|
|
||||||
int scale = surf[surf_no].scale ? 1 : gWindowScale;
|
|
||||||
SDL_Rect frameRect = RectToSDLRect(rect);
|
SDL_Rect frameRect = RectToSDLRect(rect);
|
||||||
frameRect = {frameRect.x * scale, frameRect.y * scale, frameRect.w * scale, frameRect.h * scale};
|
frameRect = {frameRect.x * gWindowScale, frameRect.y * gWindowScale, frameRect.w * gWindowScale, frameRect.h * gWindowScale};
|
||||||
|
|
||||||
//Get dest rect
|
//Get dest rect
|
||||||
scale = surf[surf_no].scale ? gWindowScale : 1;
|
SDL_Rect destRect = {x * gWindowScale, y * gWindowScale, frameRect.w, frameRect.h};
|
||||||
SDL_Rect destRect = {x * gWindowScale, y * gWindowScale, frameRect.w * scale, frameRect.h * scale};
|
|
||||||
|
|
||||||
//Set cliprect
|
//Set cliprect
|
||||||
clipRect = {clipRect.x * gWindowScale, clipRect.y * gWindowScale, clipRect.w * gWindowScale, clipRect.h * gWindowScale};
|
clipRect = {clipRect.x * gWindowScale, clipRect.y * gWindowScale, clipRect.w * gWindowScale, clipRect.h * gWindowScale};
|
||||||
|
@ -283,13 +277,11 @@ void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, int surf_no) //No Transp
|
||||||
//Get SDL_Rects
|
//Get SDL_Rects
|
||||||
SDL_Rect clipRect = RectToSDLRect(rcView);
|
SDL_Rect clipRect = RectToSDLRect(rcView);
|
||||||
|
|
||||||
int scale = surf[surf_no].scale ? 1 : gWindowScale;
|
|
||||||
SDL_Rect frameRect = RectToSDLRect(rect);
|
SDL_Rect frameRect = RectToSDLRect(rect);
|
||||||
frameRect = {frameRect.x * scale, frameRect.y * scale, frameRect.w * scale, frameRect.h * scale};
|
frameRect = {frameRect.x * gWindowScale, frameRect.y * gWindowScale, frameRect.w * gWindowScale, frameRect.h * gWindowScale};
|
||||||
|
|
||||||
//Get dest rect
|
//Get dest rect
|
||||||
scale = surf[surf_no].scale ? gWindowScale : 1;
|
SDL_Rect destRect = {x * gWindowScale, y * gWindowScale, frameRect.w, frameRect.h};
|
||||||
SDL_Rect destRect = {x * gWindowScale, y * gWindowScale, frameRect.w * scale, frameRect.h * scale};
|
|
||||||
|
|
||||||
//Set cliprect
|
//Set cliprect
|
||||||
clipRect = {clipRect.x * gWindowScale, clipRect.y * gWindowScale, clipRect.w * gWindowScale, clipRect.h * gWindowScale};
|
clipRect = {clipRect.x * gWindowScale, clipRect.y * gWindowScale, clipRect.w * gWindowScale, clipRect.h * gWindowScale};
|
||||||
|
@ -315,7 +307,7 @@ void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, int surf_no) //No Transp
|
||||||
void Surface2Surface(int x, int y, RECT *rect, int to, int from)
|
void Surface2Surface(int x, int y, RECT *rect, int to, int from)
|
||||||
{
|
{
|
||||||
//Get rects
|
//Get rects
|
||||||
SDL_Rect rcSet = {x, y, x + rect->right - rect->left, y + rect->bottom - rect->top};
|
SDL_Rect rcSet = {x * gWindowScale, y * gWindowScale, (x + rect->right - rect->left) * gWindowScale, (y + rect->bottom - rect->top) * gWindowScale};
|
||||||
SDL_Rect frameRect = RectToSDLRect(rect);
|
SDL_Rect frameRect = RectToSDLRect(rect);
|
||||||
frameRect = {frameRect.x * gWindowScale, frameRect.y * gWindowScale, frameRect.w * gWindowScale, frameRect.h * gWindowScale};
|
frameRect = {frameRect.x * gWindowScale, frameRect.y * gWindowScale, frameRect.w * gWindowScale, frameRect.h * gWindowScale};
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ enum Surface_Ids
|
||||||
struct SURFACE
|
struct SURFACE
|
||||||
{
|
{
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
bool scale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SURFACE surf[SURFACE_ID_MAX];
|
extern SURFACE surf[SURFACE_ID_MAX];
|
||||||
|
|
Loading…
Add table
Reference in a new issue