1616#include " shader.h"
1717#include " window.h"
1818
19+ #include " imgui.h"
20+ #include " imgui_impl_glfw.h"
21+ #include " imgui_impl_opengl3.h"
22+
1923int main (int argc, const char ** const argv) {
2024 if (argc != 2 ) {
2125 std::cout << std::format (" Usage: {} FILE\n " , argv[0 ]);
@@ -29,6 +33,16 @@ int main(int argc, const char** const argv) {
2933 }
3034
3135 Window window ({});
36+ // Setup Dear ImGui context
37+ IMGUI_CHECKVERSION ();
38+ ImGui::CreateContext ();
39+ ImGuiIO& io = ImGui::GetIO ();
40+ io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
41+ io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
42+
43+ // Setup Platform/Renderer backends
44+ ImGui_ImplGlfw_InitForOpenGL (window.GetWindow (), true ); // Second param install_callback=true will install GLFW callbacks and chain to existing ones.
45+ ImGui_ImplOpenGL3_Init ();
3246
3347 Model model = Model (model_path);
3448 Shader shader = Shader (" ../shaders/vertex.vs" , " ../shaders/fragment.fs" );
@@ -51,6 +65,10 @@ int main(int argc, const char** const argv) {
5165 while (!window.ShouldClose ()) {
5266 // handling input
5367 window.ProcessInput (camera);
68+ ImGui_ImplOpenGL3_NewFrame ();
69+ ImGui_ImplGlfw_NewFrame ();
70+ ImGui::NewFrame ();
71+ ImGui::ShowDemoWindow ();
5472
5573 // Rendering
5674 // glClearColor(0.7f, 0.3f, 0.3f, 1.0f);
@@ -80,6 +98,9 @@ int main(int argc, const char** const argv) {
8098
8199 model.Draw (shader);
82100
101+ ImGui::Render ();
102+ ImGui_ImplOpenGL3_RenderDrawData (ImGui::GetDrawData ());
103+
83104 // swap buffers and poll for IO events
84105 window.SwapBuffers ();
85106 window.PollEvents ();
@@ -99,5 +120,9 @@ int main(int argc, const char** const argv) {
99120 past_time = std::chrono::steady_clock::now ();
100121 }
101122 }
123+ ImGui_ImplOpenGL3_Shutdown ();
124+ ImGui_ImplGlfw_Shutdown ();
125+ ImGui::DestroyContext ();
126+
102127 return 0 ;
103128}
0 commit comments