From fb9bbdd12319b28b6f557354077993eb55734780 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 28 May 2020 10:19:38 -0500 Subject: [PATCH] Added more OpenGL delegates, and restructured game manager. Largely untested. --- .../Graphics/OpenGL/GLFunctionDelegates.cs | 3 +++ src/SlatedGameToolkit.Framework/StateSystem/Manager.cs | 2 +- .../StateSystem/States/IState.cs | 8 +++++++- .../Utilities/GraphicalPlayground/MainState.cs | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/SlatedGameToolkit.Framework/Graphics/OpenGL/GLFunctionDelegates.cs b/src/SlatedGameToolkit.Framework/Graphics/OpenGL/GLFunctionDelegates.cs index 8175ee6..0f9c76b 100644 --- a/src/SlatedGameToolkit.Framework/Graphics/OpenGL/GLFunctionDelegates.cs +++ b/src/SlatedGameToolkit.Framework/Graphics/OpenGL/GLFunctionDelegates.cs @@ -10,5 +10,8 @@ namespace SlatedGameToolkit.Framework.Graphics.OpenGL internal delegate void GLCompileShader(IntPtr shaderHandle); internal delegate void GLGetShaderLogInfo(IntPtr shaderHandle, int maxLength, out int writtenLength, out string output); internal delegate IntPtr GLCreateProgram(); + internal delegate IntPtr GLDeleteProgram(); internal delegate void GLAttachShader(IntPtr program, IntPtr shader); + internal delegate void GLDetachShader(IntPtr program, IntPtr shader); + internal delegate void GLDeleteShader(IntPtr shader); } \ No newline at end of file diff --git a/src/SlatedGameToolkit.Framework/StateSystem/Manager.cs b/src/SlatedGameToolkit.Framework/StateSystem/Manager.cs index e479279..606cccd 100644 --- a/src/SlatedGameToolkit.Framework/StateSystem/Manager.cs +++ b/src/SlatedGameToolkit.Framework/StateSystem/Manager.cs @@ -111,7 +111,7 @@ namespace SlatedGameToolkit.Framework.StateSystem if (states[name] == currentState) return false; IState state = states[name]; GameEngine.Logger.Debug("Removing state: " + name); - state.Dispose(); + state.Deinitialize(); return states.Remove(name); } diff --git a/src/SlatedGameToolkit.Framework/StateSystem/States/IState.cs b/src/SlatedGameToolkit.Framework/StateSystem/States/IState.cs index 2744be5..1cdc29b 100644 --- a/src/SlatedGameToolkit.Framework/StateSystem/States/IState.cs +++ b/src/SlatedGameToolkit.Framework/StateSystem/States/IState.cs @@ -3,7 +3,7 @@ using SlatedGameToolkit.Framework.Graphics.Window; namespace SlatedGameToolkit.Framework.StateSystem.States { - public interface IState : IDisposable + public interface IState { WindowHandle CurrentWindow { get; } @@ -55,5 +55,11 @@ namespace SlatedGameToolkit.Framework.StateSystem.States /// /// A string representing the name of this state. string getName(); + + /// + /// Called when this state is being removed from the manager, and likely not used again in this games life cycle. + /// Any unmanaged resources that needs to be disposed of should be done so here. + /// + void Deinitialize(); } } \ No newline at end of file diff --git a/src/SlatedGameToolkit.Tools/Utilities/GraphicalPlayground/MainState.cs b/src/SlatedGameToolkit.Tools/Utilities/GraphicalPlayground/MainState.cs index 9b02a5d..bca2537 100644 --- a/src/SlatedGameToolkit.Tools/Utilities/GraphicalPlayground/MainState.cs +++ b/src/SlatedGameToolkit.Tools/Utilities/GraphicalPlayground/MainState.cs @@ -22,7 +22,7 @@ namespace SlatedGameToolkit.Tools.Utilities.GraphicalPlayground return true; } - public void Dispose() + public void Deinitialize() { window.Dispose(); }