1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-24 07:40:22 +01:00

Updated Getting Started (markdown)

omar 2024-10-29 16:57:40 +01:00
parent e5ec9a2519
commit ef83b506fd

@ -19,8 +19,11 @@ _(had to turn off wiki editing, see [Home](Home) for details. you may post meani
## Preamble
This is a Tutorial for getting Dear ImGui integrated in your application.
<BR>Also refer to our [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) and others [Wiki](https://github.com/ocornut/imgui/wiki) pages.
**This is a Tutorial for getting Dear ImGui integrated in your C++ application.**
<BR>This is not a Tutorial for _using_ the Dear ImGui API. For that, refer to the [Once you are setup...](#once-you-are-setup) section of this page.
Also refer to our [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) and others [Wiki](https://github.com/ocornut/imgui/wiki) pages.
<BR>For other programming languages or framework see our [Bindings/Backends](https://github.com/ocornut/imgui/wiki/Bindings) page.
Before anything, **Build and run one of the examples application, play around with it.**
<BR>With Visual Studio, open `examples/imgui_examples.sln`. XCode projects and Makefiles are also often provided.
@ -34,7 +37,7 @@ For various reasons, our examples are very raw: we don't load fancy fonts and ge
## Game Loop?
Dear ImGui comes from a game development background, where applications are expected to updating continuously at interactive framerates (e.g. 60 FPS) and where it is expected that an underlying graphics-heavy application is running and showing behind Dear ImGui. This is how our examples are generally structured. While it is technically possible to lift some of those assumptions when using Dear ImGui (e.g. going idle, using variable frame rates, having no "main viewport"), those uses cases are currently not well supported by default, requires a more intimate understanding of both the system and dear imgui, and are outside the scope of this article.
Dear ImGui comes from a game development background, where applications are expected to updating continuously at interactive framerates (e.g. 60 FPS) and where it is expected that an underlying graphics-heavy application is running and showing behind Dear ImGui. This is how our examples are generally structured. While it is technically possible to lift some of those assumptions when using Dear ImGui (e.g. going idle, using variable frame rates, having no "main viewport"), those uses cases are technically possible but currently not well supported by default, requires a more intimate understanding of both the system and dear imgui, and are outside the scope of this article.
A typical game-like application taking advantage of GPU rendering would run in a loop:
```cpp
@ -47,7 +50,7 @@ while (application_not_closed)
// Wait some time (e.g. 1/60 of a second)
}
```
In the case of your example application, we explicitly attempt to synchronize to screen refresh when swap/present, making the application refresh at the natural screen refresh rate. A full-fledged application may use different timing mechanism to throttle framerate, but this is outside of our scope.
In the case of your example application, we explicitly attempt to synchronize to screen refresh on swap/present, making the application refresh at the natural screen refresh rate. A full-fledged application may use different timing mechanism to throttle framerate, but this is outside of our scope.
## Compiling/Linking
@ -61,6 +64,8 @@ In the case of your example application, we explicitly attempt to synchronize to
- Visual Studio users: Add `misc/debuggers/imgui.natvis` and `misc/debuggers/imgui.natstepfilter` to improve the debugging experience.
- std::string users: Add `misc/cpp/imgui_stdlib.*` to easily use InputText with std::string.
It is recommended that you follow those steps and not attempt to build Dear ImGui as a static or shared library! It's perfectly possible to do, but if you are following a "Getting Started" guide the last thing you want to do is to create yourself more problems. Note that Dear ImGui is both small and easy to build, so adding its files directly to your project should be fine. Note that Dear ImGui is a very call-heavy API, so building as a shared library is not ideal because of increased function calling overhead.
**If your application already uses the API you pulled the backends for, things should compile and link already.**
Most users with linking problems are in fact having problems because of the underlying windowing or graphics tech they use. e.g. If you use DirectX11 you need to link with d3d11.lib, if you use SDL2 you need to obtain the library (from their website or vcpkg) and link with SDL2.lib+SDL2main.lib etc.
@ -70,7 +75,7 @@ If you are creating a new application from scratch: while it is generally outsid
## Setting up Dear ImGui & Backends
After this list we will show the corresponding code.
(below this list we will show the corresponding code)
- (1) Add `imgui/` to include paths. Include header files for main lib (`#include "imgui.h"`) + backends (e.g. `#include "imgui_impl_win32.h"`, `#include "imgui_impl_dx11.h"`).
- (2) Create Dear ImGui context with `ImGui::CreateContext()`.