1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

newSurface method now accepts Point instead of two integers

This commit is contained in:
Ivan Savenko
2024-07-21 19:41:46 +00:00
parent 20ba63bba3
commit 7f5cd8a7aa
6 changed files with 12 additions and 12 deletions

View File

@@ -63,21 +63,21 @@ void CSDL_Ext::setAlpha(SDL_Surface * bg, int value)
SDL_SetSurfaceAlphaMod(bg, value);
}
SDL_Surface * CSDL_Ext::newSurface(int w, int h)
SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions)
{
return newSurface(w, h, screen);
return newSurface(dimensions, screen);
}
SDL_Surface * CSDL_Ext::newSurface(int w, int h, SDL_Surface * mod) //creates new surface, with flags/format same as in surface given
SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions, SDL_Surface * mod) //creates new surface, with flags/format same as in surface given
{
SDL_Surface * ret = SDL_CreateRGBSurface(0,w,h,mod->format->BitsPerPixel,mod->format->Rmask,mod->format->Gmask,mod->format->Bmask,mod->format->Amask);
SDL_Surface * ret = SDL_CreateRGBSurface(0,dimensions.x,dimensions.y,mod->format->BitsPerPixel,mod->format->Rmask,mod->format->Gmask,mod->format->Bmask,mod->format->Amask);
if(ret == nullptr)
{
const char * error = SDL_GetError();
std::string messagePattern = "Failed to create SDL Surface of size %d x %d, %d bpp. Reason: %s";
std::string message = boost::str(boost::format(messagePattern) % w % h % mod->format->BitsPerPixel % error);
std::string message = boost::str(boost::format(messagePattern) % dimensions.x % dimensions.y % mod->format->BitsPerPixel % error);
handleFatalError(message, true);
}
@@ -631,7 +631,7 @@ SDL_Surface * CSDL_Ext::scaleSurface(SDL_Surface * surf, int width, int height)
return nullptr;
SDL_Surface * intermediate = SDL_ConvertSurface(surf, screen->format, 0);
SDL_Surface * ret = newSurface(width, height, intermediate);
SDL_Surface * ret = newSurface(Point(width, height), intermediate);
#if SDL_VERSION_ATLEAST(2,0,16)
SDL_SoftStretchLinear(intermediate, nullptr, ret, nullptr);