mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Add ability to configure which renderers are used by love.graphics.
- Add t.renderers and t.excluderenderers love.conf fields. They can be an array of renderer names. - Add --renderers a,list,of,renderernames and --excluderenderers more,renderers argument options.
This commit is contained in:
@@ -295,7 +295,7 @@ std::vector<Window::ContextAttribs> Window::getContextAttribsList() const
|
||||
return attribslist;
|
||||
}
|
||||
|
||||
bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, graphics::Graphics::Renderer renderer)
|
||||
bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, graphics::Renderer renderer)
|
||||
{
|
||||
bool needsglcontext = (windowflags & SDL_WINDOW_OPENGL) != 0;
|
||||
#ifdef LOVE_GRAPHICS_METAL
|
||||
@@ -368,7 +368,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
||||
return true;
|
||||
};
|
||||
|
||||
if (renderer == graphics::Graphics::RENDERER_OPENGL)
|
||||
if (renderer == graphics::RENDERER_OPENGL)
|
||||
{
|
||||
std::vector<ContextAttribs> attribslist = getContextAttribsList();
|
||||
|
||||
@@ -404,7 +404,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
||||
}
|
||||
}
|
||||
#ifdef LOVE_GRAPHICS_METAL
|
||||
else if (renderer == graphics::Graphics::RENDERER_METAL)
|
||||
else if (renderer == graphics::RENDERER_METAL)
|
||||
{
|
||||
if (create(nullptr) && window != nullptr)
|
||||
metalView = SDL_Metal_CreateView(window);
|
||||
@@ -465,7 +465,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
if (graphics.get() && graphics->isRenderTargetActive())
|
||||
throw love::Exception("love.window.setMode cannot be called while a render target is active in love.graphics.");
|
||||
|
||||
auto renderer = graphics != nullptr ? graphics->getRenderer() : graphics::Graphics::RENDERER_NONE;
|
||||
auto renderer = graphics != nullptr ? graphics->getRenderer() : graphics::RENDERER_NONE;
|
||||
|
||||
if (isOpen())
|
||||
updateSettings(this->settings, false);
|
||||
@@ -557,7 +557,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
|
||||
if (isOpen())
|
||||
{
|
||||
if (SDL_SetWindowFullscreen(window, sdlflags) == 0 && renderer == graphics::Graphics::RENDERER_OPENGL)
|
||||
if (SDL_SetWindowFullscreen(window, sdlflags) == 0 && renderer == graphics::RENDERER_OPENGL)
|
||||
SDL_GL_MakeCurrent(window, glcontext);
|
||||
|
||||
if (!f.fullscreen)
|
||||
@@ -575,11 +575,11 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (renderer == graphics::Graphics::RENDERER_OPENGL)
|
||||
if (renderer == graphics::RENDERER_OPENGL)
|
||||
sdlflags |= SDL_WINDOW_OPENGL;
|
||||
|
||||
#ifdef LOVE_GRAPHICS_METAL
|
||||
if (renderer == graphics::Graphics::RENDERER_METAL)
|
||||
if (renderer == graphics::RENDERER_METAL)
|
||||
sdlflags |= SDL_WINDOW_METAL;
|
||||
#endif
|
||||
|
||||
@@ -626,10 +626,10 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
if (needsetmode)
|
||||
{
|
||||
void *context = nullptr;
|
||||
if (renderer == graphics::Graphics::RENDERER_OPENGL)
|
||||
if (renderer == graphics::RENDERER_OPENGL)
|
||||
context = (void *) glcontext;
|
||||
#ifdef LOVE_GRAPHICS_METAL
|
||||
if (renderer == graphics::Graphics::RENDERER_METAL && metalView)
|
||||
if (renderer == graphics::RENDERER_METAL && metalView)
|
||||
context = (void *) SDL_Metal_GetLayer(metalView);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ private:
|
||||
void setGLContextAttributes(const ContextAttribs &attribs);
|
||||
bool checkGLVersion(const ContextAttribs &attribs, std::string &outversion);
|
||||
std::vector<ContextAttribs> getContextAttribsList() const;
|
||||
bool createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, graphics::Graphics::Renderer renderer);
|
||||
bool createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, graphics::Renderer renderer);
|
||||
|
||||
// Update the saved window settings based on the window's actual state.
|
||||
void updateSettings(const WindowSettings &newsettings, bool updateGraphicsViewport);
|
||||
@@ -172,7 +172,7 @@ private:
|
||||
SDL_MetalView metalView;
|
||||
#endif
|
||||
|
||||
graphics::Graphics::Renderer windowRenderer = graphics::Graphics::RENDERER_NONE;
|
||||
graphics::Renderer windowRenderer = graphics::RENDERER_NONE;
|
||||
|
||||
bool displayedWindowError;
|
||||
bool hasSDL203orEarlier;
|
||||
|
||||
Reference in New Issue
Block a user