Sologala / imgui-app-base

Wrapping the routines of imgui and its backends to a Class AppBase, only need providing lambda liake callback to create imgui app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImGui_AppBase

🚩 ImGui_AppBase wrapped the routine of ImGui and OpenGL as well as Glfw, which like GUI context initialization and destroying. Let us be more concentrated on the main processes.

Usage

#include <imgui.h>
#include <imgui_app_base.h>

int main(int argc, char *argv[])
{
    ImGuiApp::AppBase::Option opt;
    opt.font_size = 30;
    ImGuiApp::AppBase app("test-app", ImVec2(800, 600), opt);
    bool clicked = false;
    app.AddDrawCallBack([clicked]() {
        // Main processes is handled by AddDrawCallBack.
        ImGui::Begin("app", nullptr);
        ImGui::SetWindowSize(ImVec2(800, 600));
        ImGui::SetWindowPos(ImVec2(0, 0));

        bool clicked = ImGui::Button("Click Me", ImVec2(100, 100));
        if (clicked)
        {
            ImGui::Text("clicked");
        }
        ImGui::Text("Static Text");
        ImGui::End();
        return true;

    });

    app.Run();

    return 0;
}

About

Wrapping the routines of imgui and its backends to a Class AppBase, only need providing lambda liake callback to create imgui app.


Languages

Language:C 98.4%Language:C++ 1.3%Language:CMake 0.3%