mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-09 13:24:01 +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)
|
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->open(w, h, full, bpp, vsync, display, hz);
|
||||||
|
window->updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::updateWindowDrawSize(int w, int h)
|
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());
|
enumerateScreenModes(window->getDisplayIndex());
|
||||||
|
|
||||||
window->initSize();
|
window->updateSize();
|
||||||
cacheRender(); // Clears the window bg to black early; prevents flickering
|
cacheRender(); // Clears the window bg to black early; prevents flickering
|
||||||
lib_graphics = true;
|
lib_graphics = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ void Window::onQuit()
|
||||||
|
|
||||||
void Window::setFullscreen(bool on)
|
void Window::setFullscreen(bool on)
|
||||||
{
|
{
|
||||||
if(_full != on)
|
if(!!_full != on)
|
||||||
open(-1, -1, on, -1, -1, -1, -1);
|
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);
|
_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;
|
_w = w;
|
||||||
_h = h;
|
_h = h;
|
||||||
_display = display;
|
_display = display;
|
||||||
_bpp = bpp;
|
_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)
|
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 getDisplayIndex() const; // -1 on error/unsupported
|
||||||
int getRefreshRate() const { return _hz; }
|
int getRefreshRate() const { return _hz; }
|
||||||
void warpMouse(int x, int y);
|
void warpMouse(int x, int y);
|
||||||
void initSize();
|
void updateSize();
|
||||||
|
|
||||||
inline bool isFullscreen() const { return _full; }
|
inline bool isFullscreen() const { return _full; }
|
||||||
bool isOpen() const;
|
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);
|
onResize(WIN->w, WIN->h);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,9 +100,11 @@ void Window::_adjust(unsigned w, unsigned h, bool full, unsigned bpp, bool vsync
|
||||||
const bool useDesktop = w == 0 || h == 0;
|
const bool useDesktop = w == 0 || h == 0;
|
||||||
|
|
||||||
SDL_DisplayMode displaymode;
|
SDL_DisplayMode displaymode;
|
||||||
|
if(useDesktop)
|
||||||
|
{
|
||||||
if(SDL_GetDesktopDisplayMode(display, &displaymode) != 0)
|
if(SDL_GetDesktopDisplayMode(display, &displaymode) != 0)
|
||||||
{
|
{
|
||||||
// fail-safe
|
// Failed to get this; use sane defaults
|
||||||
displaymode.w = 800;
|
displaymode.w = 800;
|
||||||
displaymode.h = 600;
|
displaymode.h = 600;
|
||||||
displaymode.driverdata = 0;
|
displaymode.driverdata = 0;
|
||||||
|
@ -110,21 +112,17 @@ void Window::_adjust(unsigned w, unsigned h, bool full, unsigned bpp, bool vsync
|
||||||
displaymode.format = 0;
|
displaymode.format = 0;
|
||||||
display = 0;
|
display = 0;
|
||||||
}
|
}
|
||||||
|
w = displaymode.w;
|
||||||
|
h = displaymode.h;
|
||||||
|
}
|
||||||
|
|
||||||
setvsync(vsync);
|
setvsync(vsync);
|
||||||
|
|
||||||
if(useDesktop)
|
|
||||||
{
|
|
||||||
w = 800;
|
|
||||||
h = 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(full)
|
if(full)
|
||||||
{
|
{
|
||||||
int screenflags = useDesktop ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
|
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
|
// must not be already in fullscreen here, otherwise new display mode doesn't apply properly
|
||||||
|
SDL_SetWindowFullscreen(WIN, 0);
|
||||||
SDL_SetWindowDisplayMode(WIN, &displaymode);
|
SDL_SetWindowDisplayMode(WIN, &displaymode);
|
||||||
SDL_SetWindowFullscreen(WIN, screenflags);
|
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;
|
int ww, hh;
|
||||||
SDL_GetWindowSize(WIN, &ww, &hh);
|
SDL_GetWindowSize(WIN, &ww, &hh);
|
||||||
|
|
Loading…
Add table
Reference in a new issue