Fixed double ImGuiLayer

This commit is contained in:
Simon Lübeß
2020-11-17 11:58:46 +01:00
parent 9b2d32d43b
commit 6211655041
5 changed files with 29 additions and 6 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ namespace GlitchyEngine
_window.EventCallback = new => OnEvent;
_imGuiLayer = new ImGuiLayer();
PushLayer(_imGuiLayer);
PushOverlay(_imGuiLayer);
}
public void OnEvent(Event e)
+7 -2
View File
@@ -13,6 +13,7 @@ namespace GlitchyEngine.ImGui
public override void OnAttach()
{
ImGuiImplWin32.EnableDpiAwareness();
Log.EngineLogger.Trace("Initializing ImGui...");
ImGui.CHECKVERSION();
@@ -24,8 +25,12 @@ namespace GlitchyEngine.ImGui
io.ConfigFlags |= .DockingEnable;
io.ConfigFlags |= .ViewportsEnable;
ref ImGui.Style style = ref ImGui.GetStyle();
// Todo: currently broken in ImGui
//io.ConfigFlags |= .DpiEnableScaleFonts;
//io.ConfigFlags |= .DpiEnableScaleViewports;
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ref ImGui.Style style = ref ImGui.GetStyle();
if(io.ConfigFlags.HasFlag(.ViewportsEnable))
{
style.WindowRounding = 0.0f;
@@ -36,8 +41,8 @@ namespace GlitchyEngine.ImGui
#if GE_WINDOWS
// Todo: temporary, needs to be platform independent
ImGuiImplDX11.Init(Platform.DX11.DirectX.Device, Platform.DX11.DirectX.ImmediateContext);
ImGuiImplWin32.Init((Windows.HWnd)(int)Application.Get().Window.NativeWindow);
ImGuiImplDX11.Init(Platform.DX11.DirectX.Device, Platform.DX11.DirectX.ImmediateContext);
#endif
}
+10 -1
View File
@@ -4,7 +4,16 @@ namespace GlitchyEngine
{
public class LayerStack
{
private List<Layer> _layers = new List<Layer>() ~ DeleteContainerAndItems!(_);
private List<Layer> _layers = new List<Layer>() ~ delete _;
public ~this()
{
for(let layer in _layers)
{
layer.OnDetach();
delete layer;
}
}
/*
* Marks the index of the last layer.
@@ -16,6 +16,8 @@ namespace GlitchyEngine
/// The windows specific Window implementation
public extension Window
{
const String WindowClassName = "GlitchyEngineWindow";
private Windows.HInstance _instanceHandle;
private Windows.HWnd _windowHandle;
@@ -152,6 +154,14 @@ namespace GlitchyEngine
Init(desc);
}
[LinkName("UnregisterClassW")]
static extern Windows.IntBool UnregisterClass(char16* className, Windows.HInstance hInstance);
public ~this()
{
UnregisterClass(WindowClassName.ToScopedNativeWChar!(), _instanceHandle);
}
private void Init(WindowDescription desc)
{
@@ -171,7 +181,7 @@ namespace GlitchyEngine
_windowClass.Cursor = LoadCursorW(0, IDC_ARROW);
_windowClass.BackgroundBrush = (HBRUSH)SystemColor.WindowFrame;
_windowClass.ClassName = "GlitchyEngineWindow".ToScopedNativeWChar!();
_windowClass.ClassName = WindowClassName.ToScopedNativeWChar!();
if (RegisterClassExW(ref _windowClass) == 0)
{