Giter VIP home page Giter VIP logo

imgui-opengl-glfw-glew-cmake-demo's Introduction

imgui-opengl-glfw-cmake-demo

This is a demo project for ImGui with opegl, glfw3, glew and CMake.

The purpose of this project is to combine ImGui with glew and CMake. The original example is written with gl3w instead of glew. I personally preffers glew. As for CMake, I want to get used to it to build.

This project generates a stand alone demo app. Currently it is build only on Apple environment (only on Macs) but the build system and libraries are all crass-platform so it is possible to expand for build in Windows and Linux environment.

mac-app.gif

A breaf explanation of ImGui

It's easy to use simple GUI library for C++. It suits for 3D pipeline enabled application. The easiest way is just copy and add libraries in your project. That's all.

The next citations are from it's README.

dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).

ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.

How to build this project

It is really easy to use ImGui. The easiest way is for adding its sources to your project. in this demo, I aimed to use CMake as a build tool in a case cooperating with other sources.

This project uses several libraries so you have to prepare these. If you've alreadly had them you can skip this instructions

Mac

Install libraries:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # Install homebrew
$ brew update
$ brew install cmake # Install CMake
$ brew install glfw # Install glfw3
$ brew install glew # Install glew

Build and generate a stand alone app:

$ cd /to/project/root/
$ mkdir build && cd build
$ cmake ..
$ make

Or you can build and run with CLion.

You'll find the app in the build directry.

Windows

Currently no instructions - Your contribution are welcomed.

Linux

Currently no instructions - Your contribution are welcomed.

References

Contributions

This project was originally a by-product of my learning of CMake and ImGui. Your comments and pull request are always welcomed.

imgui-opengl-glfw-glew-cmake-demo's People

Contributors

morizotter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

imgui-opengl-glfw-glew-cmake-demo's Issues

Cmake for Linux

Hi,
Thanks for the great example.
I am breaking my head to make this work on Linux. No matter what i do, I get:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

This is the make file:

``
cmake_minimum_required(VERSION 3.6)
find_package(PkgConfig REQUIRED)
set(CMAKE_BUILD_TYPE Release)
#set(CMAKE_BUILD_TYPE "Debug")
set(CXX_RELEASE_FLAGS = -O3 -march=native)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#-std=c++0x
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILE 1)
set(APP_VERSION_MAJOR 1)
set(APP_VERSION_MINOR 0)

#project(imgui-deepsleep)
#SET( PROJ_NAME imgui-deepsleep )
set(PROJ_NAME DeepSleepGUI) # the name of the executable

message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
message(STATUS "PROJ_NAME: ${PROJ_NAME}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "CXX_RELEASE_FLAGS: ${CXX_RELEASE_FLAGS}")
set(CMAKE_BUILD_TYPE Release)
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message("system: ${CMAKE_SYSTEM_PREFIX_PATH}")

Imgui itself

add_subdirectory(imgui)

include_directories(${PROJECT_SOURCE_DIR})

#target_link_libraries(${PROJ_NAME} imgui)

find Eigen3

find_package (Eigen3 REQUIRED)
include_directories (${EIGEN3_INCLUDE_DIRS})

glfw

find_package(glfw3 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
link_libraries(${GLFW_LIBRARY_DIRS})

find_package(GLEW QUIET CONFIG)

opengl

find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})

glew

find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})

add and depend on OpenGL

find_package(OpenGL REQUIRED)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR})
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${OPENGL_LIBRARIES})

find_path(GLEW_INCLUDE_DIR GL/glew.h)
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)

find_package(GLEW REQUIRED)
if (GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
link_libraries(${GLEW_LIBRARIES})
endif()

#Boost
message("system: ${CMAKE_SYSTEM_PREFIX_PATH}")
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")

if (APPLE)
# use OpenMP
include(FindOpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(SEND_ERROR "OpenMP not found.")
endif()
find_library(COCOA_LIBRARY Cocoa)
find_library(OpenGL_LIBRARY OpenGL)
find_library(IOKIT_LIBRARY IOKit)
find_library(COREVIDEO_LIBRARY CoreVideo)
SET(EXTRA_LIBS ${COCOA_LIBRARY} ${OpenGL_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY})
endif (APPLE)

set(PROJ_NAME DeepSleepGUI) # the name of the executable
SET( PROJ_SOURCES_DIR src)
SET( PROJ_SOURCES ${PROJ_SOURCES_DIR}/deepsleep/main.cpp)
SET( PROJ_INCLUDES include)
message(STATUS "PROJ_INCLUDES: ${PROJ_INCLUDES}")
SET( PROJ_HEADERS "")
SET(PROJECT_INCLUDE_DIR ${PROJ_INCLUDES})
SET(PROJECT_SOURCE_DIR ${PROJ_SOURCES})

include_directories("${PROJECT_INCLUDE_DIR}")
add_executable(${PROJ_NAME} ${PROJ_SOURCES} ${PROJ_HEADERS} ${PROJECT_INCLUDE_DIR})

#find_package(glm REQUIRED)

target_link_libraries(
${PROJ_NAME}
imgui
glfw
${GLFW_LIBRARIES}
${GLEW_LIBRARIES}
${EXTRA_LIBS}
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}
)
``

Any help would be appreciated,

Consider using a newer version of ImGui

Thank you for providing this demo! It was a great resource for building projects with GLFW and ImGui. I'd just like to note that the ImGui version in this repository is old (four years), and ImGui developers improve the library at a fairly rapid pace. The latest version is less demanding on the CPU, but the code to set it up and use it differ slightly from what's required in this version.

An example on how to use this new version of ImGui is available at its official repository: https://github.com/ocornut/imgui/blob/master/examples/example_glfw_opengl3/main.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.