# ImGUI ###### tags: `software` `electrical_system` `NTURT` ## References * [Dear ImGUi](https://github.com/ocornut/imgui) * [imgui-SFML](https://github.com/eliasdaler/imgui-sfml) <參考用> > Note: ImGUI only draw the image and not displaying it, it requires backends that are specific to platforms to actual display to the screen. Since `OpenGL` is one of the most popular cross-plafrom display library, we will use it here. ## How to start using ImGUI ? ### Ubuntu Install glfw ```shell= sudo apt install libglfw3 sudo apt install libglfw3-dev ``` ### On Raspberry Pi Install glfw ```shell= sudo apt install libglfw3 sudo apt install libglfw3-dev ``` :::warning Note: Since Raspberry Pi (1~4) only supports OpenGL 2, the backend should choose `imgui_impl_opengl2.h`. ::: ### macOS 1. download **brew** in terminal ```shell= /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /Users/work/.zprofile echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/work/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" ``` 2. install glfw ```shell= brew install glfw ``` 3. download **cmake** in terminal ```shell= brew install cmake brew install cmake-docs ``` ### Using cmake to build From: [csdn](https://blog.csdn.net/u012234115/article/details/118961206) Add your application at the end of the file ```cmake= cmake_minimum_required(VERSION 3.8) project(imgui_test) set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_STANDARD 17) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # find apple specific graphics library if(APPLE) find_library(OPENGL_LIBRARY OpenGL REQUIRED) find_library(COCOA_LIBRARY Cocoa REQUIRED) find_library(IOKIT_LIBRARY IOKit REQUIRED) find_library(COREVID_LIBRARY CoreVideo REQUIRED) endif() # imgui includes include_directories( imgui imgui/backends ) # pull apple global includes if(APPLE) include_directories( /usr/local/include /opt/local/include /opt/homebrew/include ) endif() # set common imgui sources file(GLOB IMGUI_SRC imgui/*.h imgui/*.cpp ) # set platform specific imgui sources if(WIN32) file(GLOB IMGUI_PLATFORM_SRC imgui/backends/imgui_impl_win32.* imgui/backends/imgui_impl_dx12.* ) elseif(UNIX) add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GL3W) include_directories( imgui/examples/libs/gl3w ) file(GLOB IMGUI_PLATFORM_SRC imgui/examples/libs/gl3w/GL/gl3w.* imgui/backends/imgui_impl_glfw.* imgui/backends/imgui_impl_opengl2.* ) endif() # link apple globle libraries if(APPLE) link_directories( /usr/local/lib /opt/local/lib /opt/homebrew/lib ) endif() # library: imgui add_library(imgui ${IMGUI_SRC} ${IMGUI_PLATFORM_SRC} ) # link to platform specific libraries if(WIN32) target_link_libraries(imgui d3d12.lib d3compiler.lib dxgi.lib ) elseif(APPLE) target_link_libraries(imgui ${OPENGL_LIBRARY} ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVID_LIBRARY} glfw ) elseif(UNIX AND NOT APPLE) target_link_libraries(imgui GL glfw dl ) endif() add_executable(${PROJECT_NAME} src/main.cpp ) target_link_libraries(${PROJECT_NAME} imgui ) ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up