From 454508376039429ad292de69cd491badda798062 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 May 2014 22:47:46 +0300 Subject: Fix code style in render. --- src/render/graphics.cpp | 6 ++++-- src/render/mobileopenglgraphics.cpp | 4 ++-- src/render/normalopenglgraphics.cpp | 4 ++-- src/render/nullopenglgraphics.cpp | 2 +- src/render/safeopenglgraphics.cpp | 2 +- src/render/sdlgraphics.cpp | 23 +++++++++++++---------- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 24c3ab69e..baceeacc1 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -300,8 +300,10 @@ bool Graphics::setOpenGLMode() GLint texSize; bool rectTex = graphicsManager.supportExtension( "GL_ARB_texture_rectangle"); - if (rectTex && OpenGLImageHelper::getInternalTextureType() == 4 - && getOpenGL() != 3 && config.getBoolValue("rectangulartextures") + if (rectTex + && OpenGLImageHelper::getInternalTextureType() == 4 + && getOpenGL() != RENDER_GLES_OPENGL + && config.getBoolValue("rectangulartextures") && !graphicsManager.isUseTextureSampler()) { logger->log1("using GL_ARB_texture_rectangle"); diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 9a420740b..dcb34ffd5 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -113,7 +113,7 @@ void MobileOpenGLGraphics::initArrays() mMaxVertices = 1024; // need alocate small size, after if limit reached reallocate to double size - const int sz = mMaxVertices * 4 + 30; + const size_t sz = mMaxVertices * 4 + 30; vertexBufSize = mMaxVertices; if (!mFloatTexArray) mFloatTexArray = new GLfloat[sz]; @@ -924,7 +924,7 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot() if (SDL_MUSTLOCK(screenshot)) SDL_LockSurface(screenshot); - const unsigned int lineSize = 3 * w; + const size_t lineSize = 3 * w; GLubyte *const buf = new GLubyte[lineSize]; // Grap the pixel buffer and write it to the SDL surface diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index bb8eed230..7130e2914 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -132,7 +132,7 @@ void NormalOpenGLGraphics::initArrays() // need alocate small size, after if limit reached reallocate to double size vertexBufSize = mMaxVertices; - const int sz = mMaxVertices * 4 + 30; + const size_t sz = mMaxVertices * 4 + 30; if (!mFloatTexArray) mFloatTexArray = new GLfloat[sz]; if (!mIntTexArray) @@ -1194,7 +1194,7 @@ SDL_Surface* NormalOpenGLGraphics::getScreenshot() glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels); // Flip the screenshot, as OpenGL has 0,0 in bottom left - const unsigned int lineSize = 3 * w; + const size_t lineSize = 3 * w; GLubyte *const buf = new GLubyte[lineSize]; const int h2 = h / 2; diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 6497a7b5a..8eb88f060 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -76,7 +76,7 @@ void NullOpenGLGraphics::initArrays() // need alocate small size, after if limit reached reallocate to double size vertexBufSize = mMaxVertices; - const int sz = mMaxVertices * 4 + 30; + const size_t sz = mMaxVertices * 4 + 30; if (!mFloatTexArray) mFloatTexArray = new GLfloat[sz]; if (!mIntTexArray) diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index d5c9981a3..fcf4a7e68 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -500,7 +500,7 @@ SDL_Surface* SafeOpenGLGraphics::getScreenshot() glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels); // Flip the screenshot, as OpenGL has 0,0 in bottom left - unsigned int lineSize = 3 * w; + size_t lineSize = 3 * w; GLubyte* buf = new GLubyte[lineSize]; const int h2 = h / 2; diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 9b852689d..8720b4dc9 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -952,19 +952,22 @@ void SDLGraphics::fillRectangle(const Rect& rectangle) for (y = y1; y < y2; y++) { uint8_t *const p = static_cast(mWindow->pixels) - + y * mWindow->pitch; + + static_cast(y * mWindow->pitch); for (x = x1; x < x2; x++) - *(p + x) = static_cast(pixel); + { + *(p + static_cast(x)) + = static_cast(pixel); + } } break; case 2: for (y = y1; y < y2; y++) { uint8_t *const p0 = static_cast(mWindow->pixels) - + y * mWindow->pitch; + + static_cast(y * mWindow->pitch); for (x = x1; x < x2; x++) { - uint8_t *const p = p0 + x * 2; + uint8_t *const p = p0 + static_cast(x * 2); *reinterpret_cast(p) = SDLAlpha16( static_cast(pixel), *reinterpret_cast(p), @@ -982,10 +985,10 @@ void SDLGraphics::fillRectangle(const Rect& rectangle) for (y = y1; y < y2; y++) { uint8_t *const p0 = static_cast(mWindow->pixels) - + y * mWindow->pitch; + + static_cast(y * mWindow->pitch); for (x = x1; x < x2; x++) { - uint8_t *const p = p0 + x * 3; + uint8_t *const p = p0 + static_cast(x * 3); #if SDL_BYTEORDER == SDL_BIG_ENDIAN p[2] = static_cast((p[2] * ca + cb) >> 8); p[1] = static_cast((p[1] * ca + cg) >> 8); @@ -1074,10 +1077,10 @@ void SDLGraphics::fillRectangle(const Rect& rectangle) { uint32_t *const p0 = reinterpret_cast( static_cast(mWindow->pixels) - + y * mWindow->pitch); + + static_cast(y * mWindow->pitch)); for (x = x1; x < x2; x++) { - uint32_t *const p = p0 + x; + uint32_t *const p = p0 + static_cast(x); const uint32_t dst = *p; *p = cB[dst & bMask / bShift] | cG[(dst & gMask) / gShift] @@ -1222,7 +1225,7 @@ void SDLGraphics::drawHLine(int x1, int y, int x2) SDL_LockSurface(mWindow); uint8_t *p = static_cast(mWindow->pixels) - + y * mWindow->pitch + x1 * bpp; + + static_cast(y * mWindow->pitch + x1 * bpp); const uint32_t pixel = SDL_MapRGB(mWindow->format, static_cast(mColor.r), @@ -1347,7 +1350,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) SDL_LockSurface(mWindow); uint8_t *p = static_cast(mWindow->pixels) - + y1 * mWindow->pitch + x * bpp; + + static_cast(y1 * mWindow->pitch + x * bpp); const uint32_t pixel = SDL_MapRGB(mWindow->format, static_cast(mColor.r), -- cgit v1.2.3-60-g2f50