Code Monkey home page Code Monkey logo

helloworldwithdearimgui's Introduction

"hello, world" with Dear ImGui

Dear ImGui is a great library but it may not be easy to get a simple "hello, world". Indeed, Dear ImGui doesn't handle the display, keyboard and mouse by itself. A backend is required to do this:

You will need a backend to integrate Dear ImGui in your app. The backend passes mouse/keyboard/gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices.

A backend is something like SDL or OpenGL, stuffs that I am absolutely not familiar with, so it took me a while just to display a simple text.

Here is an "hello, world" project so you can get started easily!

hello world

Run the project

The project builds with CMake.

From the command line:

git clone https://github.com/Bktero/HelloWorldWithDearImGui
cmake HelloWorldWithDearImGui\ -B build -G Ninja
cmake --build build
./build/HelloWorldWithDearImGui.exe

It will clone this repository, generate build files for Ninja with GCC, build the project and run the application. Of course, you can select the generator and compiler you want. I have successfully built the project on Windows 10 with mingw64/GCC 9.2 (with both Make and Ninja) and MSVC 2019.

Under the hood

Download dependencies from GitHub

The project uses the OpenGL + GLFW backend.

The FetchContent module is used in CMakelists.txt to download the dependencies from GitHub:

Note that the official GitHub for GLEW is https://github.com/nigels-com/glew but it doesn't build properly with CMake. This issue suggests to use an alternative repository: https://github.com/Perlmint/glew-cmake.

C++ standard version

Dear ImGui requires C++11. In C++98, GCC emits warnings:

warning: anonymous variadic macros were introduced in C++11 [-Wvariadic-macros]

helloworldwithdearimgui's People

Contributors

bktero avatar

Stargazers

Michael Burt avatar  avatar Patrick Macdonald avatar tewili avatar Lena avatar

Watchers

James Cloos avatar  avatar

Forkers

nbonnec djreep81

helloworldwithdearimgui's Issues

Cocoa; Failed to find service port for display

First of all, thanks for sharing this example, much appreciated!
I'm new to c++, and am trying to adapt this to work under macos m1.
I've got it building without issue, but on running I get the following error:

Glfw Error 65544: Cocoa: Failed to find service port for display
Glfw Error 65544: Cocoa: Failed to find service port for display
Glfw Error 65544: Cocoa: Failed to find service port for display
Glfw Error 65543: NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above
Glfw Error 65538: Cannot set swap interval without a current OpenGL or OpenGL ES context

Any ideas what I need to do to fix this?

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.