Refactoring in SDLMain.
This commit is contained in:
parent
4e3ad27ae8
commit
ccc831e34d
7 changed files with 34 additions and 13 deletions
|
@ -27,12 +27,27 @@ namespace cloonel {
|
|||
bool initialized;
|
||||
};
|
||||
|
||||
namespace {
|
||||
float2 GetScaling (ushort2 parRes, ushort2 parRef) __attribute__((pure));
|
||||
|
||||
///----------------------------------------------------------------------
|
||||
///----------------------------------------------------------------------
|
||||
float2 GetScaling (ushort2 parRes, ushort2 parRef) {
|
||||
return float2(
|
||||
static_cast<float>(parRes.x()) / static_cast<float>(parRef.x()),
|
||||
static_cast<float>(parRes.y()) / static_cast<float>(parRef.y())
|
||||
);
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
||||
///------------------------------------------------------------------------
|
||||
///------------------------------------------------------------------------
|
||||
SDLMain::SDLMain (const char* parGameName, int parWidth, int parHeight) :
|
||||
SDLMain::SDLMain (const char* parGameName, ushort2 parRes, ushort2 parReferenceRes) :
|
||||
m_gameName(parGameName),
|
||||
m_localData(new LocalData),
|
||||
m_defWH(parWidth, parHeight)
|
||||
m_WHScaling(GetScaling(parRes, parReferenceRes)),
|
||||
m_WH(parRes),
|
||||
m_WHRef(parReferenceRes)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,7 +75,7 @@ namespace cloonel {
|
|||
throw std::runtime_error(SDL_GetError());
|
||||
parInitSDL.initialized = true;
|
||||
|
||||
SDL_Window* const win = SDL_CreateWindow(m_gameName.c_str(), 100, 100, m_defWH.x(), m_defWH.y(), SDL_WINDOW_SHOWN);
|
||||
SDL_Window* const win = SDL_CreateWindow(m_gameName.c_str(), 100, 100, m_WH.x(), m_WH.y(), SDL_WINDOW_SHOWN);
|
||||
if (!win)
|
||||
throw std::runtime_error(SDL_GetError());
|
||||
parInitSDL.window = win;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue