README.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. -----------------------------------------------------------------------
  2. dear imgui, v1.71
  3. -----------------------------------------------------------------------
  4. examples/README.txt
  5. (This is the README file for the examples/ folder. See docs/ for more documentation)
  6. -----------------------------------------------------------------------
  7. Dear ImGui is highly portable and only requires a few things to run and render:
  8. - Providing mouse/keyboard inputs
  9. - Uploading the font atlas texture into graphics memory
  10. - Providing a render function to render indexed textured triangles
  11. - Optional: clipboard support, mouse cursor supports, Windows IME support, etc.
  12. - Optional (Advanced,Beta): platform window API to use multi-viewport.
  13. This is essentially what the example bindings in this folder are providing + obligatory portability cruft.
  14. It is important to understand the difference between the core Dear ImGui library (files in the root folder)
  15. and examples bindings which we are describing here (examples/ folder).
  16. You should be able to write bindings for pretty much any platform and any 3D graphics API. With some extra
  17. effort you can even perform the rendering remotely, on a different machine than the one running the logic.
  18. This folder contains two things:
  19. - Example bindings for popular platforms/graphics API, which you can use as is or adapt for your own use.
  20. They are the imgui_impl_XXXX files found in the examples/ folder.
  21. - Example applications (standalone, ready-to-build) using the aforementioned bindings.
  22. They are the in the XXXX_example/ sub-folders.
  23. You can find binaries of some of those example applications at:
  24. http://www.dearimgui.org/binaries
  25. ---------------------------------------
  26. MISC COMMENTS AND SUGGESTIONS
  27. ---------------------------------------
  28. - Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
  29. Please read the comments and instruction at the top of each file.
  30. - If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
  31. to your project and use them unmodified. Each imgui_impl_xxxx.cpp comes with its own individual
  32. ChangeLog at the top of the .cpp files, so if you want to update them later it will be easier to
  33. catch up with what changed.
  34. - Dear ImGui has 0 to 1 frame of lag for most behaviors, at 60 FPS your experience should be pleasant.
  35. However, consider that OS mouse cursors are typically drawn through a specific hardware accelerated path
  36. and will feel smoother than common GPU rendered contents (including Dear ImGui windows).
  37. You may experiment with the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor itself,
  38. to visualize the lag between a hardware cursor and a software cursor. However, rendering a mouse cursor
  39. at 60 FPS will feel slow. It might be beneficial to the user experience to switch to a software rendered
  40. cursor only when an interactive drag is in progress.
  41. Note that some setup or GPU drivers are likely to be causing extra lag depending on their settings.
  42. If you feel that dragging windows feels laggy and you are not sure who to blame: try to build an
  43. application drawing a shape directly under the mouse cursor.
  44. ---------------------------------------
  45. EXAMPLE BINDINGS
  46. ---------------------------------------
  47. Most the example bindings are split in 2 parts:
  48. - The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
  49. Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp)
  50. - The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data.
  51. Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp)
  52. - The example _applications_ usually combine 1 platform + 1 renderer binding to create a working program.
  53. Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp.
  54. - Some bindings for higher level frameworks carry both "Platform" and "Renderer" parts in one file.
  55. This is the case for Allegro 5 (imgui_impl_allegro5.cpp), Marmalade (imgui_impl_marmalade5.cpp).
  56. - If you use your own engine, you may decide to use some of existing bindings and/or rewrite some using
  57. your own API. As a recommendation, if you are new to Dear ImGui, try using the existing binding as-is
  58. first, before moving on to rewrite some of the code. Although it is tempting to rewrite both of the
  59. imgui_impl_xxxx files to fit under your coding style, consider that it is not necessary!
  60. In fact, if you are new to Dear ImGui, rewriting them will almost always be harder.
  61. Example: your engine is built over Windows + DirectX11 but you have your own high-level rendering
  62. system layered over DirectX11.
  63. Suggestion: step 1: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first.
  64. Once this work, _if_ you want you can replace the imgui_impl_dx11.cpp code with a custom renderer
  65. using your own functions, etc.
  66. Please consider using the bindings to the lower-level platform/graphics API as-is.
  67. Example: your engine is multi-platform (consoles, phones, etc.), you have high-level systems everywhere.
  68. Suggestion: step 1: try using a non-portable binding first (e.g. win32 + underlying graphics API)!
  69. This is counter-intuitive, but this will get you running faster! Once you better understand how imgui
  70. works and is bound, you can rewrite the code using your own systems.
  71. - Road-map: Dear ImGui 1.80 (WIP currently in the "docking" branch) will allows imgui windows to be
  72. seamlessly detached from the main application window. This is achieved using an extra layer to the
  73. platform and renderer bindings, which allows Dear ImGui to communicate platform-specific requests such as
  74. "create an additional OS window", "create a render context", "get the OS position of this window" etc.
  75. When using this feature, the coupling with your OS/renderer becomes much tighter than a regular imgui
  76. integration. It is also much more complicated and require more work to integrate correctly.
  77. If you are new to imgui and you are trying to integrate it into your application, first try to ignore
  78. everything related to Viewport and Platform Windows. You'll be able to come back to it later!
  79. Note that if you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit
  80. from improvements and fixes related to viewports and platform windows without extra work on your side.
  81. See 'ImGuiPlatformIO' for details.
  82. List of Platforms Bindings in this repository:
  83. imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/
  84. imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl back-ends)
  85. imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
  86. imgui_impl_win32.cpp ; Win32 native API (Windows)
  87. imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2019)
  88. List of Renderer Bindings in this repository:
  89. imgui_impl_dx9.cpp ; DirectX9
  90. imgui_impl_dx10.cpp ; DirectX10
  91. imgui_impl_dx11.cpp ; DirectX11
  92. imgui_impl_dx12.cpp ; DirectX12
  93. imgui_impl_metal.mm ; Metal (with ObjC)
  94. imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context)
  95. imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline)
  96. imgui_impl_vulkan.cpp ; Vulkan
  97. List of high-level Frameworks Bindings in this repository: (combine Platform + Renderer)
  98. imgui_impl_allegro5.cpp
  99. imgui_impl_marmalade.cpp
  100. Note that Dear ImGui works with Emscripten.
  101. The examples_emscripten/ app uses sdl.cpp + opengl3.cpp but other combinations are possible.
  102. Third-party framework, graphics API and languages bindings are listed at:
  103. https://github.com/ocornut/imgui/wiki/Bindings
  104. Languages: C, C#, ChaiScript, D, Go, Haxe, Java, Lua, Odin, Pascal, PureBasic, Python, Rust, Swift...
  105. Frameworks: Cinder, Cocoa (OSX), Cocos2d-x, SFML, GML/GameMaker Studio, Irrlicht, Ogre, OpenSceneGraph,
  106. openFrameworks, LOVE, NanoRT, Nim Game Lib, Qt3d, SFML, Unreal Engine 4...
  107. Miscellaneous: Software Renderer, RemoteImgui, etc.
  108. ---------------------------------------
  109. EXAMPLE APPLICATIONS
  110. ---------------------------------------
  111. Building:
  112. Unfortunately in 2018 it is still tedious to create and maintain portable build files using external
  113. libraries (the kind we're using here to create a window and render 3D triangles) without relying on
  114. third party software. For most examples here I choose to provide:
  115. - Makefiles for Linux/OSX
  116. - Batch files for Visual Studio 2008+
  117. - A .sln project file for Visual Studio 2010+
  118. - Xcode project files for the Apple examples
  119. Please let me know if they don't work with your setup!
  120. You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those
  121. directly with a command-line compiler.
  122. example_allegro5/
  123. Allegro 5 example.
  124. = main.cpp + imgui_impl_allegro5.cpp
  125. example_apple_metal/
  126. OSX & iOS + Metal.
  127. = main.m + imgui_impl_osx.mm + imgui_impl_metal.mm
  128. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9.
  129. (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends.
  130. You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.)
  131. example_apple_opengl2/
  132. OSX + OpenGL2.
  133. = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp
  134. (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends.
  135. You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.)
  136. example_empscripten:
  137. Emcripten + SDL2 + OpenGL3+/ES2/ES3 example.
  138. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
  139. Note that other examples based on SDL or GLFW + OpenGL could easily be modified to work with Emscripten.
  140. We provide this to make the Emscripten differences obvious, and have them not pollute all other examples.
  141. example_glfw_metal/
  142. GLFW (Mac) + Metal example.
  143. = main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm.
  144. example_glfw_opengl2/
  145. GLFW + OpenGL2 example (legacy, fixed pipeline).
  146. = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
  147. **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
  148. **Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)**
  149. This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
  150. If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
  151. make things more complicated, will require your code to reset many OpenGL attributes to their initial
  152. state, and might confuse your GPU driver. One star, not recommended.
  153. example_glfw_opengl3/
  154. GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline).
  155. = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
  156. This uses more modern OpenGL calls and custom shaders.
  157. Prefer using that if you are using modern OpenGL in your application (anything with shaders).
  158. (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent
  159. source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different
  160. from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.)
  161. example_glfw_vulkan/
  162. GLFW (Win32, Mac, Linux) + Vulkan example.
  163. = main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
  164. This is quite long and tedious, because: Vulkan.
  165. example_glut_opengl2/
  166. GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
  167. = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
  168. Note that GLUT/FreeGLUT is largely obsolete software, prefer using GLFW or SDL.
  169. example_marmalade/
  170. Marmalade example using IwGx.
  171. = main.cpp + imgui_impl_marmalade.cpp
  172. example_null
  173. Null example, compile and link imgui, create context, run headless with no inputs and no graphics output.
  174. = main.cpp
  175. This is used to quickly test compilation of core imgui files in as many setups as possible.
  176. Because this application doesn't create a window nor a graphic context, there's no graphics output.
  177. example_sdl_opengl2/
  178. SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
  179. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
  180. **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
  181. **Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)**
  182. This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
  183. If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
  184. make things more complicated, will require your code to reset many OpenGL attributes to their initial
  185. state, and might confuse your GPU driver. One star, not recommended.
  186. example_sdl_opengl3/
  187. SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example.
  188. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
  189. This uses more modern OpenGL calls and custom shaders.
  190. Prefer using that if you are using modern OpenGL in your application (anything with shaders).
  191. (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent
  192. source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different
  193. from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.)
  194. example_sdl_vulkan/
  195. SDL2 (Win32, Mac, Linux, etc.) + Vulkan example.
  196. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
  197. This is quite long and tedious, because: Vulkan.
  198. example_win32_directx9/
  199. DirectX9 example, Windows only.
  200. = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp
  201. example_win32_directx10/
  202. DirectX10 example, Windows only.
  203. = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp
  204. example_win32_directx11/
  205. DirectX11 example, Windows only.
  206. = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp
  207. example_win32_directx12/
  208. DirectX12 example, Windows only.
  209. = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp
  210. This is quite long and tedious, because: DirectX12.