One of the best ways to work with Dear ImGui is by combining it with OpenGL and SDL2.
To be able to follow this tutorial, we will need the tools properly pre-installed on our system. We have all the installation tutorials, they are:
In this article we will see how to compile Dear ImGui with OpenGL and SDL2 on your system, be it Windows, macOS or GNU/Linux.
Let’s go to the steps!
Steps
1. Clone the Dear ImGui repository
2. Create a directory and subdirectory for your project
3. Copy all files from the imgui repository listed below to your project subdirectory: imgui
4. Also copy additional files to compile
5. Create this main.cpp file in the root of your project: myproject/main.cpp
and insert the content below:
6. Create a Makefile for us to compile
vim Makefile
And insert the content below:
7. Now just compile:
8. And run the project:
The possible output will be similar to the image below:
If you have any questions, review the libs installation paths on your system!
opengl
imgui
sdl2
cpp
Marcos Oliveira
Software developer