Skip to content

Multiplatform (ImGui + ImPlot + CMake) application template

License

Notifications You must be signed in to change notification settings

krupkat/imguiplot-app

Repository files navigation

MacOS Ubuntu Windows Formatting Static analysis

imguiplot-app

Multiplatform (ImGui + ImPlot + CMake) application template.

Quickly prototype applications with the ImGui / ImPlot libraries:

#include <imgui.h>
#include <implot.h>
#include <sdl_renderer_app.hpp>

int main(int, char**) {
  imguiplot::SdlRendererApp app({
    .window_width = 1600, 
    .window_height = 900
  });

  return app.Run([] {
    ImGui::ShowDemoWindow();
    ImPlot::ShowDemoWindow();
  });
}

Prerequisites

A compiler with C++20 support and at least one of the supported backend libraries: SDL, GLFW.

Build

Examples

Use standard CMake commands to build the demo applications. See the workflow definitions for the exact build instructions for your OS.

Library

Use this repository as a submodule / subfolder and link to the imguiplot-backend-app target in your CMake file.

git clone --recurse-submodules https://github.com/krupkat/imguiplot-app.git

Your CMake file:

cmake_minimum_required(VERSION 3.21)

project(my-imguiplot-demo)
set(CMAKE_CXX_STANDARD 20)
add_subdirectory(imguiplot-app)

add_executable(my-demo demo.cpp)
target_link_libraries(my-demo imguiplot-glfw-app imgui)

# copy a font file next to the executable
copy_file(my-demo "${IMGUI_FONT_DIR}/ProggyClean.ttf")

Your cpp file:

#include <imgui.h>
#include <glfw_opengl3_app.hpp>

int main(int, char**) {
  imguiplot::GlfwOpenGL3App app({
    .font_path = "ProggyClean.ttf",
    .font_size = 24
  });

  return app.Run([] {
    ImGui::Begin("Demo");
    ImGui::Text("Hello, world!");
    ImGui::End(); 
  });
}

Contributions

Contributions are more than welcome, feel free to open an issue. Additional backends should be easy to add by creating your_backend_app.cpp based on one of the examples.

License

Distributed under the MIT license. See LICENSE for more information.

Contact

Tomas Krupka - krupkat.cz