The code in this repository integrates Dear ImGui into StereoKit (using sk_gpu for rendering).
It aids in rendering Dear ImGui draw lists into a StereoKit render target texture (tex_t
), while leaving all control in the user's hands.
See example/
for an example written in C++.
SKIG tries to do as little as possible. The user is expected to:
During application initialization:
- set up a Dear ImGui context and font,
- call
skig_init
to initialize the font atlas texture, - set up a StereoKit render target.
During application step:
- call
skig_begin
to save the default render pipeline state, - render as many Dear ImGui contexts as wanted:
- update Dear ImGui IO state,
- draw widgets as usual,
- call
ImGui::Render()
, - call
skig_render(renderTarget)
, which will callImGui::GetDrawData()
and render it to the passed in texture,
- call
skig_end
to restore the render pipeline state for main viewport.
During application exit, or when you want to free memory used by Dear ImGui:
- call
skig_destroy
.
example/
contains a simple C++ application based on the StereoKit native template.include/
contains the public headers.src/
contains the source code.
Changing the StereoKit or Dear ImGui version can be done using CMakeLists.txt
. This might become configurable in the future.
This repository contains a prebuilt imgui_shader.hlsl.h
from sk_gpu. If using a different version of StereoKit, you might need to copy a precompiled version, or build it manually using the shader compiler or editor, both of which are available in that repository.
Use CMake to generate the build configuration and run the build:
# Create a build directory
mkdir build
cd build
# Generate a build configuration. See the "configuring your build" section for more options.
cmake ..
# You can now build the project
cmake --build . --parallel 4
You can use these options to adjust the build:
-
-G
to change the build tool. -
-D CMAKE_BUILD_TYPE=Debug
to include debug symbols. -
-D SKIG_USE_CIMGUI
to link against cimgui instead of Dear ImGui.
CPM should make this process easy (see their documentation for how to include it):
# ...
CPMAddPackage(
NAME StereoKitImGui
GITHUB_REPOSITORY opl-/StereoKitImGui
GIT_TAG v1.0.0
# OPTIONS
# "SKIG_USE_CIMGUI ON"
)
target_link_libraries(yourProject StereoKitImGui)