Index

zydeco / 7457fba

Experiment in graphics programming, C++, OpenGL, simulation techniques.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
803 Sep 2023 23:177457fbaImGui bringupJosh Stockin1740G

Blob @ zydeco / src / render / objects / GLRenderObjectImGui.cpp

text/plain2276 bytesdownload raw
1#include "ZydecoCommon.hpp"
2#include "GLRenderObject.hpp"
3#include "GLRenderObjectImGui.hpp"
4
5
6GLRenderObjectImGui::GLRenderObjectImGui():
7 GLRenderObject::GLRenderObject("", 10)
8{
9 m_font = ImGui::GetIO().Fonts->AddFontFromFileTTF("/usr/share/fonts/FiraSans-Regular.ttf", 14);
10 ImGui_ImplOpenGL3_CreateFontsTexture();
11}
12
13void GLRenderObjectImGui::Render()
14{
15 if (!m_renderEnabled) { return; }
16
17 ImGuiIO& io = ImGui::GetIO();
18
19 ImGui_ImplSDL2_NewFrame();
20 ImGui_ImplOpenGL3_NewFrame();
21
22 ImGui::NewFrame();
23
24 auto mods = io.KeyMods;
25 auto ctrl = io.KeyCtrl;
26 auto alt = io.KeyAlt;
27 auto shift = io.KeyShift;
28
29 ImGui::StyleColorsClassic();
30 ImGui::PushFont(m_font);
31
32 static bool show_demo_window = false;
33 static bool show_about_window = false;
34 if (ImGui::BeginMainMenuBar())
35 {
36 ImGui::MenuItem("Zydeco", nullptr, &show_demo_window, false);
37 if (ImGui::BeginMenu("Help"))
38 {
39 ImGui::MenuItem("ImGui Demo", nullptr, &show_demo_window, true);
40 ImGui::MenuItem("About", nullptr, &show_about_window, true);
41 ImGui::EndMenu();
42 }
43 ImGui::EndMainMenuBar();
44 }
45
46 ImGui::DockSpaceOverViewport(ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode, nullptr);
47
48 if (show_demo_window) { ImGui::ShowDemoWindow(&show_demo_window); }
49 if (show_about_window)
50 {
51 ImGui::SetNextWindowSize({350, 120});
52 if (ImGui::Begin("About", &show_about_window, ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse
53 | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoResize))
54 {
55 ImGui::Text("Zydeco (c) 2023 Joshua Stockin");
56 ImGui::Text("<https://joshstock.in> <josh@joshstock.in>");
57 ImGui::Separator();
58 ImGui::TextWrapped("Zydeco is an experimental project in C++, graphics programming with OpenGL, procedural generation, and world simulation.");
59 ImGui::End();
60 }
61 }
62
63 ImGui::PopFont();
64
65 io.KeyMods = mods;
66 io.KeyCtrl = ctrl;
67 io.KeyAlt = alt;
68 io.KeyShift = shift;
69
70 ImGui::Render();
71 ImGui::UpdatePlatformWindows();
72
73 ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
74}
75