Fix randomly happening floating point error during clipping.
This commit is contained in:
parent
e65c2341c2
commit
38826b94b8
4 changed files with 21 additions and 3 deletions
15
src/rect_to_sdl.cpp
Normal file
15
src/rect_to_sdl.cpp
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue