Skip to content

Commit e3bd41b

Browse files
first minimal working project
1 parent 3e0df8c commit e3bd41b

File tree

7 files changed

+13431
-0
lines changed

7 files changed

+13431
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Folders
2+
/build/*
3+
14
# Prerequisites
25
*.d
36

CMakeLists.txt

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
3+
project(
4+
minimal_gui
5+
DESCRIPTION "My minimal C++ imgui"
6+
LANGUAGES CXX)
7+
8+
set(CMAKE_CXX_STANDARD 20)
9+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
10+
11+
find_package(OpenGL REQUIRED)
12+
find_package(SDL2 REQUIRED)
13+
14+
include(FetchContent)
15+
16+
FetchContent_Declare(
17+
imgui
18+
GIT_REPOSITORY "https://github.com/ocornut/imgui.git"
19+
# docking-latest
20+
GIT_TAG 226e0d579d2632a81d95f60bb5d65c70e55feb90
21+
)
22+
FetchContent_MakeAvailable(imgui)
23+
24+
FetchContent_Declare(
25+
implot
26+
GIT_REPOSITORY "https://github.com/epezent/implot.git"
27+
GIT_TAG f156599faefe316f7dd20fe6c783bf87c8bb6fd9
28+
)
29+
FetchContent_MakeAvailable(implot)
30+
31+
add_library(imgui
32+
${imgui_SOURCE_DIR}/imgui.cpp
33+
${imgui_SOURCE_DIR}/imgui.h
34+
${imgui_SOURCE_DIR}/imconfig.h
35+
${imgui_SOURCE_DIR}/imgui_demo.cpp
36+
${imgui_SOURCE_DIR}/imgui_draw.cpp
37+
${imgui_SOURCE_DIR}/imgui_internal.h
38+
${imgui_SOURCE_DIR}/imgui_tables.cpp
39+
${imgui_SOURCE_DIR}/imgui_widgets.cpp
40+
${imgui_SOURCE_DIR}/imstb_rectpack.h
41+
${imgui_SOURCE_DIR}/imstb_textedit.h
42+
${imgui_SOURCE_DIR}/imstb_truetype.h
43+
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
44+
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.h
45+
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
46+
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.h
47+
${implot_SOURCE_DIR}/implot.h
48+
${implot_SOURCE_DIR}/implot_internal.h
49+
${implot_SOURCE_DIR}/implot.cpp
50+
${implot_SOURCE_DIR}/implot_items.cpp
51+
${implot_SOURCE_DIR}/implot_demo.cpp
52+
)
53+
54+
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})
55+
target_link_libraries(imgui PUBLIC SDL2::SDL2)
56+
57+
# Define the main executable
58+
add_executable(${PROJECT_NAME} src/main.cpp)
59+
60+
target_include_directories(${PROJECT_NAME} PRIVATE
61+
${imgui_SOURCE_DIR}
62+
${implot_SOURCE_DIR}
63+
${imgui_SOURCE_DIR}/backends
64+
)
65+
66+
# Link SDL2 and ImGui to your project
67+
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2 OpenGL::GL imgui)

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# My Minimal ImGui Project
2+
3+
This project consits in creating a instant mode gui in C++ using **Dear ImGui** and **ImPlot** with **SDL2** and **OpenGL3** backend.
4+
5+
For now, the main file consited in displaying the demo proposed by the creator, build using cmake.
6+
7+
To create your own GUI, see in the main files the `ImGui:ShowDemoWindow()` and `ImPlot:ShowDemoWindow()` functions calls and the window created right after. Replace those calls with the call of a functions where you define windows. (Don't forget to modify CMakeLists.txt file if needed). You can find the examples provided of those two functions in the `examples` folder. These piece of code are a copy of demo from the Dear ImGui and ImPlot repo, but not builds, the build ones are those pulled during fetching of repos.
8+
9+
## Sources
10+
[Dear ImGui](https://github.com/ocornut/imgui)
11+
12+
[ImPlot](https://github.com/epezent/implot/)
13+
14+
## Build
15+
### Dependancies
16+
`Dear ImGui` and `ImPlot` are fetched and build during the compile process
17+
18+
Requier SDL2 and OpenGL3
19+
20+
```bash
21+
sudo apt install libsdl2-dev # for SDL2
22+
```
23+
24+
Alternatively if you want to build SDL2 inside the project, add those lines in the CMakeLists.txt
25+
26+
```cmake
27+
FetchContent_Declare(
28+
SDL2
29+
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
30+
GIT_TAG release-2.0.22
31+
)
32+
33+
FetchContent_MakeAvailable(SDL2)
34+
```
35+
36+
### build
37+
Inside the parent folder
38+
```bash
39+
mkdir -p build && cd build
40+
cmake ..
41+
cmake -build .
42+
```
43+
44+
### Launch executable
45+
```bash
46+
./minimal_gui
47+
```

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This folder is not usefull in the build process, but contains examples.

0 commit comments

Comments
 (0)