mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
Fix initializing the graphics module after a window is opened.
This commit is contained in:
@@ -361,18 +361,13 @@ Graphics::Graphics()
|
|||||||
{
|
{
|
||||||
window->setGraphics(this);
|
window->setGraphics(this);
|
||||||
|
|
||||||
|
// Recreate the window using the current renderer, if needed.
|
||||||
if (window->isOpen())
|
if (window->isOpen())
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
love::window::WindowSettings settings;
|
love::window::WindowSettings settings;
|
||||||
window->getWindow(w, h, settings);
|
window->getWindow(w, h, settings);
|
||||||
|
window->setWindow(w, h, &settings);
|
||||||
double dpiW = w;
|
|
||||||
double dpiH = h;
|
|
||||||
window->windowToDPICoords(&dpiW, &dpiH);
|
|
||||||
|
|
||||||
void *context = nullptr; // TODO
|
|
||||||
setMode(context, (int) dpiW, (int) dpiH, window->getPixelWidth(), window->getPixelHeight(), settings.stencil, settings.depth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -131,18 +131,13 @@ Graphics::Graphics()
|
|||||||
{
|
{
|
||||||
window->setGraphics(this);
|
window->setGraphics(this);
|
||||||
|
|
||||||
|
// Recreate the window using the current renderer, if needed.
|
||||||
if (window->isOpen())
|
if (window->isOpen())
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
love::window::WindowSettings s;
|
love::window::WindowSettings settings;
|
||||||
window->getWindow(w, h, s);
|
window->getWindow(w, h, settings);
|
||||||
|
window->setWindow(w, h, &settings);
|
||||||
double dpiW = w;
|
|
||||||
double dpiH = h;
|
|
||||||
window->windowToDPICoords(&dpiW, &dpiH);
|
|
||||||
|
|
||||||
void *context = nullptr; // TODO
|
|
||||||
setMode(context, (int) dpiW, (int) dpiH, window->getPixelWidth(), window->getPixelHeight(), s.stencil, s.msaa);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -552,6 +552,9 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (renderer != windowRenderer && isOpen())
|
||||||
|
close();
|
||||||
|
|
||||||
if (isOpen())
|
if (isOpen())
|
||||||
{
|
{
|
||||||
if (SDL_SetWindowFullscreen(window, sdlflags) == 0 && renderer == graphics::Graphics::RENDERER_OPENGL)
|
if (SDL_SetWindowFullscreen(window, sdlflags) == 0 && renderer == graphics::Graphics::RENDERER_OPENGL)
|
||||||
@@ -613,6 +616,8 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|||||||
|
|
||||||
updateSettings(f, false);
|
updateSettings(f, false);
|
||||||
|
|
||||||
|
windowRenderer = renderer;
|
||||||
|
|
||||||
if (graphics.get())
|
if (graphics.get())
|
||||||
{
|
{
|
||||||
double scaledw, scaledh;
|
double scaledw, scaledh;
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ private:
|
|||||||
SDL_MetalView metalView;
|
SDL_MetalView metalView;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
graphics::Graphics::Renderer windowRenderer = graphics::Graphics::RENDERER_NONE;
|
||||||
|
|
||||||
bool displayedWindowError;
|
bool displayedWindowError;
|
||||||
bool hasSDL203orEarlier;
|
bool hasSDL203orEarlier;
|
||||||
ContextAttribs contextAttribs;
|
ContextAttribs contextAttribs;
|
||||||
|
|||||||
Reference in New Issue
Block a user