From d29b7528a65dc7e518703d9cf5ad1f4f8f31747d Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 17 Sep 2015 15:22:16 +0300 Subject: [PATCH] Fix some type conversion warnings --- SDL2pp/Renderer.cc | 16 ++++++++-------- SDL2pp/Surface.cc | 4 ++-- examples/fill.cc | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 0d435a8..6227c6b 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -231,11 +231,11 @@ Renderer& Renderer::DrawPoint(const Point& p) { Renderer& Renderer::DrawPoints(const Point* points, int count) { std::vector sdl_points; - sdl_points.reserve(count); + sdl_points.reserve(static_cast(count)); for (const Point* p = points; p != points + count; ++p) sdl_points.emplace_back(*p); - if (SDL_RenderDrawPoints(renderer_, sdl_points.data(), sdl_points.size()) != 0) + if (SDL_RenderDrawPoints(renderer_, sdl_points.data(), count) != 0) throw Exception("SDL_RenderDrawPoints"); return *this; @@ -254,11 +254,11 @@ Renderer& Renderer::DrawLine(const Point& p1, const Point& p2) { Renderer& Renderer::DrawLines(const Point* points, int count) { std::vector sdl_points; - sdl_points.reserve(count); + sdl_points.reserve(static_cast(count)); for (const Point* p = points; p != points + count; ++p) sdl_points.emplace_back(*p); - if (SDL_RenderDrawLines(renderer_, sdl_points.data(), sdl_points.size()) != 0) + if (SDL_RenderDrawLines(renderer_, sdl_points.data(), count) != 0) throw Exception("SDL_RenderDrawLines"); return *this; @@ -284,11 +284,11 @@ Renderer& Renderer::DrawRect(const Rect& r) { Renderer& Renderer::DrawRects(const Rect* rects, int count) { std::vector sdl_rects; - sdl_rects.reserve(count); + sdl_rects.reserve(static_cast(count)); for (const Rect* r = rects; r != rects + count; ++r) sdl_rects.emplace_back(*r); - if (SDL_RenderDrawRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0) + if (SDL_RenderDrawRects(renderer_, sdl_rects.data(), count) != 0) throw Exception("SDL_RenderDrawRects"); return *this; @@ -314,11 +314,11 @@ Renderer& Renderer::FillRect(const Rect& r) { Renderer& Renderer::FillRects(const Rect* rects, int count) { std::vector sdl_rects; - sdl_rects.reserve(count); + sdl_rects.reserve(static_cast(count)); for (const Rect* r = rects; r != rects + count; ++r) sdl_rects.emplace_back(*r); - if (SDL_RenderFillRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0) + if (SDL_RenderFillRects(renderer_, sdl_rects.data(), count) != 0) throw Exception("SDL_RenderFillRects"); return *this; diff --git a/SDL2pp/Surface.cc b/SDL2pp/Surface.cc index 7fc86fe..ce7362c 100644 --- a/SDL2pp/Surface.cc +++ b/SDL2pp/Surface.cc @@ -192,11 +192,11 @@ Surface& Surface::FillRect(const Optional& rect, Uint32 color) { Surface& Surface::FillRects(const Rect* rects, int count, Uint32 color) { std::vector sdl_rects; - sdl_rects.reserve(count); + sdl_rects.reserve(static_cast(count)); for (const Rect* r = rects; r != rects + count; ++r) sdl_rects.emplace_back(*r); - if (SDL_FillRects(surface_, sdl_rects.data(), sdl_rects.size(), color) != 0) + if (SDL_FillRects(surface_, sdl_rects.data(), count, color) != 0) throw Exception("SDL_FillRects"); return *this; } diff --git a/examples/fill.cc b/examples/fill.cc index 83c61fa..de0724e 100644 --- a/examples/fill.cc +++ b/examples/fill.cc @@ -61,10 +61,10 @@ static int Run() { render.Clear(); // Fill - float dx = sin(SDL_GetTicks() / 5000.0f * pi) * 32.0f; - float dy = cos(SDL_GetTicks() / 10000.0f * pi) * 32.0f; + float dx = std::sin(SDL_GetTicks() / 5000.0f * pi) * 32.0f; + float dy = std::cos(SDL_GetTicks() / 10000.0f * pi) * 32.0f; - render.FillCopy(sprite, NullOpt, Rect(32, 32, window.GetWidth() - 64, window.GetHeight() - 64), SDL2pp::Point(dx, dy), SDL_FLIP_HORIZONTAL); + render.FillCopy(sprite, NullOpt, Rect(32, 32, window.GetWidth() - 64, window.GetHeight() - 64), SDL2pp::Point((int)dx, (int)dy), SDL_FLIP_HORIZONTAL); render.Present();