From ebd598b2b075e3b7d890bfe642cc8d4f4ef12c7c Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 12 May 2018 19:31:34 +0200 Subject: [PATCH] Fixing a bunch of compiler warnings. --- source/Graphics/BatchRenderer2D.cpp | 2 +- source/Graphics/DefaultRenderer2D.cpp | 2 +- source/Graphics/Image.cpp | 14 +++++++------- source/Graphics/Text.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/Graphics/BatchRenderer2D.cpp b/source/Graphics/BatchRenderer2D.cpp index 73d3119..9748453 100644 --- a/source/Graphics/BatchRenderer2D.cpp +++ b/source/Graphics/BatchRenderer2D.cpp @@ -221,7 +221,7 @@ unsigned int BatchRenderer2D::addRenderable(Vertex2D* buffer, const Renderable2D // Pretransform vertex positions to skip setting a uniform model // matrix in the shader for each renderable reducing the number of draw calls. - for(int i = 0; i < vertices.size(); i++) { + for(size_t i = 0; i < vertices.size(); i++) { buffer[i].position = transform * vertices[i].position; buffer[i].color = vertices[i].color; buffer[i].uv = vertices[i].uv; diff --git a/source/Graphics/DefaultRenderer2D.cpp b/source/Graphics/DefaultRenderer2D.cpp index 7fd447e..99724f4 100644 --- a/source/Graphics/DefaultRenderer2D.cpp +++ b/source/Graphics/DefaultRenderer2D.cpp @@ -37,7 +37,7 @@ void DefaultRenderer2D::render() glEnableVertexAttribArray(VertexAttribColor0); glEnableVertexAttribArray(VertexAttribTexCoord0); - for(int i = 0; i < m_queue.size(); i++) { + for(size_t i = 0; i < m_queue.size(); i++) { const Renderable2D* obj = m_queue[i]; const std::vector vertices = obj->getVertices(); diff --git a/source/Graphics/Image.cpp b/source/Graphics/Image.cpp index 59d5f02..66dc3d7 100644 --- a/source/Graphics/Image.cpp +++ b/source/Graphics/Image.cpp @@ -19,7 +19,7 @@ void Image::create(unsigned width, unsigned height, const Color& color) m_pixels.resize(m_size.x * m_size.y * (getBpp() / 8)); - for(int i = 0; i < m_pixels.size(); i += 4) { + for(size_t i = 0; i < m_pixels.size(); i += 4) { m_pixels[i+0] = color.r; m_pixels[i+1] = color.g; @@ -42,7 +42,7 @@ void Image::create(PixelFormat format, unsigned width, unsigned height, const Co m_pixels.resize(m_size.x * m_size.y * (getBpp() / 8)); if (getBpp() == 32) { - for(int i = 0; i < m_pixels.size(); i += 4) { + for(size_t i = 0; i < m_pixels.size(); i += 4) { m_pixels[i+0] = color.r; m_pixels[i+1] = color.g; @@ -50,14 +50,14 @@ void Image::create(PixelFormat format, unsigned width, unsigned height, const Co m_pixels[i+3] = color.a; } } else if (getBpp() == 24) { - for(int i = 0; i < m_pixels.size(); i += 3) { + for(size_t i = 0; i < m_pixels.size(); i += 3) { m_pixels[i+0] = color.r; m_pixels[i+1] = color.g; m_pixels[i+2] = color.b; } } else { - for(int i = 0; i < m_pixels.size(); i += 1) { + for(size_t i = 0; i < m_pixels.size(); i += 1) { m_pixels[i] = color.a; } } @@ -163,7 +163,7 @@ Color Image::getPixel(unsigned x, unsigned y) const if (m_format == PixelFormat::PF_RGBA) { c.a = base[3]; } else { - c.a = 1.0f; + c.a = 255; } } // Alpha, single channel format. @@ -178,12 +178,12 @@ void Image::flipY() unsigned int stride = getStride(); // The quick and dirty way :) - for(int y = 0; y < m_size.y / 2; y++) { + for(size_t y = 0; y < m_size.y / 2; y++) { int row0 = y * stride; int row1 = (m_size.y - y - 1) * stride; - for(int x = 0; x < stride; x++) { + for(size_t x = 0; x < stride; x++) { unsigned char tmp = m_pixels[row0 + x]; m_pixels[row0 + x] = m_pixels[row1 + x]; m_pixels[row1 + x] = tmp; diff --git a/source/Graphics/Text.cpp b/source/Graphics/Text.cpp index 7160c8e..6acbcf9 100644 --- a/source/Graphics/Text.cpp +++ b/source/Graphics/Text.cpp @@ -90,7 +90,7 @@ Vector2f Text::getSize() const { Vector2f size; - for(int i = 0; i < m_string.size(); i++) { + for(size_t i = 0; i < m_string.size(); i++) { Font::Glyph glyph = m_font->getGlyph(m_string[i]); @@ -136,7 +136,7 @@ void Text::updateGeometry() const m_vertices.clear(); - for(int i = 0; i < m_string.length(); i++) { + for(size_t i = 0; i < m_string.length(); i++) { Vertex2D v1, v2, v3, v4;