Proxy 1

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

-----------------------------------------------------------------------

dear imgui, v1.75 WIP


-----------------------------------------------------------------------
examples/README.txt
(This is the README file for the examples/ folder. See docs/ for more
documentation)
-----------------------------------------------------------------------

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.

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.

You can find binaries of some of those example applications at:

---------------------------------------
MISC COMMENTS AND SUGGESTIONS
---------------------------------------

- Read FAQ at

- 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.

- If you are using of the backend provided here, so you can copy the
imgui_impl_xxx.cpp/h files
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
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,
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
cursor only when an interactive drag is in progress.
Note that some setup or GPU drivers are likely to be causing extra lag depending
on their settings.
If you feel that dragging windows feels laggy and you are not sure who to blame:
try to build an
application drawing a shape directly under the mouse cursor.

---------------------------------------
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.
Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2
(imgui_impl_sdl.cpp), etc.

- 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), etc.

- The example _applications_ usually combine 1 platform + 1 renderer binding to


create a working program.
Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp
+ imgui_impl_dx11.cpp.

- 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).

- If you use your own engine, you may decide to use some of existing bindings
and/or rewrite some using
your own API. As a recommendation, if you are new to Dear ImGui, try using the
existing binding as-is
first, before moving on to rewrite some of the code. Although it is tempting to
rewrite both of the
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.

Example: your engine is built over Windows + DirectX11 but you have your own
high-level rendering
system layered over DirectX11.
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.
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.

- Road-map: Dear ImGui 1.80 (WIP currently in the "docking" branch) will allows
imgui windows to be
seamlessly detached from the main application window. This is achieved using an
extra layer to the
platform and renderer bindings, which allows Dear ImGui to communicate platform-
specific requests.
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.

List of Platforms Bindings in this repository:

imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.)


imgui_impl_osx.mm ; macOS native API (not as feature complete as
glfw/sdl back-ends)
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android)
imgui_impl_win32.cpp ; Win32 native API (Windows)
imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2019)

You might also like