Simple library to handle an OpenGL window with Dear ImGui integration
- Class based windows management system
- Built-in OpenGL event handling
- Built-in ImGui handling
- Add the following lines to your CMakeLists.txt:
include(FetchContent) FetchContent_Declare(ImGuiHandler GIT_REPOSITORY "https://github.com/Fattorino/ImGuiHandler.git" GIT_TAG "origin/master" SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/includes/ImGuiHandler" ) FetchContent_MakeAvailable(ImGuiHandler)
target_link_libraries(YourProject ImGuiHandler)
- Make sure you have the following dependencies available for
find_package()
:- Dear ImGui
- OpenGL
- GLFW
- Download and copy, or clone the repo inside your project
- Add the following lines to your CMakeLists.txt:
add_subdirectory(path/to/ImGuiHandler) target_link_libraries(YourProject ImGuiHandler)
- Make sure you have the following dependencies available for
find_package()
:- Dear ImGui
- OpenGL
- GLFW
#include <ImGuiHandler.h>
class DemoWindow : public appLayer
{
private:
float var = 200.f;
public:
void onCreate() override;
void update() override;
void menuBar() override;
};
#include "DemoWindow.h
void DemoWindow::onCreate() { var = 200.f; }
void DemoWindow::update()
{
ImGui::Begin("DemoWindow");
ImGui::SliderFloat("Drag me", &var, 0.f, 100.f);
ImGui::Text("VAL: %f", var);
ImGui::End();
}
void DemoWindow::menuBar()
{
if (ImGui::BeginMenu("Demo"))
{
if (ImGui::MenuItem("Win")) { }
if (ImGui::MenuItem("dow")) { }
ImGui::EndMenu();
}
}
#include "DemoWindow.h"
void menuBar()
{
if (ImGui::BeginMenu("Main parent window"))
{
if (ImGui::MenuItem("Menu")) { }
if (ImGui::MenuItem("Bar")) { }
ImGui::EndMenu();
}
}
int main()
{
if (!IGH.init("Example", 650, 200))
return 1;
ImGui::GetIO().IniFilename = nullptr;
IGH.pushLayer<DemoWindow>();
IGH.menuBar(menuBar);
IGH.setActiveWin(0);
bool done = false;
while (!done)
{
IGH.loop(&done);
}
IGH.end();
return 0;
}