pub struct WgpuTextureManager { /* private fields */ }Expand description
Texture manager for WGPU renderer
This manages the mapping between Dear ImGui texture IDs and WGPU textures, similar to the ImageBindGroups storage in the C++ implementation.
Implementations§
Source§impl WgpuTextureManager
impl WgpuTextureManager
Sourcepub fn register_texture(&mut self, texture: WgpuTexture) -> u64
pub fn register_texture(&mut self, texture: WgpuTexture) -> u64
Register a new texture and return its ID
Sourcepub fn get_texture(&self, id: u64) -> Option<&WgpuTexture>
pub fn get_texture(&self, id: u64) -> Option<&WgpuTexture>
Get a texture by ID
Sourcepub fn remove_texture(&mut self, id: u64) -> Option<WgpuTexture>
pub fn remove_texture(&mut self, id: u64) -> Option<WgpuTexture>
Remove a texture by ID
Sourcepub fn contains_texture(&self, id: u64) -> bool
pub fn contains_texture(&self, id: u64) -> bool
Check if a texture exists
Sourcepub fn insert_texture_with_id(&mut self, id: u64, texture: WgpuTexture)
pub fn insert_texture_with_id(&mut self, id: u64, texture: WgpuTexture)
Insert a texture with a specific ID
Sourcepub fn destroy_texture_by_id(&mut self, id: u64)
pub fn destroy_texture_by_id(&mut self, id: u64)
Destroy a texture by ID
Sourcepub fn update_texture_from_data_with_id(
&mut self,
device: &Device,
queue: &Queue,
texture_data: &TextureData,
texture_id: u64,
) -> RendererResult<()>
pub fn update_texture_from_data_with_id( &mut self, device: &Device, queue: &Queue, texture_data: &TextureData, texture_id: u64, ) -> RendererResult<()>
Update an existing texture from Dear ImGui texture data with specific ID
Sourcepub fn texture_count(&self) -> usize
pub fn texture_count(&self) -> usize
Get the number of registered textures
Source§impl WgpuTextureManager
Texture creation and management functions
impl WgpuTextureManager
Texture creation and management functions
Sourcepub fn create_texture_from_data(
&mut self,
device: &Device,
queue: &Queue,
texture_data: &TextureData,
) -> RendererResult<u64>
pub fn create_texture_from_data( &mut self, device: &Device, queue: &Queue, texture_data: &TextureData, ) -> RendererResult<u64>
Create a texture from Dear ImGui texture data
Sourcepub fn update_texture_from_data(
&mut self,
device: &Device,
queue: &Queue,
texture_data: &TextureData,
) -> RendererResult<()>
pub fn update_texture_from_data( &mut self, device: &Device, queue: &Queue, texture_data: &TextureData, ) -> RendererResult<()>
Update an existing texture from Dear ImGui texture data
Sourcepub fn destroy_texture(&mut self, texture_id: TextureId)
pub fn destroy_texture(&mut self, texture_id: TextureId)
Destroy a texture
Sourcepub fn handle_texture_updates(
&mut self,
draw_data: &DrawData,
device: &Device,
queue: &Queue,
render_resources: &mut RenderResources,
)
pub fn handle_texture_updates( &mut self, draw_data: &DrawData, device: &Device, queue: &Queue, render_resources: &mut RenderResources, )
Handle texture updates from Dear ImGui draw data
This iterates DrawData::textures() and applies create/update/destroy requests.
For WantCreate, we create the GPU texture, then write the generated id back into
the ImTextureData via set_tex_id() and mark status OK (matching C++ backend).
For WantUpdates, if a valid id is not yet assigned (first use), we create now and
assign the id; otherwise we update in place. When textures are recreated or destroyed,
the corresponding cached bind groups in RenderResources are invalidated so that
subsequent draws will see the updated views.
Sourcepub fn update_single_texture(
&mut self,
texture_data: &TextureData,
device: &Device,
queue: &Queue,
) -> RendererResult<TextureUpdateResult>
pub fn update_single_texture( &mut self, texture_data: &TextureData, device: &Device, queue: &Queue, ) -> RendererResult<TextureUpdateResult>
Update a single texture based on its status
This corresponds to ImGui_ImplWGPU_UpdateTexture in the C++ implementation.
§Returns
Returns a TextureUpdateResult that contains the operation result and
any status/ID updates that need to be applied to the texture data.
This follows Rust’s principle of explicit state management.
§Example
let result = texture_manager.update_single_texture(&texture_data, &device, &queue)?;
result.apply_to(&mut texture_data);