Created
September 1, 2020 19:27
-
-
Save xeekworx/7581abb74d8932862f6b540bc77fd629 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <SDL.h> // Unnecessary if the source including this header already includes SDL.h | |
#include <cmath> // For round() | |
struct SDL_RectF { | |
float x, y, w, h; | |
operator SDL_Rect() | |
{ | |
return SDL_Rect{ | |
static_cast<int>(std::round(x)), | |
static_cast<int>(std::round(y)), | |
static_cast<int>(std::round(w)), | |
static_cast<int>(std::round(h)), | |
}; | |
} | |
}; | |
struct SDL_RectD { | |
double x, y, w, h; | |
operator SDL_Rect() | |
{ | |
return SDL_Rect{ | |
static_cast<int>(std::round(x)), | |
static_cast<int>(std::round(y)), | |
static_cast<int>(std::round(w)), | |
static_cast<int>(std::round(h)), | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment