Fix randomly happening floating point error during clipping.

This commit is contained in:
King_DuckZ 2016-11-09 01:46:36 +01:00
parent e65c2341c2
commit 38826b94b8
4 changed files with 21 additions and 3 deletions

15
src/rect_to_sdl.cpp Normal file
View file

@ -0,0 +1,15 @@
#include "rect_to_sdl.hpp"
#include <cmath>
namespace curry {
SDL_Rect make_sdlrect (const Rect<float>& parOther) {
typedef decltype(std::declval<SDL_Rect>().w) ValueType;
return SDL_Rect{
static_cast<ValueType>(std::lround(parOther.left())),
static_cast<ValueType>(std::lround(parOther.top())),
static_cast<ValueType>(std::lround(parOther.width())),
static_cast<ValueType>(std::lround(parOther.height()))
};
}
} //namespace curry