Skip to content

Creating New App

tpecholt edited this page Dec 25, 2025 · 4 revisions

This tutorial assumes basic familiarity with C++ app structure and your IDE of choice.

Two scenarios are presented here. Using plain Visual Studio project files or CMake project which can be built with various IDEs and from command line. For non-trivial projects CMake is a better choice and once configured you can generate project file for your IDE out of it and build and debug it there.

Follow different tutorial to setup your Android app.

Required steps:

  1. Create new C++ project:

    • Visual Studio: Select File / New / Project. Choose Empty Project template. This will actually create a solution file with one sub-project.
    • Visual Studio: Set the project to at least C++17 mode which is the minimal version supported by ImRAD with Project Properties / C++ / Language / C++ Language Standard.
    • CMake: Create CMakeLists.txt with add_executable
  2. Add main.cpp file with ImGui initialization code and the event loop.

    • If you don't have main.cpp yet generate it from ImRAD by going to New File / Project Templates / GLFW template [1]. If you prefer to use a different backend supported by ImGui such as DirectX or SDL try to use one of the ImGui examples but certain adjustments may be needed. For example you will need to include imrad.h with IMRAD_H_IMPLEMENTATION defined.
    • Visual Studio: Add Existing file to the project.
    • CMake: List main.cpp in add_executable
  3. Add GLFW [1] dependency

    • Visual Studio: Obtain GLFW windows binaries. In main project set Project Properties / C++ / General / Additional Include directories and Project Properties / Linker / Input / Additional Dependencies
    • CMake: GLFW comes with CMakeLists.txt. You can either configure and install it separately or disable installation, tests etc. and then add_subdirectory, target_link_libraries it.
  4. Add ImGui dependency:

    • Download ImGui sources from project website. Include only the appropriate backend sources - imgui_impl_glfw.cpp, imgui_impl_opengl3.cpp but don't forget imgui_stdlib.cpp.
    • Visual Studio: Add imgui static library with Add / New Project / Static Library and add its sources. Set its include directories and linker dependencies so it will compile.
    • Visual Studio: Add imgui library as the main project dependency with Add Reference. That instructs VS to link the library with your app but it doesn't set include directories so you need to add that too.
    • CMake: download imgui sources in a subfolder. ImGui doesn't come with CMakeLists.txt so create one with add_library(STATIC). Reference new CMakeLists from the main one with add_subdirectory, target_link_libraries
  5. Set include path pointing to the ImRAD installation / include folder. This will give you access to imrad.h which is used by the generated code.

    • Visual Studio: Project Configuration / C++ / General / Additional Include Directories
    • CMake: target_include_directories
  6. (Optional) Configure imrad.h by adding project-wide preprocessor defines

    • IMRAD_WITH_LOAD_TEXTURE - to enable Image widget. Additonal STB library dependency is needed
    • IMRAD_WITH_FMT - if you prefer to use external fmt library for string formatting
    • IMRAD_WITH_MINIZIP - to enable loading textures and style assets from zipped resource file. Additional zlib library dependency will be needed
    • Visual Studio: Set Project Configuration / C++ / Preprocessor / Preprocessor Definitions
    • CMake: target_compile_definitions
  7. Basic app scaffolding is finished so try to run it to see if everything works

    • CMake: You can generate project files for your IDE of choice for example by running cmake-gui. Then build and debug it there. Or use cmake CLI and build it on the command line.
    • Proceed to create an app window here

References

  1. GLFW is a well known cross-platform library for basic window management and OpenGL context initialization.

Clone this wiki locally