summaryrefslogtreecommitdiff
path: root/src/resources/openglimagehelper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-06 23:34:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-07 19:23:40 +0300
commit36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch)
tree190156cb88b13a38a6d13c69ee0742cc078065a1 /src/resources/openglimagehelper.cpp
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmanaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/resources/openglimagehelper.cpp')
-rw-r--r--src/resources/openglimagehelper.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index d854c0666..66c60e039 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -69,7 +69,7 @@ OpenGLImageHelper::~OpenGLImageHelper()
Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
{
SDL_Surface *const tmpImage = loadPng(rw);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image load failed: %s", IMG_GetError());
return nullptr;
@@ -77,7 +77,7 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const surf = convertTo32Bit(tmpImage);
MSDL_FreeSurface(tmpImage);
- if (!surf)
+ if (surf == nullptr)
return nullptr;
uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
@@ -88,14 +88,14 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
case 1:
{
const DyePalette *const pal = dye.getSPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h);
break;
}
case 2:
{
const DyePalette *const pal = dye.getAPalete();
- if (pal)
+ if (pal != nullptr)
DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h);
break;
}
@@ -121,11 +121,11 @@ Image *OpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
const int width, const int height,
const float alpha)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
Image *const img = glLoad(tmpImage, width, height);
- if (img)
+ if (img != nullptr)
img->setAlpha(alpha);
return img;
}
@@ -141,7 +141,7 @@ int OpenGLImageHelper::powerOfTwo(const int input)
SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
int width, int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
int realWidth = powerOfTwo(width);
@@ -190,7 +190,7 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image convert failed: out of memory");
return nullptr;
@@ -203,7 +203,7 @@ SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
int width, int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
#ifdef USE_SDL2
@@ -242,7 +242,7 @@ SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
32, rmask, gmask, bmask, amask);
- if (!tmpImage)
+ if (tmpImage == nullptr)
{
reportAlways("Error, image convert failed: out of memory");
return nullptr;
@@ -308,21 +308,21 @@ void OpenGLImageHelper::bindTexture(const GLuint texture)
Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
int width, int height)
{
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
BLOCK_START("OpenGLImageHelper::glLoad")
// Flush current error flag.
graphicsManager.getLastError();
- if (!width)
+ if (width == 0)
width = tmpImage->w;
- if (!height)
+ if (height == 0)
height = tmpImage->h;
SDL_Surface *oldImage = tmpImage;
tmpImage = convertSurfaceNormalize(tmpImage, width, height);
- if (!tmpImage)
+ if (tmpImage == nullptr)
return nullptr;
const int realWidth = tmpImage->w;
@@ -414,7 +414,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
MSDL_FreeSurface(tmpImage);
GLenum error = graphicsManager.getLastError();
- if (error)
+ if (error != 0u)
{
std::string errmsg = GraphicsManager::errorToString(error);
reportAlways("Error: Image GL import failed: %s (%u)",
@@ -493,17 +493,17 @@ void OpenGLImageHelper::copySurfaceToImage(const Image *const image,
const int x, const int y,
SDL_Surface *surface) const
{
- if (!surface || !image)
+ if (surface == nullptr || image == nullptr)
return;
SDL_Surface *const oldSurface = surface;
surface = convertSurface(surface, surface->w, surface->h);
- if (!surface)
+ if (surface == nullptr)
return;
// +++ probably need combine
// mglTextureSubImage2D and mglTextureSubImage2DEXT
- if (mglTextureSubImage2D)
+ if (mglTextureSubImage2D != nullptr)
{
mglTextureSubImage2D(image->mGLImage,
0,