Reimplementing DearImGui

This commit is contained in:
2025-03-22 01:04:15 +01:00
parent dfa5d1245f
commit 9a8ab7853a
8 changed files with 768 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ Engine_Core :: struct {
#if EDITOR {
editor: Editor;
imgui_context: *ImGui.ImGuiContext;
}
window: *Window;
@@ -68,6 +69,7 @@ Shader_Time :: struct {
}
coven_init :: (window_title: string, window_width: u32, window_height: u32, fullscreen: bool) {
engine.imgui_context = ImGui.CreateContext();
engine.window = create_window(window_title, window_width, window_height, fullscreen);
engine.renderer = create_renderer(engine.window);
engine.renderer.vsync = true;
@@ -91,6 +93,12 @@ coven_run :: (game_update_proc: (float), game_editor_update_proc: (float), game_
}
}
sdl_window := cast(*SDL_Window_Type)engine.window;
ImGui_ImplSdl_Init(sdl_window.sdl_window);
ImGui.StyleColorsClassic();
ImGui.GetIO();
time = xx seconds_since_init();
while !quit {
@@ -98,6 +106,13 @@ coven_run :: (game_update_proc: (float), game_editor_update_proc: (float), game_
frame_index += 1;
ImGui_ImplSdl_NewFrame((cast(*SDL_Window_Type)engine.window).sdl_window);
imgui_impldx11_new_frame();
ImGui.NewFrame();
show: bool = true;
ImGui.ShowDemoWindow(*show);
update_input();
// @Incomplete
@@ -156,9 +171,16 @@ coven_run :: (game_update_proc: (float), game_editor_update_proc: (float), game_
update_audio(dt);
ImGui.Render();
render();
}
imgui_impldx11_shutdown();
#if WITH_EDITOR {
ImGui.DestroyContext(engine.imgui_context);
}
SDL_DestroyWindow(engine.window);
SDL_Quit();