WgpuTextureManager

Struct WgpuTextureManager 

Source
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

Source

pub fn new() -> Self

Create a new texture manager

Source

pub fn register_texture(&mut self, texture: WgpuTexture) -> u64

Register a new texture and return its ID

Source

pub fn get_texture(&self, id: u64) -> Option<&WgpuTexture>

Get a texture by ID

Source

pub fn remove_texture(&mut self, id: u64) -> Option<WgpuTexture>

Remove a texture by ID

Source

pub fn contains_texture(&self, id: u64) -> bool

Check if a texture exists

Source

pub fn insert_texture_with_id(&mut self, id: u64, texture: WgpuTexture)

Insert a texture with a specific ID

Source

pub fn destroy_texture_by_id(&mut self, id: u64)

Destroy a texture by ID

Source

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

Source

pub fn texture_count(&self) -> usize

Get the number of registered textures

Source

pub fn clear(&mut self)

Clear all textures

Source§

impl WgpuTextureManager

Texture creation and management functions

Source

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

Source

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

Source

pub fn destroy_texture(&mut self, texture_id: TextureId)

Destroy a texture

Source

pub fn handle_texture_updates( &mut self, draw_data: &DrawData, device: &Device, queue: &Queue, )

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.

Source

pub fn update_single_texture( &mut self, texture_data: &TextureData, device: &Device, queue: &Queue, ) -> Result<TextureUpdateResult, String>

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);

Trait Implementations§

Source§

impl Debug for WgpuTextureManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WgpuTextureManager

Source§

fn default() -> WgpuTextureManager

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,