[Scummvm-git-logs] scummvm master -> 936109fe4f20e08fe184a02177979181b3d065af

scemino noreply at scummvm.org
Fri May 3 18:25:45 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
936109fe4f BACKENDS: Update ImGui callbacks in OSystem and fix engines


Commit: 936109fe4f20e08fe184a02177979181b3d065af
    https://github.com/scummvm/scummvm/commit/936109fe4f20e08fe184a02177979181b3d065af
Author: scemino (scemino74 at gmail.com)
Date: 2024-05-03T20:25:01+02:00

Commit Message:
BACKENDS: Update ImGui callbacks in OSystem and fix engines

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 d40642aa77c..463ec7d133d 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -49,7 +49,7 @@ public:
 	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(ImGuiCallbacks callbacks) { }
+	virtual void setImGuiCallbacks(const ImGuiCallbacks &callbacks) { }
 #endif
 	virtual bool setShader(const Common::Path &fileName) { return false; }
 	virtual const OSystem::GraphicsMode *getSupportedStretchModes() const {
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index ad693010f9b..e38daca739e 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -208,7 +208,7 @@ private:
 
 #if defined(USE_IMGUI) && SDL_VERSION_ATLEAST(2, 0, 0)
 public:
-	void setImGuiRenderCallback(ImGuiCallbacks callbacks) override { _callbacks = callbacks; }
+	void setImGuiCallbacks(const ImGuiCallbacks &callbacks) override { _callbacks = callbacks; }
 
 protected:
 	ImGuiCallbacks _callbacks;
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index d4397f655e4..e8f27b60024 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -74,8 +74,8 @@ int ModularGraphicsBackend::getGraphicsMode() const {
 }
 
 #if defined(USE_IMGUI)
-void ModularGraphicsBackend::setImGuiRenderCallback(ImGuiCallbacks callbacks) {
-	_graphicsManager->setImGuiRenderCallback(callbacks);
+void ModularGraphicsBackend::setImGuiCallbacks(const ImGuiCallbacks &callbacks) {
+	_graphicsManager->setImGuiCallbacks(callbacks);
 }
 #endif
 
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index fedf4b35d5f..13ddb88f1c8 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -68,7 +68,7 @@ public:
 	bool setGraphicsMode(int mode, uint flags = kGfxModeNoFlags) override;
 	int getGraphicsMode() const override;
 #if defined(USE_IMGUI)
-	void setImGuiRenderCallback(ImGuiCallbacks callbacks) override final;
+	void setImGuiCallbacks(const ImGuiCallbacks &callbacks) override final;
 #endif
 	bool setShader(const Common::Path &name) override final;
 	const GraphicsMode *getSupportedStretchModes() const override final;
diff --git a/common/system.h b/common/system.h
index 3c6f7221cf0..94205fc082d 100644
--- a/common/system.h
+++ b/common/system.h
@@ -917,13 +917,13 @@ public:
 
 #if defined(USE_IMGUI)
 	/**
-	 * Set the address for ImGui rendering callback
+	 * Set the init/render/cleanup callbacks for ImGui.
 	 *
-	 * This is only supported on select backends desktop oriented
+	 * This is only supported on select backends desktop oriented.
 	 *
-	 * @param render The function pointer called while rendering on screen
+	 * @param callbacks Structure containing init/render/cleanup callbacks called on screen initialization, rendering and when deinitialized.
 	 */
-	virtual void setImGuiRenderCallback(ImGuiCallbacks callbacks) { }
+	virtual void setImGuiCallbacks(const ImGuiCallbacks &callbacks) {}
 #endif
 
 	/**
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index e5a3043c0a2..24bf25ddd91 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -290,8 +290,11 @@ Common::Error DirectorEngine::run() {
 	}
 
 #ifdef USE_IMGUI
-	onImGuiInit();
-	_system->setImGuiRenderCallback(onImGuiRender);
+	ImGuiCallbacks callbacks;
+	callbacks.init = onImGuiInit;
+	callbacks.render = onImGuiRender;
+	callbacks.cleanup = onImGuiCleanup;
+	_system->setImGuiCallbacks(callbacks);
 #endif
 
 	bool loop = true;
@@ -320,11 +323,6 @@ Common::Error DirectorEngine::run() {
 		g_director->delayMillis(10);
 	}
 
-#ifdef USE_IMGUI
-	_system->setImGuiRenderCallback(nullptr);
-	onImGuiCleanup();
-#endif
-
 	return Common::kNoError;
 }
 
diff --git a/engines/twp/twp.cpp b/engines/twp/twp.cpp
index 22043c48238..5bff288b697 100644
--- a/engines/twp/twp.cpp
+++ b/engines/twp/twp.cpp
@@ -873,8 +873,11 @@ Common::Error TwpEngine::run() {
 	updateSettingVars();
 
 #ifdef USE_IMGUI
-	onImGuiInit();
-	_system->setImGuiRenderCallback(onImGuiRender);
+	ImGuiCallbacks callbacks;
+	callbacks.init = onImGuiInit;
+	callbacks.render = onImGuiRender;
+	callbacks.cleanup = onImGuiCleanup;
+	_system->setImGuiCallbacks(callbacks);
 #endif
 
 	// Simple event handling loop
@@ -1101,11 +1104,6 @@ Common::Error TwpEngine::run() {
 		}
 	}
 
-#ifdef USE_IMGUI
-	_system->setImGuiRenderCallback(nullptr);
-	onImGuiCleanup();
-#endif
-
 	return Common::kNoError;
 }
 




More information about the Scummvm-git-logs mailing list