DrawData

Struct DrawData 

Source
pub struct DrawData {
    pub total_idx_count: i32,
    pub total_vtx_count: i32,
    pub display_pos: [f32; 2],
    pub display_size: [f32; 2],
    pub framebuffer_scale: [f32; 2],
    /* private fields */
}
Expand description

All draw data to render a Dear ImGui frame.

Fields§

§total_idx_count: i32

For convenience, sum of all draw list index buffer sizes.

§total_vtx_count: i32

For convenience, sum of all draw list vertex buffer sizes.

§display_pos: [f32; 2]

Upper-left position of the viewport to render.

(= upper-left corner of the orthogonal projection matrix to use)

§display_size: [f32; 2]

Size of the viewport to render.

(= display_pos + display_size == lower-right corner of the orthogonal matrix to use)

§framebuffer_scale: [f32; 2]

Amount of pixels for each unit of display_size.

Based on io.display_frame_buffer_scale. Typically [1.0, 1.0] on normal displays, and [2.0, 2.0] on Retina displays, but fractional values are also possible.

Implementations§

Source§

impl DrawData

Source

pub fn valid(&self) -> bool

Check if the draw data is valid

Draw data is only valid after Context::render() is called and before the next Context::new_frame() is called.

Source

pub fn draw_lists(&self) -> DrawListIterator<'_>

Returns an iterator over the draw lists included in the draw data.

Source

pub fn draw_lists_count(&self) -> usize

Returns the number of draw lists included in the draw data.

Source

pub fn textures(&self) -> TextureIterator<'_>

Returns an iterator over the textures that need to be updated

This is used by renderer backends to process texture creation, updates, and destruction. Each item is an ImTextureData* carrying a Status which can be one of:

  • OK: nothing to do.
  • WantCreate: create a GPU texture and upload all pixels.
  • WantUpdates: upload specified UpdateRect regions.
  • WantDestroy: destroy the GPU texture (may be delayed until unused). Most of the time this list has only 1 texture and it doesn’t need any update.

Note: items returned by this iterator provide a guarded mutable view; do not store them or hold them across iterations.

Source

pub fn textures_count(&self) -> usize

Returns the number of textures in the texture list

Source

pub fn texture(&self, index: usize) -> Option<&TextureData>

Get a specific texture by index

Returns None if the index is out of bounds or no textures are available.

Source

pub fn texture_mut(&mut self, index: usize) -> Option<&mut TextureData>

Get a mutable reference to a specific texture by index

Returns None if the index is out of bounds or no textures are available.

Source

pub fn display_pos(&self) -> [f32; 2]

Get the display position as an array

Source

pub fn display_size(&self) -> [f32; 2]

Get the display size as an array

Source

pub fn framebuffer_scale(&self) -> [f32; 2]

Get the framebuffer scale as an array

Source

pub fn deindex_all_buffers(&mut self)

Converts all buffers from indexed to non-indexed, in case you cannot render indexed buffers

This is slow and most likely a waste of resources. Always prefer indexed rendering!

Source

pub fn scale_clip_rects(&mut self, fb_scale: [f32; 2])

Scales the clip rect of each draw command

Can be used if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.

Trait Implementations§

Source§

impl From<&DrawData> for OwnedDrawData

Source§

fn from(value: &DrawData) -> Self

Construct OwnedDrawData from DrawData by creating a heap-allocated deep copy of the given DrawData

Source§

impl RawCast<ImDrawData> for DrawData

Source§

unsafe fn from_raw(raw: &T) -> &Self

Casts an immutable reference from the raw type Read more
Source§

unsafe fn from_raw_mut(raw: &mut T) -> &mut Self

Casts a mutable reference from the raw type Read more
Source§

unsafe fn raw(&self) -> &T

Casts an immutable reference to the raw type Read more
Source§

unsafe fn raw_mut(&mut self) -> &mut T

Casts a mutable reference to the raw type Read more
Source§

impl RawWrapper for DrawData

Source§

type Raw = ImDrawData

Wrapped raw type
Source§

unsafe fn raw(&self) -> &Self::Raw

Returns an immutable reference to the wrapped raw value Read more
Source§

unsafe fn raw_mut(&mut self) -> &mut Self::Raw

Returns a mutable reference to the wrapped raw value 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<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