mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
Update FAQ.md
This commit is contained in:
parent
bdce833636
commit
f60518b430
35
docs/FAQ.md
35
docs/FAQ.md
@ -44,11 +44,10 @@ or view this file with any Markdown viewer.
|
|||||||
### Q: Where is the documentation?
|
### Q: Where is the documentation?
|
||||||
|
|
||||||
**This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.**
|
**This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.**
|
||||||
- Run the examples/ and explore them.
|
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them.
|
||||||
- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function.
|
- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
||||||
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
|
||||||
- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h).
|
- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h).
|
||||||
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application.
|
- The [Wiki](https://github.com/ocornut/imgui/wiki) has many resources and links.
|
||||||
- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
|
- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -131,13 +130,14 @@ e.g. `if (ImGui::GetIO().WantCaptureMouse) { ... }`
|
|||||||
### Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
|
### Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
|
||||||
- You can control Dear ImGui with a gamepad. Read about navigation in "Using gamepad/keyboard navigation controls".
|
- You can control Dear ImGui with a gamepad. Read about navigation in "Using gamepad/keyboard navigation controls".
|
||||||
(short version: map gamepad inputs into the io.NavInputs[] array + set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad`).
|
(short version: map gamepad inputs into the io.NavInputs[] array + set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad`).
|
||||||
|
- See navigation [control sheets for gamepads](http://www.dearimgui.org/controls_sheets) (for PS4, XB1, Switch gamepads).
|
||||||
- You can share your computer mouse seamlessly with your console/tablet/phone using [Synergy](https://symless.com/synergy)
|
- You can share your computer mouse seamlessly with your console/tablet/phone using [Synergy](https://symless.com/synergy)
|
||||||
This is the preferred solution for developer productivity.
|
This is the preferred solution for developer productivity.
|
||||||
In particular, the [micro-synergy-client repository](https://github.com/symless/micro-synergy-client) has simple
|
In particular, the [micro-synergy-client repository](https://github.com/symless/micro-synergy-client) has simple
|
||||||
and portable source code (uSynergy.c/.h) for a small embeddable client that you can use on any platform to connect
|
and portable source code (uSynergy.c/.h) for a small embeddable client that you can use on any platform to connect
|
||||||
to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer.
|
to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer.
|
||||||
Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols.
|
Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols.
|
||||||
- You may also use a third party solution such as [Remote ImGui](https://github.com/JordiRos/remoteimgui) or [imgui-ws](https://github.com/ggerganov/imgui-ws) which sends the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine. See Wiki index for most details.
|
- You may also use a third party solution such as [Remote ImGui](https://github.com/JordiRos/remoteimgui) or [imgui-ws](https://github.com/ggerganov/imgui-ws) which sends the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine. See [Wiki](https://github.com/ocornut/imgui/wiki) index for most details.
|
||||||
- For touch inputs, you can increase the hit box of widgets (via the `style.TouchPadding` setting) to accommodate
|
- For touch inputs, you can increase the hit box of widgets (via the `style.TouchPadding` setting) to accommodate
|
||||||
for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing
|
for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing
|
||||||
for screen real-estate and precision.
|
for screen real-estate and precision.
|
||||||
@ -283,7 +283,7 @@ node open/closed state differently. See what makes more sense in your situation!
|
|||||||
### Q: How can I display an image? What is ImTextureID, how does it work?
|
### Q: How can I display an image? What is ImTextureID, how does it work?
|
||||||
|
|
||||||
Short explanation:
|
Short explanation:
|
||||||
- Please read Wiki entry for examples: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
- Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki).
|
||||||
- You may use functions such as `ImGui::Image()`, `ImGui::ImageButton()` or lower-level `ImDrawList::AddImage()` to emit draw calls that will use your own textures.
|
- You may use functions such as `ImGui::Image()`, `ImGui::ImageButton()` or lower-level `ImDrawList::AddImage()` to emit draw calls that will use your own textures.
|
||||||
- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value.
|
- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value.
|
||||||
- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason).
|
- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason).
|
||||||
@ -301,15 +301,18 @@ Dear ImGui doesn't know or understand what you are storing in ImTextureID, it me
|
|||||||
OpenGL:
|
OpenGL:
|
||||||
- ImTextureID = GLuint
|
- ImTextureID = GLuint
|
||||||
- See ImGui_ImplOpenGL3_RenderDrawData() function in imgui_impl_opengl3.cpp
|
- See ImGui_ImplOpenGL3_RenderDrawData() function in imgui_impl_opengl3.cpp
|
||||||
|
```
|
||||||
|
```
|
||||||
DirectX9:
|
DirectX9:
|
||||||
- ImTextureID = LPDIRECT3DTEXTURE9
|
- ImTextureID = LPDIRECT3DTEXTURE9
|
||||||
- See ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp
|
- See ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp
|
||||||
|
```
|
||||||
|
```
|
||||||
DirectX11:
|
DirectX11:
|
||||||
- ImTextureID = ID3D11ShaderResourceView*
|
- ImTextureID = ID3D11ShaderResourceView*
|
||||||
- See ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp
|
- See ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp
|
||||||
|
```
|
||||||
|
```
|
||||||
DirectX12:
|
DirectX12:
|
||||||
- ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE
|
- ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE
|
||||||
- See ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp
|
- See ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp
|
||||||
@ -337,7 +340,7 @@ Once you understand this design you will understand that loading image files and
|
|||||||
This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them.
|
This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them.
|
||||||
If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using.
|
If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using.
|
||||||
|
|
||||||
Refer to the Wiki to find simplified examples for loading textures with OpenGL, DirectX9 and DirectX11: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki) to find simplified examples for loading textures with OpenGL, DirectX9 and DirectX11.
|
||||||
|
|
||||||
C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa.
|
C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa.
|
||||||
Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*.
|
Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*.
|
||||||
@ -442,7 +445,7 @@ New programmers: remember that in C/C++ and most programming languages if you wa
|
|||||||
backslash \ within a string literal, you need to write it double backslash "\\":
|
backslash \ within a string literal, you need to write it double backslash "\\":
|
||||||
|
|
||||||
```c
|
```c
|
||||||
io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escape the M here!)
|
io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escaping the M here!)
|
||||||
io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size; // CORRECT
|
io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size; // CORRECT
|
||||||
io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
||||||
```
|
```
|
||||||
@ -452,7 +455,7 @@ io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
|||||||
### Q: How can I easily use icons in my application?
|
### Q: How can I easily use icons in my application?
|
||||||
The most convenient and practical way is to merge an icon font such as FontAwesome inside you
|
The most convenient and practical way is to merge an icon font such as FontAwesome inside you
|
||||||
main font. Then you can refer to icons within your strings.
|
main font. Then you can refer to icons within your strings.
|
||||||
You may want to see ImFontConfig::GlyphMinAdvanceX to make your icon look monospace to facilitate alignment.
|
You may want to see `ImFontConfig::GlyphMinAdvanceX` to make your icon look monospace to facilitate alignment.
|
||||||
(Read the [docs/FONTS.txt](https://github.com/ocornut/imgui/blob/master/docs/FONTS.txt) file for more details about icons font loading.)
|
(Read the [docs/FONTS.txt](https://github.com/ocornut/imgui/blob/master/docs/FONTS.txt) file for more details about icons font loading.)
|
||||||
With some extra effort, you may use colorful icon by registering custom rectangle space inside the font atlas,
|
With some extra effort, you may use colorful icon by registering custom rectangle space inside the font atlas,
|
||||||
and copying your own graphics data into it. See docs/FONTS.txt about using the AddCustomRectFontGlyph API.
|
and copying your own graphics data into it. See docs/FONTS.txt about using the AddCustomRectFontGlyph API.
|
||||||
@ -513,7 +516,7 @@ by using the u8"hello" syntax. Specifying literal in your source code using a lo
|
|||||||
(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
|
(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
|
||||||
Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
|
Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
|
||||||
|
|
||||||
Text input: it is up to your application to pass the right character code by calling io.AddInputCharacter().
|
Text input: it is up to your application to pass the right character code by calling `io.AddInputCharacter()`.
|
||||||
The applications in examples/ are doing that.
|
The applications in examples/ are doing that.
|
||||||
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
|
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
|
||||||
You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
|
You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
|
||||||
@ -529,8 +532,8 @@ the default implementation of io.ImeSetInputScreenPosFn() to set your Microsoft
|
|||||||
- Businesses: convince your company to fund development via support contracts/sponsoring! This is among the most useful thing you can do for Dear ImGui. With increased funding we will be able to hire more people working on this project.
|
- Businesses: convince your company to fund development via support contracts/sponsoring! This is among the most useful thing you can do for Dear ImGui. With increased funding we will be able to hire more people working on this project.
|
||||||
- Individuals: you can also become a [Patron](http://www.patreon.com/imgui) or donate on PayPal! See README.
|
- Individuals: you can also become a [Patron](http://www.patreon.com/imgui) or donate on PayPal! See README.
|
||||||
- Disclose your usage of dear imgui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
- Disclose your usage of dear imgui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
||||||
You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/2847). Visuals are ideal as they inspire other programmers.
|
You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/2847). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
|
||||||
But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
|
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
||||||
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete pR.
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user