mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-14 19:04:44 +00:00
ImGui::Image example DX9 ? #510
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#510
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?
Not really an issue, but rather a noob question.
Does anyone have a tiny example how I can load and use my own textures in dx9 with imgui:image ?
I'm not very experienced in dx drawing stuff and only managed to get a white empty rectangle showing up in imgui..so I guess I'm missing something.
In my Init func, I'm loading the texture from the file into memory:
static LPDIRECT3DTEXTURE9 pTexture= NULL;
D3DXCreateTextureFromFile(g_pD3DDevice, "something.jpg", &pTexture)
...
now I guess I'm missing something here ?
...
and later calling the ImGui:Image((void*)pTexture, .... ) to add the image to my window.
I guess I'm missing the part where the texture gets loaded into the renderpipeline, but I'm not so sure where to do this... ImGui:Image adds the required vertices to it's own buffer from what I saw, but somewhere a direct3DDevice->SetTexture (0, texture); is missing I guess ?
Thanks for a quick slap on my head ;)
(does anyone have experience with loading quite a few textures (let's say 50 icons or so) + running imgui in terms of FPS ?)
Everything should be documented if you read the comment about TextureId, the code in direct9_example/ and the "Image" example in the imgui demo.
Basically ImTextureId is a void* where you can store anything you want. Whatever you pass to Image() is passed down the pipeline to your render function in the end, which can change texture according to this void*.
That is what confused me, the "Image" example in the imgui demo was using the Textureid from the FontAtlas. And in the header was something written with "SetTextID(..)" , but that just set the current TextureID of the fontatlas instance....which afaik is not meant for drawing nor handling other images ?
It is doing that because that's the only texture that the demo application has access to.
You can use your own texture obviously.
Yes I read these comments, but I fail to make it "use" my texture for that, I guess because I fail to see the connection between my custom texture, FontAtlas's SetTextID and how imgui's drawing works.
That's why I asked for a tiny code example, since I lack some important part I assume ^^
Somewhere in the ImGui_ImplDX9_RenderDrawLists, // Render command lists I assume it will be passing back my Texture ID and I have to handle the rendering for that texture ?
The code in imgui_impl_dx9.* assume that ImTextureId == LPDIRECT3DTEXTURE9
g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->TextureId );That's all. Just pass your LPDIRECT3DTEXTURE9 and cast it to (void*) when calling Image.
Hmm, from all I know, I did that in my code, I used the pointer to the texture as TextureId, passing it as void_:
ImGui:Image((void_)pTexture,....)
It drew only a blank white rectangle, that what made me waste 2 hours and then give up to ask here.
I'll try again tomorrow I guess :)
thanks a lot, I am in LOVE with ImGUI 😍
I don't know what pTexture is, it is a
LPDIRECT3DTEXTURE9(akaDIRECT3DTEXTURE9*)? it may be invalid, or at least it has to be valid until rendering happen.Or make sure your UV are correct.
You can also set a breakpoint in the imgui_impl_dx9.cpp renderer and cast it back to LPDIRECT3DTEXTURE9 and inspect from there.
Thanks! Sorry I can't help a lot those questions are overwhelming and I'm trying to shut them down as fast as I can :)