Skip to main content

OwnedTextureData

Struct OwnedTextureData 

Source
pub struct OwnedTextureData { /* private fields */ }
Expand description

Owned texture data managed by Dear ImGui.

This owns an ImTextureData instance allocated by Dear ImGui (C++) and will destroy it on drop. It dereferences to TextureData so you can call the same APIs as on borrowed texture data (e.g. items returned by DrawData::textures_mut()).

Implementations§

Source§

impl OwnedTextureData

Source

pub fn new() -> Self

Create a new empty texture data object (C++ constructed).

Source

pub fn into_raw(self) -> *mut ImTextureData

Leak the underlying ImTextureData* without destroying it.

Source

pub unsafe fn from_raw_owned(raw: *mut ImTextureData) -> Self

Take ownership of a raw ImTextureData*.

§Safety
  • raw must be a valid pointer returned by ImTextureData_ImTextureData().
  • The caller must ensure no other owner will call ImTextureData_destroy(raw).

Methods from Deref<Target = TextureData>§

Source

pub fn as_raw(&self) -> *const ImTextureData

Get the raw pointer to the underlying ImTextureData

Source

pub fn as_raw_mut(&mut self) -> *mut ImTextureData

Get the raw mutable pointer to the underlying ImTextureData

Source

pub fn unique_id(&self) -> ManagedTextureId

Get this managed texture’s stable ImGui identity.

Source

pub fn status(&self) -> TextureStatus

Get the current status of this texture

Source

pub fn set_status(&mut self, status: TextureStatus)

Set the status of this texture

This should only be called by renderer backends after handling a request.

Source

pub fn backend_user_data(&self) -> *mut c_void

Get the backend user data

Source

pub fn set_backend_user_data(&mut self, data: *mut c_void)

Set the backend user data

Source

pub fn tex_id(&self) -> TextureId

Get the texture ID

Source

pub fn set_tex_id(&mut self, tex_id: TextureId)

Set the texture ID

This should only be called by renderer backends after creating or destroying the texture.

Source

pub fn texture_ref(&mut self) -> TextureRef<'_>

Get the current texture reference for this managed texture.

Source

pub fn format(&self) -> TextureFormat

Get the texture format

Source

pub fn width(&self) -> u32

Get the texture width

Source

pub fn height(&self) -> u32

Get the texture height

Source

pub fn bytes_per_pixel(&self) -> usize

Get the bytes per pixel

Source

pub fn unused_frames(&self) -> usize

Get the number of unused frames

Source

pub fn ref_count(&self) -> u16

Get the reference count

Source

pub fn use_colors(&self) -> bool

Check if the texture uses colors (rather than just white + alpha)

Source

pub fn want_destroy_next_frame(&self) -> bool

Check if the texture is queued for destruction next frame

Source

pub fn pixels(&self) -> Option<&[u8]>

Get the pixel data

Returns None if no pixel data is available.

Source

pub fn used_rect(&self) -> TextureRect

Get the bounding box of all used pixels in the texture

Source

pub fn update_rect(&self) -> TextureRect

Get the bounding box of all queued updates

Source

pub fn updates(&self) -> impl Iterator<Item = TextureRect> + '_

Iterate over queued update rectangles (copying to safe TextureRect)

Source

pub fn pixels_at(&self, x: u32, y: u32) -> Option<&[u8]>

Get the pixel data at a specific position

Returns None if no pixel data is available or coordinates are out of bounds.

Source

pub fn pitch(&self) -> usize

Get the pitch (bytes per row)

Source

pub fn create(&mut self, format: TextureFormat, width: u32, height: u32)

Create a new texture with the specified format and dimensions

This allocates pixel data and sets the status to WantCreate.

Source

pub fn destroy_pixels(&mut self)

Destroy the pixel data

This frees the CPU-side pixel data but doesn’t affect the GPU texture.

Source

pub fn set_data(&mut self, data: &[u8])

Set the pixel data for the texture

This copies the provided data into the texture’s pixel buffer.

Source

pub fn set_width(&mut self, width: u32)

Set the width of the texture

Source

pub fn set_height(&mut self, height: u32)

Set the height of the texture

Source

pub fn set_format(&mut self, format: TextureFormat)

Set the format of the texture

Trait Implementations§

Source§

impl AsMut<TextureData> for OwnedTextureData

Source§

fn as_mut(&mut self) -> &mut TextureData

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<TextureData> for OwnedTextureData

Source§

fn as_ref(&self) -> &TextureData

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Deref for OwnedTextureData

Source§

type Target = TextureData

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for OwnedTextureData

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for OwnedTextureData

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> 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