mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +00:00
fixes to window size management, fullscreen transition, etc
This commit is contained in:
parent
86cd7950ca
commit
a1f92433d8
5 changed files with 27 additions and 26 deletions
|
@ -156,6 +156,7 @@ void Core::setup_opengl()
|
|||
void Core::resizeWindow(int w, int h, int full, int bpp, int vsync, int display, int hz)
|
||||
{
|
||||
window->open(w, h, full, bpp, vsync, display, hz);
|
||||
window->updateSize();
|
||||
}
|
||||
|
||||
void Core::updateWindowDrawSize(int w, int h)
|
||||
|
@ -723,7 +724,7 @@ void Core::initGraphicsLibrary(int width, int height, bool fullscreen, bool vsyn
|
|||
|
||||
enumerateScreenModes(window->getDisplayIndex());
|
||||
|
||||
window->initSize();
|
||||
window->updateSize();
|
||||
cacheRender(); // Clears the window bg to black early; prevents flickering
|
||||
lib_graphics = true;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ void Window::onQuit()
|
|||
|
||||
void Window::setFullscreen(bool on)
|
||||
{
|
||||
if(_full != on)
|
||||
if(!!_full != on)
|
||||
open(-1, -1, on, -1, -1, -1, -1);
|
||||
}
|
||||
|
||||
|
@ -52,15 +52,17 @@ void Window::open(int w, int h, int full, int bpp, int vsync, int display, int h
|
|||
{
|
||||
_fixOpenParams(w, h, full, bpp, vsync, display, hz);
|
||||
|
||||
if(isOpen())
|
||||
_adjust(w, h, !!full, bpp, !!vsync, display, hz);
|
||||
else
|
||||
_open(w, h, !!full, bpp, !!vsync, display, hz);
|
||||
|
||||
_w = w;
|
||||
_h = h;
|
||||
_display = display;
|
||||
_bpp = bpp;
|
||||
_full = !!full;
|
||||
_vsync = !!vsync;
|
||||
|
||||
if(isOpen())
|
||||
_adjust(w, h, !!full, bpp, !!vsync, display, hz);
|
||||
else
|
||||
_open(w, h, !!full, bpp, !!vsync, display, hz);
|
||||
}
|
||||
|
||||
void Window::_fixOpenParams(int& w, int& h, int& full, int& bpp, int& vsync, int& display, int& hz)
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
int getDisplayIndex() const; // -1 on error/unsupported
|
||||
int getRefreshRate() const { return _hz; }
|
||||
void warpMouse(int x, int y);
|
||||
void initSize();
|
||||
void updateSize();
|
||||
|
||||
inline bool isFullscreen() const { return _full; }
|
||||
bool isOpen() const;
|
||||
|
|
|
@ -129,7 +129,7 @@ void Window::_onEventImpl(const SDL_Event& ev)
|
|||
}
|
||||
}
|
||||
|
||||
void Window::initSize()
|
||||
void Window::updateSize()
|
||||
{
|
||||
onResize(WIN->w, WIN->h);
|
||||
}
|
||||
|
|
|
@ -100,31 +100,29 @@ void Window::_adjust(unsigned w, unsigned h, bool full, unsigned bpp, bool vsync
|
|||
const bool useDesktop = w == 0 || h == 0;
|
||||
|
||||
SDL_DisplayMode displaymode;
|
||||
if(SDL_GetDesktopDisplayMode(display, &displaymode) != 0)
|
||||
if(useDesktop)
|
||||
{
|
||||
// fail-safe
|
||||
displaymode.w = 800;
|
||||
displaymode.h = 600;
|
||||
displaymode.driverdata = 0;
|
||||
displaymode.refresh_rate = 0;
|
||||
displaymode.format = 0;
|
||||
display = 0;
|
||||
if(SDL_GetDesktopDisplayMode(display, &displaymode) != 0)
|
||||
{
|
||||
// Failed to get this; use sane defaults
|
||||
displaymode.w = 800;
|
||||
displaymode.h = 600;
|
||||
displaymode.driverdata = 0;
|
||||
displaymode.refresh_rate = 0;
|
||||
displaymode.format = 0;
|
||||
display = 0;
|
||||
}
|
||||
w = displaymode.w;
|
||||
h = displaymode.h;
|
||||
}
|
||||
|
||||
setvsync(vsync);
|
||||
|
||||
if(useDesktop)
|
||||
{
|
||||
w = 800;
|
||||
h = 600;
|
||||
}
|
||||
|
||||
if(full)
|
||||
{
|
||||
int screenflags = useDesktop ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
|
||||
displaymode.w = w;
|
||||
displaymode.h = h;
|
||||
// must not be already in fullscreen here, otherwise new display mode doesn't apply properly
|
||||
SDL_SetWindowFullscreen(WIN, 0);
|
||||
SDL_SetWindowDisplayMode(WIN, &displaymode);
|
||||
SDL_SetWindowFullscreen(WIN, screenflags);
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ void Window::_adjust(unsigned w, unsigned h, bool full, unsigned bpp, bool vsync
|
|||
}
|
||||
}
|
||||
|
||||
void Window::initSize()
|
||||
void Window::updateSize()
|
||||
{
|
||||
int ww, hh;
|
||||
SDL_GetWindowSize(WIN, &ww, &hh);
|
||||
|
|
Loading…
Reference in a new issue