mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Use a flags table for setMode now, implement resizable and borderless windows, and add resize event
Example setMode invocation: love.graphics.setMode(800, 600, {fullscreen = false, vsync = true, borderless = true})
t.screen.resizable and t.screen.borderless are available in love.conf
And love.resize(w, h) gets called if it exists on a resize event.
NOTE: love.handlers.resize(w, h) does the required setMode, but that does mean a visual reload
--HG--
branch : minor
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
using love::window::WindowFlags;
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
@@ -105,7 +107,7 @@ void Graphics::restoreState(const DisplayState &s)
|
||||
setScissor();
|
||||
}
|
||||
|
||||
bool Graphics::setMode(int width, int height, bool fullscreen, bool vsync, int fsaa)
|
||||
bool Graphics::setMode(int width, int height, WindowFlags *flags)
|
||||
{
|
||||
// This operation destroys the OpenGL context, so
|
||||
// we must save the state.
|
||||
@@ -117,7 +119,7 @@ bool Graphics::setMode(int width, int height, bool fullscreen, bool vsync, int f
|
||||
// the display mode change.
|
||||
Volatile::unloadAll();
|
||||
|
||||
bool success = currentWindow->setWindow(width, height, fullscreen, vsync, fsaa);
|
||||
bool success = currentWindow->setWindow(width, height, flags);
|
||||
// Regardless of failure, we'll have to set up OpenGL once again.
|
||||
|
||||
width = currentWindow->getWidth();
|
||||
@@ -171,17 +173,18 @@ bool Graphics::setMode(int width, int height, bool fullscreen, bool vsync, int f
|
||||
return success;
|
||||
}
|
||||
|
||||
void Graphics::getMode(int &width, int &height, bool &fullscreen, bool &vsync, int &fsaa)
|
||||
void Graphics::getMode(int &width, int &height, WindowFlags &flags)
|
||||
{
|
||||
currentWindow->getWindow(width, height, fullscreen, vsync, fsaa);
|
||||
currentWindow->getWindow(width, height, flags);
|
||||
}
|
||||
|
||||
bool Graphics::toggleFullscreen()
|
||||
{
|
||||
int width, height, fsaa;
|
||||
bool fullscreen, vsync;
|
||||
currentWindow->getWindow(width, height, fullscreen, vsync, fsaa);
|
||||
return setMode(width, height, !fullscreen, vsync, fsaa);
|
||||
int width, height;
|
||||
WindowFlags flags;
|
||||
currentWindow->getWindow(width, height, flags);
|
||||
flags.fullscreen = !flags.fullscreen;
|
||||
return setMode(width, height, &flags);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user