[Scummvm-git-logs] scummvm master -> 989acab7b2adfac7eb04961ed8bcf1436b78502e
sev-
noreply at scummvm.org
Sun Apr 28 19:48:16 UTC 2024
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3822d9d644 BACKENDS: Move setImGuiRenderCallback in OSystem and hide implementation
e6a7d6bc9b OPENGLSDL: Don't compile code when not on SDL 2.0
7a4f6aa2af OPENGLSDL3D: Make ImGui init and deinit variableless
a04fe8ef2f OPENGL: Don't always force redraw when ImGui is enabled
989acab7b2 IMGUI: Only enable ImGui on SDL2
Commit: 3822d9d644436d7c603313aa2cf09303bfb321d1
https://github.com/scummvm/scummvm/commit/3822d9d644436d7c603313aa2cf09303bfb321d1
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-04-28T21:48:10+02:00
Commit Message:
BACKENDS: Move setImGuiRenderCallback in OSystem and hide implementation
This avoids dynamic casts and having a variable defined in
backends not supporting ImGui
Changed paths:
backends/graphics/graphics.h
backends/graphics/sdl/sdl-graphics.h
backends/modular-backend.cpp
backends/modular-backend.h
common/system.h
engines/director/director.cpp
engines/twp/twp.cpp
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index 2d5de6c5beb..91e57d83b3c 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -48,6 +48,9 @@ public:
virtual int getDefaultGraphicsMode() const { return 0; }
virtual bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) { return (mode == 0); }
virtual int getGraphicsMode() const { return 0; }
+#if defined(USE_IMGUI)
+ virtual void setImGuiRenderCallback(void(*render)()) { }
+#endif
virtual bool setShader(const Common::Path &fileName) { return false; }
virtual const OSystem::GraphicsMode *getSupportedStretchModes() const {
static const OSystem::GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
@@ -113,11 +116,6 @@ public:
virtual void saveScreenshot() {}
virtual bool lockMouse(bool lock) { return false; }
-
- virtual void setImGuiRenderCallback(void(*render)()) { _imGuiRender = render; }
-
-protected:
- void(*_imGuiRender)() = nullptr;
};
#endif
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index a846c500ab4..7ecb516c18a 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -205,6 +205,15 @@ protected:
private:
void toggleFullScreen();
+
+#if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
+public:
+ void setImGuiRenderCallback(void(*render)()) override { _imGuiRender = render; }
+
+protected:
+ void(*_imGuiRender)() = nullptr;
+#endif
+
};
#endif
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index 9cc446c6705..dfbe88b44e4 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -73,6 +73,12 @@ int ModularGraphicsBackend::getGraphicsMode() const {
return _graphicsManager->getGraphicsMode();
}
+#if defined(USE_IMGUI)
+void ModularGraphicsBackend::setImGuiRenderCallback(void(*render)()) {
+ _graphicsManager->setImGuiRenderCallback(render);
+}
+#endif
+
bool ModularGraphicsBackend::setShader(const Common::Path &fileName) {
return _graphicsManager->setShader(fileName);
}
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 3231ffc3407..033759d6347 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -67,6 +67,9 @@ public:
int getDefaultGraphicsMode() const override;
bool setGraphicsMode(int mode, uint flags = kGfxModeNoFlags) override;
int getGraphicsMode() const override;
+#if defined(USE_IMGUI)
+ void setImGuiRenderCallback(void(*render)()) override final;
+#endif
bool setShader(const Common::Path &name) override final;
const GraphicsMode *getSupportedStretchModes() const override final;
int getDefaultStretchMode() const override final;
diff --git a/common/system.h b/common/system.h
index 7849c1db19d..f67e056d649 100644
--- a/common/system.h
+++ b/common/system.h
@@ -907,6 +907,17 @@ public:
virtual void *getOpenGLProcAddress(const char *name) const { return nullptr; }
#endif
+#if defined(USE_IMGUI)
+ /**
+ * Set the address for ImGui rendering callback
+ *
+ * This is only supported on select backends desktop oriented
+ *
+ * @param render The function pointer called while rendering on screen
+ */
+ virtual void setImGuiRenderCallback(void(*render)()) { }
+#endif
+
/**
* Load the specified shader.
*
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 940f38086a8..e5a3043c0a2 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -291,10 +291,7 @@ Common::Error DirectorEngine::run() {
#ifdef USE_IMGUI
onImGuiInit();
- ModularGraphicsBackend *gfxBackend = dynamic_cast<ModularGraphicsBackend *>(_system);
- if (gfxBackend) {
- gfxBackend->getGraphicsManager()->setImGuiRenderCallback(onImGuiRender);
- }
+ _system->setImGuiRenderCallback(onImGuiRender);
#endif
bool loop = true;
@@ -324,6 +321,7 @@ Common::Error DirectorEngine::run() {
}
#ifdef USE_IMGUI
+ _system->setImGuiRenderCallback(nullptr);
onImGuiCleanup();
#endif
diff --git a/engines/twp/twp.cpp b/engines/twp/twp.cpp
index bc6c69e962e..22043c48238 100644
--- a/engines/twp/twp.cpp
+++ b/engines/twp/twp.cpp
@@ -874,10 +874,7 @@ Common::Error TwpEngine::run() {
#ifdef USE_IMGUI
onImGuiInit();
- ModularGraphicsBackend *gfxBackend = dynamic_cast<ModularGraphicsBackend *>(_system);
- if (gfxBackend) {
- gfxBackend->getGraphicsManager()->setImGuiRenderCallback(onImGuiRender);
- }
+ _system->setImGuiRenderCallback(onImGuiRender);
#endif
// Simple event handling loop
@@ -1105,6 +1102,7 @@ Common::Error TwpEngine::run() {
}
#ifdef USE_IMGUI
+ _system->setImGuiRenderCallback(nullptr);
onImGuiCleanup();
#endif
Commit: e6a7d6bc9b93b9b36a824dc8dc80a4d0e0494079
https://github.com/scummvm/scummvm/commit/e6a7d6bc9b93b9b36a824dc8dc80a4d0e0494079
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-04-28T21:48:10+02:00
Commit Message:
OPENGLSDL: Don't compile code when not on SDL 2.0
Changed paths:
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 7e0f04c84a9..e60ec704daf 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -458,7 +458,7 @@ void OpenGLSdlGraphicsManager::refreshScreen() {
}
#endif
-#ifdef USE_IMGUI
+#if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
if(_imGuiRender) {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame(_window->getSDLWindow());
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
index 0361fe810a6..454238360f4 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
@@ -689,7 +689,7 @@ void OpenGLSdlGraphics3dManager::updateScreen() {
}
#endif
-#ifdef USE_IMGUI
+#if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
if (_imGuiRender) {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame(_window->getSDLWindow());
Commit: 7a4f6aa2afe245962590708c227a44171ea83772
https://github.com/scummvm/scummvm/commit/7a4f6aa2afe245962590708c227a44171ea83772
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-04-28T21:48:10+02:00
Commit Message:
OPENGLSDL3D: Make ImGui init and deinit variableless
It is inited only when context is created and deinited when it is
destroyed
Changed paths:
backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
backends/graphics3d/openglsdl/openglsdl-graphics3d.h
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
index 454238360f4..e0e549266b2 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
@@ -150,12 +150,6 @@ OpenGLSdlGraphics3dManager::OpenGLSdlGraphics3dManager(SdlEventSource *eventSour
}
OpenGLSdlGraphics3dManager::~OpenGLSdlGraphics3dManager() {
-#if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
- ImGui_ImplOpenGL3_Shutdown();
- ImGui_ImplSDL2_Shutdown();
- ImGui::DestroyContext();
-#endif
-
closeOverlay();
#if SDL_VERSION_ATLEAST(2, 0, 0)
deinitializeRenderer();
@@ -333,9 +327,7 @@ void OpenGLSdlGraphics3dManager::setupScreen() {
}
}
- // Clear the GL context when going from / to the launcher
- SDL_GL_DeleteContext(_glContext);
- _glContext = nullptr;
+ deinitializeRenderer();
if (needsWindowReset) {
_window->destroyWindow();
@@ -473,19 +465,6 @@ void OpenGLSdlGraphics3dManager::initializeOpenGLContext() const {
if (SDL_GL_SetSwapInterval(_vsync ? 1 : 0)) {
warning("Unable to %s VSync: %s", _vsync ? "enable" : "disable", SDL_GetError());
}
-
-#ifdef USE_IMGUI
- if (!_imguiInit) {
- // Setup Dear ImGui
- IMGUI_CHECKVERSION();
- ImGui::CreateContext();
- ImGui_ImplSDL2_InitForOpenGL(_window->getSDLWindow(), _glContext);
- ImGui_ImplOpenGL3_Init("#version 110");
- ImGui::StyleColorsDark();
- ImGuiIO &io = ImGui::GetIO();
- io.IniFilename = nullptr;
- }
-#endif
#endif
}
@@ -577,6 +556,17 @@ bool OpenGLSdlGraphics3dManager::createOrUpdateGLContext(uint gameWidth, uint ga
_glContext = SDL_GL_CreateContext(_window->getSDLWindow());
if (_glContext) {
clear = true;
+
+#ifdef USE_IMGUI
+ // Setup Dear ImGui
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+ ImGui_ImplSDL2_InitForOpenGL(_window->getSDLWindow(), _glContext);
+ ImGui_ImplOpenGL3_Init("#version 110");
+ ImGui::StyleColorsDark();
+ ImGuiIO &io = ImGui::GetIO();
+ io.IniFilename = nullptr;
+#endif
}
}
@@ -615,9 +605,6 @@ bool OpenGLSdlGraphics3dManager::createOrUpdateGLContext(uint gameWidth, uint ga
return false;
initializeOpenGLContext();
-#if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
- _imguiInit = true;
-#endif
if (clear)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -832,6 +819,14 @@ void OpenGLSdlGraphics3dManager::showSystemMouseCursor(bool visible) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
void OpenGLSdlGraphics3dManager::deinitializeRenderer() {
+#ifdef USE_IMGUI
+ if (_glContext) {
+ ImGui_ImplOpenGL3_Shutdown();
+ ImGui_ImplSDL2_Shutdown();
+ ImGui::DestroyContext();
+ }
+#endif
+
SDL_GL_DeleteContext(_glContext);
_glContext = nullptr;
}
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
index 8ccaee2c86b..7c633fbef75 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
@@ -120,7 +120,6 @@ protected:
int _glContextProfileMask, _glContextMajor, _glContextMinor;
SDL_GLContext _glContext;
void deinitializeRenderer();
- bool _imguiInit = false;
#endif
OpenGL::ContextType _glContextType;
Commit: a04fe8ef2fcec83e1c43640154790d98e622848c
https://github.com/scummvm/scummvm/commit/a04fe8ef2fcec83e1c43640154790d98e622848c
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-04-28T21:48:10+02:00
Commit Message:
OPENGL: Don't always force redraw when ImGui is enabled
Only do it when ImGui is enabled by the engine and move the check in SDL
backend where ImGui is supported.
This makes the OpenGL backend independent of ImGui.
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/openglsdl/openglsdl-graphics.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index ed867af71b1..0829dc439f9 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -665,9 +665,7 @@ void OpenGLGraphicsManager::updateScreen() {
&& !_osdMessageSurface && !_osdIconSurface
#endif
) {
-#if !defined(USE_IMGUI)
return;
-#endif
}
// Update changes to textures.
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index e60ec704daf..ff9f636d007 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -305,6 +305,12 @@ void OpenGLSdlGraphicsManager::updateScreen() {
--_ignoreResizeEvents;
}
+#if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
+ if (_imGuiRender) {
+ _forceRedraw = true;
+ }
+#endif
+
OpenGLGraphicsManager::updateScreen();
}
Commit: 989acab7b2adfac7eb04961ed8bcf1436b78502e
https://github.com/scummvm/scummvm/commit/989acab7b2adfac7eb04961ed8bcf1436b78502e
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-04-28T21:48:10+02:00
Commit Message:
IMGUI: Only enable ImGui on SDL2
Changed paths:
configure
diff --git a/configure b/configure
index 3702572eaf9..d48e53fa236 100755
--- a/configure
+++ b/configure
@@ -6775,12 +6775,31 @@ echo "$_discord"
#
echocheck "ImGui"
-if test "$_opengl" = yes ; then
- define_in_config_if_yes "$_imgui" 'USE_IMGUI'
- echo "$_imgui"
+if test "$_imgui" != no ; then
+ if test "$_opengl" = yes ; then
+ case $_backend in
+ sdl)
+ if test "$_sdlMajorVersionNumber" -ge 2 ; then
+ _imgui=yes
+ echo "yes"
+ else
+ _imgui=no
+ echo "no (backend unsupported)"
+ fi
+ ;;
+ *)
+ # For now, only SDL supports ImGui
+ _imgui=no
+ echo "no (backend unsupported)"
+ ;;
+ esac
+ else
+ echo "no (requires OpenGL)"
+ fi
else
- echo "no (requires OpenGL)"
+ echo "$_imgui"
fi
+define_in_config_if_yes "$_imgui" 'USE_IMGUI'
#
# Enable vkeybd / event recorder
More information about the Scummvm-git-logs
mailing list