Skip to content

Commit

Permalink
ImGuiIntegration: document large mesh support
Browse files Browse the repository at this point in the history
  • Loading branch information
pezcode committed Feb 5, 2022
1 parent d6d9610 commit b484d1f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/namespaces.dox
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ See also @ref building-integration and @ref cmake-integration. See the

Conversion of math classes and rendering of Dear ImGui using Magnum.

@section ImGuiIntegration-usage Usage

This library depends on [Dear ImGui](https://github.com/ocornut/imgui) and is
built if `WITH_IMGUI` is enabled when building Magnum Integration. To use this
library with CMake, put [FindMagnumIntegration.cmake](https://github.com/mosra/magnum-integration/blob/master/modules/FindMagnumIntegration.cmake)
Expand All @@ -390,6 +392,8 @@ set(WITH_IMGUI ON CACHE BOOL "" FORCE)
add_subdirectory(magnum-integration EXCLUDE_FROM_ALL)
@endcode

@section ImGuiIntegration-configuration Configuration

Dear ImGui configuration can normally be manipulated at compile time by
defining `IMGUI_USER_CONFIG` which is then included by the Dear ImGui library.
However, this library already uses this feature and defining
Expand Down
29 changes: 29 additions & 0 deletions src/Magnum/ImGuiIntegration/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,35 @@ If you don't do that, the fonts stay at the original scale, not matching the
new UI scaling anymore. If you didn't supply any custom font, the function will
reconfigure the builtin font automatically.
@section ImGuiIntegration-Context-large-meshes Large meshes
Complex user interfaces or widgets like [ImPlot](https://github.com/epezent/implot)
may end up creating large meshes with more than 64,000 vertices. Because ImGui
defaults to 16-bit index buffers this can lead to asserts or visual errors.
If the underlying GL context supports @ref GL::Mesh::setBaseVertex() "setting the base vertex for indexed meshes"
the rendering backend sets the @cpp ImGuiBackendFlags_RendererHasVtxOffset @ce
flag. This lets ImGui know the backend can handle per-draw vertex offsets,
allowing meshes with a little over 2 million vertices. Support for that
requires one of the following:
- OpenGL 3.2 and higher or extension `ARB_draw_elements_base_vertex`
- OpenGL ES 3.2 or extension `OES_draw_elements_base_vertex` or
`EXT_draw_elements_base_vertex`
- WebGL 2.0 and extension `WEBGL_draw_instanced_base_vertex_base_instance`
If you can't guarantee that the required GL versions or extensions will be
available at runtime (mostly relevant on WebGL) the next best option is to
change ImGui's index type to 32-bit by adding the following line to the
@ref ImGuiIntegration-configuration "ImGui user config":
@code{.cpp}
#define ImDrawIdx unsigned int
@endcode
This doubles the size of the index buffer but is guaranteed to work on all GL
versions.
@section ImGuiIntegration-Context-multiple-contexts Multiple contexts
Each instance of @ref Context creates a new ImGui context. You can also pass an
Expand Down

0 comments on commit b484d1f

Please sign in to comment.