mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Fixed double ImGuiLayer
This commit is contained in:
@@ -33,7 +33,7 @@ namespace GlitchyEngine
|
||||
_window.EventCallback = new => OnEvent;
|
||||
|
||||
_imGuiLayer = new ImGuiLayer();
|
||||
PushLayer(_imGuiLayer);
|
||||
PushOverlay(_imGuiLayer);
|
||||
}
|
||||
|
||||
public void OnEvent(Event e)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -153,6 +155,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)
|
||||
{
|
||||
Log.EngineLogger.Trace("Creating window \"{}\" ({}, {})...", desc.Title, desc.Width, desc.Height);
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace Sandbox
|
||||
public this()
|
||||
{
|
||||
PushLayer(new ExampleLayer());
|
||||
PushOverlay(new ImGuiLayer());
|
||||
}
|
||||
|
||||
[Export, LinkName("CreateApplication")]
|
||||
|
||||
Reference in New Issue
Block a user