gboisse / gfx

A minimalist and easy to use graphics API.
MIT License
498 stars 35 forks source link

Get gfxTexture D3D12_GPU_DESCRIPTOR_HANDLE for imgui image #120

Closed ySion closed 5 months ago

ySion commented 6 months ago

I'm using ImGui to show some texture. ImGui's function AddImage need a argument which type is ImTextureID, it was defined as D3D12_GPU_DESCRIPTOR_HANDLE in D3D12, how can I get D3D12_GPU_DESCRIPTOR_HANDLE from a gfxTexture?

gboisse commented 5 months ago

You shouldn't need passing a D3D12_GPU_DESCRIPTOR_HANDLE as ImTextureID can be anything really based on your application needs.

If you're using the built-in gfx ImGui integration (i.e., https://github.com/gboisse/gfx/blob/master/gfx_imgui.h), then you should be able to simply pass a pointer to the GfxTexture object you want to use as image: https://github.com/gboisse/gfx/blob/d617b252a68ea27116a5a26027530c22d45bc9e6/gfx_imgui.cpp#L270-L272