mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-14 19:04:44 +00:00
How to render 3D scene within UI Element ? #475
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#475
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
I am new to imgui. After done some reading, I notice there is a way to render 3D scene in UI Element which is using ImDrawCallBack. However, I still have no clue on how to use this function.
Can show me an example on how to use this function ? Or is there any other simple way to do it.
Using OpenGL/GLFW.
The easiest way is likely to setup a new render target before you render the UI element and then use that render target later in your rendering which you want to render.
If you use the callback system the render loop code will just call your function in the right order (ImGui render window back-to-front). What the callback does is all up to you. Typically you'd want to pass data in the void*, what to render, where to render it, etc. And then the callback can act upon that.
Another solution is to render your scene in a texture/buffer and then use facilities such as ImGui::Image() to just draw this buffer within your UI. This is generally easier to play with, if you can get your scene in a texture first. (Using a callback would technically have the advantage that you can avoid an additional transfer of the pixels, if you are only rendering to a texture for imgui and it isn't needed by your game, but it may probably a bearable cost for flexibility).
I realise that I read the question wrong. I though the question was on how to render a UI element in a 3D world. Sorry about the confusion reply then :)
No problem emoon and thanks for the suggestions ocornut.
I will do offscreen rendering to texture using Frame Buffer Object(FBO) since its much more easier for me. I will close this now.