Immediate Mode GUI – Theory and Example

Slides:



Advertisements
Similar presentations
FireMonkey Deep Dive The Next Generation of Business Application Development.
Advertisements

Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
CS 180 Problem Solving and Object Oriented Programming Fall 2011 Notes for the Final Lecture Dec 7, 2011 Aditya Mathur Department of Computer Science Purdue.
Basic OOP Concepts and Terms
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Intro and Chapter 1 Goals Give student some idea.
Graphical User Interfaces in Haskell Koen Lindström Claessen.
Zhonghua Qu and Ovidiu Daescu December 24, 2009 University of Texas at Dallas.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
IE 411/511: Visual Programming for Industrial Applications
Easy Studierstube Applications with a little help from OpenInventor Gerhard Reitmayr Gerhard Reitmayr Vienna University of Technology Vienna University.
Yingcai Xiao Voxel Game Engine Development. What do we need? What tools do we have? How can we design and implement? We will answer those questions in.
QML Qt Quick with QML and you can use JavaScript for engine along C++ Started to be released since late 2009 (Qt 4.7) Nokia focused on that for the Symbian/Meego.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
Introduction to Processing. 2 What is processing? A simple programming environment that was created to make it easier to develop visually oriented applications.
ROOT’s graphics on iOS. ROOT’s graphics (general scheme):
NCBI Genome Workbench Chuong Huynh NIH/NLM/NCBI Sao Paulo, Brasil July 15, 2004 Slides from Michael Dicuccio’s Genome Workbench.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Imagine Creating Software Without a Single Line of Code!
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Rigid Body Dynamics: A Graphical Simulation Eugene Paik
MiniDraw Introducing a Framework... and a few patterns.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Data Binding, Binding Properties Doncho Minkov Telerik School Academy Technical Trainer
Dive Into® Visual Basic 2010 Express
Introducing a Framework ... and a few patterns
Microsoft Foundation Classes MFC
Java FX: Scene Builder.
Mobile Application Development with MeeGo™ - Touch Apps & UI Design
Working in the Forms Developer Environment
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Introduction to Computer CC111
Chapter Topics 15.1 Graphical User Interfaces
Goals Give student some idea what this class is about
Chapter 2 – Introduction to the Visual Studio .NET IDE
Java Look-and-Feel Design Guidelines
Activities and Intents
Better Interactive Programs
Ogre Overview.
1. Introduction to Visual Basic
Example: Card Game Create a class called “Card”
OpenGL and Related Libraries
Introduction to Events
Screen Based Design: An Introduction DW9V 34
Ellen Walker Hiram College
Chap 7. Building Java Graphical User Interfaces
More on Graphical User Interfaces
Graphical User Interfaces -- Introduction
Fundamentals of Python: From First Programs Through Data Structures
VISUAL BASIC.
Introduction to Computing Using Java
Chapter 2 – Introduction to the Visual Studio .NET IDE
CIS16 Application Development Programming with Visual Basic
Better Interactive Programs
DB Implementation: MS Access Forms
Classes and Objects.
Game Loop Update & Draw.
Fundamentals of Programming I Windows, Labels, and Command Buttons
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
Generic Graphical User Interfaces ___________
Chapter 15: GUI Applications & Event-Driven Programming
Basic OOP Concepts and Terms
Simulation And Modeling
Chapter 4 Enhancing the Graphical User Interface
Windows Forms in Visual Studio 2005: An in-depth look at key features
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

Immediate Mode GUI – Theory and Example Adam Sawicki http://asawicki.info

What is GUI? Graphical User Interface (GUI) aka Head-Up Display (HUD) Displays information Handles interaction Mouse, touch, keyboard, other controllers…

Implementation  Default system controls (Used in desktop apps) Pure system API: WinAPI C++ library: Qt, wxWidgets, … Another programming language: C#, Java, … 

Implementation Default system controls Custom rendering (Used in games, graphics apps) Library: Scaleform, Dear ImGui, … Your own implementation

Architecture Object-oriented – seems to be the most natural architecture for GUI Class hierarchy for types of controls Design patterns, e.g. composite Fields: Position, Size, … Methods: Show, Hide, Enable, Disable, …

Architecture Object-oriented – seems to be the most natural architecture for GUI

Example

Some thoughts Actual objects also form a hierarchy Every control is positioned relative to its parent Similar to how games represent scene High-level approach found in game engines – hiearchy of objects

Immediate mode GUI – idea On low level (DirectX, OpenGL, Vulkan), rendering is stateless – „immediate mode” Sequence of draw calls repeated every frame What if… we could render GUI this way? SetShader SetTexture DrawTriangles …

Dear ImGui https://github.com/ocornut/imgui C++ library License: MIT Bindings to many languages available License: MIT Author: Omar Cornut (game developer) Suited for real-time rendering Efficient Graphics API agnostic

Example code if(ImGui::Begin("First Window")) { ImGui::Text("Do you like it?"); ImGui::Button("Yes"); ImGui::Button("No"); ImGui::End(); }

Q: How are controls positioned? Automatic – each control in new row You can change this: PushItemWidth(item_width), SameLine() Columns: Columns(count) Grouping: BeginGroup(), EndGroup() Full control: GetCursorPos(), SetCursorPos(local_pos)

Q: How do I handle feedback? You receive it the same moment you define a control ImGui::Text("Do you really want to quit?"); if(ImGui::Button("Yes")) ExitProgram(); if(ImGui::Button("No")) CloseThisWindow();

Q: Where is value of controls? In your own variables You pass pointers to them as you define controls float volume = 0.7f; bool mute = true; ImGui::SliderFloat("Volume", &volume, 0.0f, 1.0f); ImGui::Checkbox("Mute", &mute);

Q: How about other state? There is other state Window position & size, focus, text selection, … Kept inside ImGui library So it’s not truly stateless… Controls are identified by hash from their labels If not unique, you can use "Label##UNIQUE_ID" You can also scope your labels: PushID(), PopID()

Q: How to render? If your frame has Update() and Render(): Do all ImGui inside Update() Inside Render() you must render it yourself For rendering you receive a sequence of: Vertex array Index array Texture ID Scissor rectangle Examples available for: DirectX 9, 10, 11, OpenGL, Vulkan, Allegro, …

Features: Property grid Suited to provide editing of properties of various types bool, int, float, string, enum vec2, vec3, vec4, color

Features: Fonts Supports TTF fonts, loaded into atlas texture You receive data for this texture, need to upload it to GPU by yourself

Live demo

Conclusion Dear ImGui is good for: Dear ImGui is not good for: Internal in-game GUI for debugging purposes Easy to use Efficient to render Dear ImGui is not good for: Fully-featured game editor Not well suited for complicated GUI, better use system controls Final game HUD No possibility of skinning or making it look pretty You can always make your own implementation Based on idea of Immediate Mode GUI!

Thank you Questions?