2018-08-31 17:33:12 +08:00
|
|
|
-----------------------------------------------------------------------
|
|
|
|
examples/README.txt
|
|
|
|
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
|
|
|
-----------------------------------------------------------------------
|
2016-03-29 17:33:23 +08:00
|
|
|
|
2018-06-08 05:48:34 +08:00
|
|
|
Dear ImGui is highly portable and only requires a few things to run and render:
|
|
|
|
|
|
|
|
- Providing mouse/keyboard inputs
|
|
|
|
- Uploading the font atlas texture into graphics memory
|
|
|
|
- Providing a render function to render indexed textured triangles
|
|
|
|
- Optional: clipboard support, mouse cursor supports, Windows IME support, etc.
|
|
|
|
- Optional (Advanced,Beta): platform window API to use multi-viewport.
|
|
|
|
|
|
|
|
This is essentially what the example bindings in this folder are providing + obligatory portability cruft.
|
|
|
|
|
|
|
|
It is important to understand the difference between the core Dear ImGui library (files in the root folder)
|
|
|
|
and examples bindings which we are describing here (examples/ folder).
|
|
|
|
You should be able to write bindings for pretty much any platform and any 3D graphics API. With some extra
|
|
|
|
effort you can even perform the rendering remotely, on a different machine than the one running the logic.
|
|
|
|
|
|
|
|
This folder contains two things:
|
|
|
|
|
|
|
|
- Example bindings for popular platforms/graphics API, which you can use as is or adapt for your own use.
|
|
|
|
They are the imgui_impl_XXXX files found in the examples/ folder.
|
|
|
|
|
|
|
|
- Example applications (standalone, ready-to-build) using the aforementioned bindings.
|
|
|
|
They are the in the XXXX_example/ sub-folders.
|
|
|
|
|
2019-01-21 05:23:29 +08:00
|
|
|
You can find binaries of some of those example applications at:
|
2018-06-08 05:48:34 +08:00
|
|
|
http://www.miracleworld.net/imgui/binaries
|
2018-01-25 01:40:23 +08:00
|
|
|
|
2015-11-29 18:53:03 +08:00
|
|
|
|
2018-06-08 05:48:34 +08:00
|
|
|
---------------------------------------
|
|
|
|
MISC COMMENTS AND SUGGESTIONS
|
|
|
|
---------------------------------------
|
|
|
|
|
2018-06-12 01:52:40 +08:00
|
|
|
- Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
|
|
|
Please read the comments and instruction at the top of each file.
|
2019-01-21 05:23:29 +08:00
|
|
|
|
2015-11-29 19:01:50 +08:00
|
|
|
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
|
2018-06-08 05:48:34 +08:00
|
|
|
to your project and use them unmodified. Each imgui_impl_xxxx.cpp comes with its own individual
|
|
|
|
ChangeLog at the top of the .cpp files, so if you want to update them later it will be easier to
|
|
|
|
catch up with what changed.
|
|
|
|
|
|
|
|
- Dear ImGui has 0 to 1 frame of lag for most behaviors, at 60 FPS your experience should be pleasant.
|
|
|
|
However, consider that OS mouse cursors are typically drawn through a specific hardware accelerated path
|
2019-01-21 05:23:29 +08:00
|
|
|
and will feel smoother than common GPU rendered contents (including Dear ImGui windows).
|
|
|
|
You may experiment with the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor itself,
|
2018-06-08 05:48:34 +08:00
|
|
|
to visualize the lag between a hardware cursor and a software cursor. However, rendering a mouse cursor
|
|
|
|
at 60 FPS will feel slow. It might be beneficial to the user experience to switch to a software rendered
|
2019-01-21 05:23:29 +08:00
|
|
|
cursor only when an interactive drag is in progress.
|
2018-06-08 05:48:34 +08:00
|
|
|
Note that some setup or GPU drivers are likely to be causing extra lag depending on their settings.
|
2019-01-21 05:23:29 +08:00
|
|
|
If you feel that dragging windows feels laggy and you are not sure who to blame: try to build an
|
2018-06-12 01:52:40 +08:00
|
|
|
application drawing a shape directly under the mouse cursor.
|
2018-01-25 01:40:23 +08:00
|
|
|
|
2016-01-22 02:51:42 +08:00
|
|
|
|
2018-06-08 05:48:34 +08:00
|
|
|
---------------------------------------
|
|
|
|
EXAMPLE BINDINGS
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
Most the example bindings are split in 2 parts:
|
|
|
|
|
|
|
|
- The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
|
2018-06-10 21:45:54 +08:00
|
|
|
Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp)
|
2018-06-08 05:48:34 +08:00
|
|
|
|
|
|
|
- The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data.
|
|
|
|
Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp)
|
|
|
|
|
|
|
|
- The example _applications_ usually combine 1 platform + 1 renderer binding to create a working program.
|
2018-06-10 22:14:43 +08:00
|
|
|
Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp.
|
2018-06-08 05:48:34 +08:00
|
|
|
|
|
|
|
- Some bindings for higher level frameworks carry both "Platform" and "Renderer" parts in one file.
|
|
|
|
This is the case for Allegro 5 (imgui_impl_allegro5.cpp), Marmalade (imgui_impl_marmalade5.cpp).
|
|
|
|
|
2019-01-21 05:23:29 +08:00
|
|
|
- If you use your own engine, you may decide to use some of existing bindings and/or rewrite some using
|
2018-06-08 05:48:34 +08:00
|
|
|
your own API. As a recommendation, if you are new to Dear ImGui, try using the existing binding as-is
|
2019-01-21 05:23:29 +08:00
|
|
|
first, before moving on to rewrite some of the code. Although it is tempting to rewrite both of the
|
2018-06-08 05:48:34 +08:00
|
|
|
imgui_impl_xxxx files to fit under your coding style, consider that it is not necessary!
|
|
|
|
In fact, if you are new to Dear ImGui, rewriting them will almost always be harder.
|
|
|
|
|
2019-01-21 05:23:29 +08:00
|
|
|
Example: your engine is built over Windows + DirectX11 but you have your own high-level rendering
|
2018-06-12 01:52:40 +08:00
|
|
|
system layered over DirectX11.
|
2019-01-21 05:23:29 +08:00
|
|
|
Suggestion: step 1: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first.
|
|
|
|
Once this work, _if_ you want you can replace the imgui_impl_dx11.cpp code with a custom renderer
|
|
|
|
using your own functions, etc.
|
2018-06-08 05:48:34 +08:00
|
|
|
Please consider using the bindings to the lower-level platform/graphics API as-is.
|
|
|
|
|
|
|
|
Example: your engine is multi-platform (consoles, phones, etc.), you have high-level systems everywhere.
|
|
|
|
Suggestion: step 1: try using a non-portable binding first (e.g. win32 + underlying graphics API)!
|
|
|
|
This is counter-intuitive, but this will get you running faster! Once you better understand how imgui
|
|
|
|
works and is bound, you can rewrite the code using your own systems.
|
|
|
|
|
2019-01-21 23:52:22 +08:00
|
|
|
- From Dear ImGui 1.XX we added an (optional) feature called "viewport" which allows imgui windows to be
|
2019-01-21 05:23:29 +08:00
|
|
|
seamlessly detached from the main application window. This is achieved using an extra layer to the
|
2019-01-21 23:52:22 +08:00
|
|
|
platform and renderer bindings, which allows imgui to communicate platform-specific requests such as
|
|
|
|
"create an additional OS window", "create a render context", "get the OS position of this window" etc.
|
|
|
|
When using this feature, the coupling with your OS/renderer becomes much tighter than a regular imgui
|
2018-06-08 05:48:34 +08:00
|
|
|
integration. It is also much more complicated and require more work to integrate correctly.
|
|
|
|
If you are new to imgui and you are trying to integrate it into your application, first try to ignore
|
|
|
|
everything related to Viewport and Platform Windows. You'll be able to come back to it later!
|
2018-06-12 01:52:40 +08:00
|
|
|
Note that if you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit
|
|
|
|
from improvements and fixes related to viewports and platform windows without extra work on your side.
|
2019-01-21 23:52:22 +08:00
|
|
|
See 'ImGuiPlatformIO' for details.
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-09 01:37:33 +08:00
|
|
|
|
2018-06-12 01:27:11 +08:00
|
|
|
List of Platforms Bindings in this repository:
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-12 01:27:11 +08:00
|
|
|
imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/
|
2018-07-04 19:13:11 +08:00
|
|
|
imgui_impl_osx.mm ; macOS native API
|
2018-06-12 01:27:11 +08:00
|
|
|
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
2018-07-08 16:57:16 +08:00
|
|
|
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
2018-06-12 01:27:11 +08:00
|
|
|
imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's)
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-12 01:27:11 +08:00
|
|
|
List of Renderer Bindings in this repository:
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-12 01:27:11 +08:00
|
|
|
imgui_impl_dx9.cpp ; DirectX9
|
|
|
|
imgui_impl_dx10.cpp ; DirectX10
|
|
|
|
imgui_impl_dx11.cpp ; DirectX11
|
2018-07-08 16:47:31 +08:00
|
|
|
imgui_impl_dx12.cpp ; DirectX12
|
|
|
|
imgui_impl_metal.mm ; Metal (with ObjC)
|
2018-06-12 01:52:40 +08:00
|
|
|
imgui_impl_opengl2.cpp ; OpenGL2 (legacy, fixed pipeline <- don't use with modern OpenGL context)
|
2018-08-09 23:42:53 +08:00
|
|
|
imgui_impl_opengl3.cpp ; OpenGL3, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline)
|
2018-06-12 01:27:11 +08:00
|
|
|
imgui_impl_vulkan.cpp ; Vulkan
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-12 01:27:11 +08:00
|
|
|
List of high-level Frameworks Bindings in this repository: (combine Platform + Renderer)
|
2018-06-08 05:48:34 +08:00
|
|
|
|
|
|
|
imgui_impl_allegro5.cpp
|
|
|
|
imgui_impl_marmalade.cpp
|
|
|
|
|
2018-06-16 16:23:11 +08:00
|
|
|
Third-party framework, graphics API and languages bindings are listed at:
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-16 16:43:05 +08:00
|
|
|
https://github.com/ocornut/imgui/wiki/Bindings
|
2018-06-08 05:48:34 +08:00
|
|
|
|
|
|
|
Languages: C, C#, ChaiScript, D, Go, Haxe, Java, Lua, Odin, Pascal, PureBasic, Python, Rust, Swift...
|
2019-01-21 05:23:29 +08:00
|
|
|
Frameworks: Cinder, Cocoa (OSX), Cocos2d-x, Emscripten, SFML, GML/GameMaker Studio, Irrlicht, Ogre,
|
2018-06-08 05:48:34 +08:00
|
|
|
OpenSceneGraph, openFrameworks, LOVE, NanoRT, Nim Game Lib, Qt3d, SFML, Unreal Engine 4...
|
|
|
|
Miscellaneous: Software Renderer, RemoteImgui, etc.
|
|
|
|
|
|
|
|
|
|
|
|
---------------------------------------
|
|
|
|
EXAMPLE APPLICATIONS
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
Building:
|
2019-01-21 05:23:29 +08:00
|
|
|
Unfortunately in 2018 it is still tedious to create and maintain portable build files using external
|
|
|
|
libraries (the kind we're using here to create a window and render 3D triangles) without relying on
|
2018-06-08 05:48:34 +08:00
|
|
|
third party software. For most examples here I choose to provide:
|
|
|
|
- Makefiles for Linux/OSX
|
|
|
|
- Batch files for Visual Studio 2008+
|
2019-01-21 05:23:29 +08:00
|
|
|
- A .sln project file for Visual Studio 2010+
|
2018-07-08 16:47:31 +08:00
|
|
|
- Xcode project files for the Apple examples
|
2018-06-08 05:48:34 +08:00
|
|
|
Please let me know if they don't work with your setup!
|
|
|
|
You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those
|
|
|
|
directly with a command-line compiler.
|
2015-02-24 17:59:56 +08:00
|
|
|
|
2015-03-09 23:09:24 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_win32_directx9/
|
2015-03-09 23:09:24 +08:00
|
|
|
DirectX9 example, Windows only.
|
2018-06-08 05:48:34 +08:00
|
|
|
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp
|
2019-01-21 05:23:29 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_win32_directx10/
|
2015-12-04 02:32:01 +08:00
|
|
|
DirectX10 example, Windows only.
|
2018-06-08 05:48:34 +08:00
|
|
|
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp
|
2015-12-04 02:32:01 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_win32_directx11/
|
2015-03-09 23:09:24 +08:00
|
|
|
DirectX11 example, Windows only.
|
2018-06-08 05:48:34 +08:00
|
|
|
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp
|
2019-01-21 05:23:29 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_win32_directx12/
|
2016-02-23 07:22:48 +08:00
|
|
|
DirectX12 example, Windows only.
|
2018-06-08 05:48:34 +08:00
|
|
|
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp
|
2019-01-18 01:04:35 +08:00
|
|
|
This is quite long and tedious, because: DirectX12.
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-07-08 16:57:16 +08:00
|
|
|
example_apple_metal/
|
|
|
|
OSX & iOS + Metal.
|
2019-01-18 01:04:35 +08:00
|
|
|
= main.m + imgui_impl_osx.mm + imgui_impl_metal.mm
|
2018-07-08 16:57:16 +08:00
|
|
|
It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
|
2018-07-08 17:16:11 +08:00
|
|
|
(NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.)
|
2018-07-08 16:57:16 +08:00
|
|
|
|
|
|
|
example_apple_opengl2/
|
|
|
|
OSX + OpenGL2.
|
|
|
|
= main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp
|
2019-01-18 01:04:35 +08:00
|
|
|
(NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.)
|
2018-07-08 16:57:16 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_glfw_opengl2/
|
2019-01-18 01:04:35 +08:00
|
|
|
GLFW + OpenGL2 example (legacy, fixed pipeline).
|
|
|
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
|
2018-06-10 21:42:14 +08:00
|
|
|
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
|
|
|
**Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)**
|
2018-09-13 22:44:08 +08:00
|
|
|
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
2018-06-08 05:48:34 +08:00
|
|
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
|
|
|
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
|
|
|
state, and might confuse your GPU driver. One star, not recommended.
|
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_glfw_opengl3/
|
2019-01-18 01:04:35 +08:00
|
|
|
GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline).
|
|
|
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
|
2019-01-21 05:23:29 +08:00
|
|
|
This uses more modern OpenGL calls and custom shaders.
|
2018-06-08 05:48:34 +08:00
|
|
|
Prefer using that if you are using modern OpenGL in your application (anything with shaders).
|
2019-01-21 05:23:29 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_glfw_vulkan/
|
|
|
|
GLFW (Win32, Mac, Linux) + Vulkan example.
|
2018-06-08 05:48:34 +08:00
|
|
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
|
2019-01-18 01:04:35 +08:00
|
|
|
This is quite long and tedious, because: Vulkan.
|
2015-07-08 23:49:32 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_sdl_opengl2/
|
2019-01-18 01:04:35 +08:00
|
|
|
SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
|
|
|
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
|
2018-06-10 21:42:14 +08:00
|
|
|
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
|
|
|
**Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)**
|
2018-09-13 22:44:08 +08:00
|
|
|
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
2018-02-23 06:20:37 +08:00
|
|
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
2018-06-08 05:48:34 +08:00
|
|
|
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
2019-01-21 05:23:29 +08:00
|
|
|
state, and might confuse your GPU driver. One star, not recommended.
|
2015-07-09 01:46:18 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_sdl_opengl3/
|
2018-08-09 23:42:53 +08:00
|
|
|
SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example.
|
2019-01-18 01:04:35 +08:00
|
|
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
|
2019-01-21 05:23:29 +08:00
|
|
|
This uses more modern OpenGL calls and custom shaders.
|
2018-02-23 06:20:37 +08:00
|
|
|
Prefer using that if you are using modern OpenGL in your application (anything with shaders).
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_sdl_vulkan/
|
2018-06-08 05:48:34 +08:00
|
|
|
SDL2 (Win32, Mac, Linux, etc.) + Vulkan example.
|
2018-06-10 21:45:54 +08:00
|
|
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
|
2019-01-18 01:04:35 +08:00
|
|
|
This is quite long and tedious, because: Vulkan.
|
2018-06-08 05:48:34 +08:00
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_allegro5/
|
2015-07-09 22:39:44 +08:00
|
|
|
Allegro 5 example.
|
2018-06-08 05:48:34 +08:00
|
|
|
= main.cpp + imgui_impl_allegro5.cpp
|
|
|
|
|
2018-06-12 01:52:40 +08:00
|
|
|
example_freeglut_opengl2/
|
|
|
|
FreeGLUT + OpenGL2.
|
|
|
|
= main.cpp + imgui_impl_freeglut.cpp + imgui_impl_opengl2.cpp
|
|
|
|
|
2018-06-10 21:42:14 +08:00
|
|
|
example_marmalade/
|
|
|
|
Marmalade example using IwGx.
|
2018-06-08 05:48:34 +08:00
|
|
|
= main.cpp + imgui_impl_marmalade.cpp
|