• This repository has been archived on 22/Apr/2020
  • Stars
    star
    156
  • Rank 239,589 (Top 5 %)
  • Language
    C++
  • Created over 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dear ImGui Renderer/Wrapper for Cinder

Dear-Imgui is now officially shipped with Cinder. Please use that implementation instead:

https://github.com/cinder/Cinder/blob/master/include/cinder/CinderImGui.h (See samples update here). This repo will be archived but you can still open issues and pull request here to help progress the impl.

Cinder-ImGui

Immediate mode GUI Library from Omar Cornut wrapped for use with Cinder 0.9.

(ImGui is free but Omar needs your support to sustain development and maintenance. If you work for a company, please consider financial support)

Patreon PayPal

ImGui is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is portable, renderer agnostic and self-contained (no external dependencies). It is based on an "immediate mode" graphical user interface paradigm which enables you to build user interfaces with ease.

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.

ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.

Getting Started

Download or check out this repository into your Cinder/blocks directory, then use Tinderbox to create a new project using ImGui.

Once the project is created you'll need to include the header in your .cpp file:

#include "CinderImGui.h"

Initialize ImGui at setup:

void CinderApp::setup()
{
    ImGui::initialize();
}

Then you're ready to start drawing components:

void CinderApp::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    ImGui::Text("Hello, world!");
}

Namespace

For ease of use I added a namespace alias for ImGui, feel free to disable it by defining CINDER_IMGUI_NO_NAMESPACE_ALIAS.

Advanced Initialization

You can provide an ui::Options object to the initialize method to setup the UI the way you want:

void CinderApp::setup()
{
    ui::initialize( ui::Options().font( ttfFontPath, 12 ).window( uiWindow ).frameRounding( 0.0f ) );
}

Multiple fonts and special glyphs are specified the same way (see ImGui docs for more info):

void CinderApp::setup()
{
    ui::initialize( ui::Options()
                    .fonts( {
                        { getAssetPath( "Kontrapunkt Bob Light.ttf" ), 12 },
                        { getAssetPath( "Kontrapunkt Bob Bold.ttf" ), 20 },
                        { getAssetPath( "FontAwesome.ttf" ), 12 }
                    } )
                    .fontGlyphRanges( "FontAwesome", { 0xf000, 0xf06e, 0 } )
                );
}

UI Creation

By default or if you don't specify an empty windowRef, the wrapper will take care of calling ImGui::NewFrame and ImGui::Render, meaning that you don't have to worry about anything else than the actual UI. You can add UI code in any place you want, that's it. The Renderer takes care of setting the matrices and the proper shader to draw the UI through a postDraw signal. (You can disable this behavior through the initialization options).

void CinderApp::draw()
{
    ui::Combo( "Blending", &blendMode, blendModes, 3 );
    ui::SliderInt( "Circles", &n, 0, 500 );
    ui::SliderFloat( "Min Radius", &minRadius, 1, 499 );
    ui::Image( mFbo->getColorTexture(), mFbo->getSize() );
}
void SomeFunctionCalledSomewhereElse()
{
    ui::Button( "MyButton" );
}

Scoped Objects

For the sake of simplifying a bit more the use of this lib, there's Scoped* objects for most push/pop functions. The state will be pushed when creating the object and popped at the end of its lifespan.

void SomeWindow()
{
    ui::ScopedWindow window( "Title" );
    ui::ScopedFont font( "Font-Bold" );

    ui::Text( "Some Bold Title" );
    ui::Image( mFbo->getColorTexture(), mFbo->getSize() );
}

Todo

  • fix keyboard events handling (modifiers not working for the moment)
  • multi-window option

ImGui Credits (from ImGui README)

Developed by Omar Cornut and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of Media Molecule and first used internally on the game Tearaway.

I first discovered imgui principles at Q-Games where Atman had dropped his own simple imgui implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating on it.

Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license).

Embeds stb_textedit.h, stb_truetype.h, stb_rectpack.h by Sean Barrett (public domain).

Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.

ImGui development is financially supported on Patreon.

Special supporters:

  • Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Stefano Cristiano.

And:

  • Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei.

And other supporters; thanks!

ImGui License

ImGui is licensed under the MIT License, see LICENSE for more information.

More Repositories

1

Cinder-Experiments

A collection of experiments, samples and other bits of code.
C++
231
star
2

SimplexNoise

Collection of Simplex Noise functions
C++
127
star
3

Watchdog

File / directory watcher for c++11 and boost
C++
123
star
4

GroveApp

C++
101
star
5

Cinder-Runtime

Runtime-Compiled C++ for Cinder
C++
57
star
6

FlyingTokyo19

Cinder C++ Workshop at Rhizomatiks - FlyingTokyo19 - May 2016
C++
57
star
7

SpacePartitioning

A collection of Space Partitioning Algorithms for Cinder
C++
45
star
8

Cinder-CodeEditor

In-App full-featured Code Editor
JavaScript
25
star
9

Cinder-OculusRift

HMD Camera setup and lense distortion for the Oculus Rift.
C++
24
star
10

Cinder-AssetManager

Supports hot reloading and asynchronous loading of assets (Replaced by https://github.com/simongeilfus/Watchdog)
C++
19
star
11

Cinder-Cereal

Add serialization support for Cinder's classes.
C++
17
star
12

HalfEdge

Work in progress Half-Edge mesh library
C++
16
star
13

Cinder-Cmft

Thin wrapper around Cmft for use with Cinder
C++
12
star
14

SharedMemoryUtils

C++
11
star
15

Cinder-Angelscript

Thin cinder wrapper around Angelscript
C++
10
star
16

PoissonDiskDistribution

C++
9
star
17

Cinder-SLB

Lua Scripting for Cinder ( Wrap SLB and luaGL )
C
8
star
18

CinderAndScriptsClass

C++
8
star
19

Triangulation

C++
7
star
20

Cinder-LiveAssetManager

New block here : https://github.com/simongeilfus/Cinder-AssetManager
C++
7
star
21

FontAwesomeCpp

Helper and generator classes to ease the use of FontAwesome in c++.
C++
7
star
22

Paleodictyon-Gwen-Wrapper

C++
6
star
23

Cinder-Chipmunk

Basic OO Chipmunk wrapper for Cinder.
Objective-C
5
star
24

Cinder-Gx

C++
5
star
25

Cinder-Qhull

Qhull block for Cinder
C
4
star
26

Cinder-GlslProgHelper

Adds preprocessor features to Cinder::GlslProg ( #include, #define, etc... )
C++
3
star
27

Cinder-Gizmo

Basic 3D manipulation library for Cinder.
C++
2
star
28

Cinder-OpenMesh

OpenMesh library
C++
2
star
29

Cinder-Shader

Small addition to Cinder's Glsl Shaders. Allow attrib location binding, transform feedback and auto reloading while you edit the code.
C++
2
star
30

project_starter_kit

c++ project starter kit
C++
1
star
31

Cinder-Gwen-1

Gwen (GUI Without Extravagant Nonsense) for Cinder
C++
1
star
32

Clang-Parser

C++
1
star
33

CinderCMakeBoilerplate

Basic project structure and tools for working with Cinder and CMake
CMake
1
star
34

LuaBindings

Sources for Cinder-LuaBind / libLuaBindings.a
C++
1
star
35

NvidiaEnablement

One-liner block for Cinder to force enable Nvidia Optimus on windows laptops
C
1
star