pub struct DrawData {
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§
§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
impl DrawData
Sourcepub fn valid(&self) -> bool
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.
Sourcepub fn draw_lists(&self) -> DrawListIterator<'_> ⓘ
pub fn draw_lists(&self) -> DrawListIterator<'_> ⓘ
Returns an iterator over the draw lists included in the draw data.
Sourcepub fn draw_lists_count(&self) -> usize
pub fn draw_lists_count(&self) -> usize
Returns the number of draw lists included in the draw data.
Sourcepub fn total_idx_count(&self) -> usize
pub fn total_idx_count(&self) -> usize
Returns the total number of index-buffer elements across all draw lists.
Sourcepub fn total_vtx_count(&self) -> usize
pub fn total_vtx_count(&self) -> usize
Returns the total number of vertex-buffer elements across all draw lists.
Sourcepub fn display_pos(&self) -> [f32; 2]
pub fn display_pos(&self) -> [f32; 2]
Get the display position as an array
Sourcepub fn display_size(&self) -> [f32; 2]
pub fn display_size(&self) -> [f32; 2]
Get the display size as an array
Sourcepub fn framebuffer_scale(&self) -> [f32; 2]
pub fn framebuffer_scale(&self) -> [f32; 2]
Get the framebuffer scale as an array
Sourcepub fn owner_viewport(&self) -> *mut ImGuiViewport
pub fn owner_viewport(&self) -> *mut ImGuiViewport
Raw owner viewport pointer for this draw data.
This is primarily useful for integrations that snapshot multiple Dear ImGui platform viewports. The pointer belongs to the current ImGui context and must not be stored beyond the draw data lifetime.
Sourcepub fn deindex_all_buffers(&mut self)
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!
Sourcepub fn scale_clip_rects(&mut self, fb_scale: [f32; 2])
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.
Source§impl DrawData
impl DrawData
Sourcepub fn textures(&self) -> TextureIterator<'_> ⓘ
pub fn textures(&self) -> TextureIterator<'_> ⓘ
Returns a shared iterator over textures attached to this draw data.
Use this for inspection, snapshotting, or read-only request collection. Renderer backends
that need to write TexID/Status after handling texture requests must use
Self::textures_mut instead.
Sourcepub fn textures_mut(&mut self) -> TextureMutCursor<'_>
pub fn textures_mut(&mut self) -> TextureMutCursor<'_>
Returns a mutable cursor over 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 specifiedUpdateRectregions.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.
The cursor intentionally does not implement Iterator. Each mutable item is borrowed
from the cursor itself, so safe Rust cannot hold one texture update guard while asking for
the next one.
use dear_imgui_rs::render::DrawData;
fn shared_texture_blocks_mutable_cursor(draw_data: &mut DrawData) {
let shared = draw_data.texture(0);
let mut textures = draw_data.textures_mut();
let _first = textures.next();
drop(shared);
}use dear_imgui_rs::render::DrawData;
fn texture_guards_cannot_overlap(draw_data: &mut DrawData) {
let mut textures = draw_data.textures_mut();
let first = textures.next();
let second = textures.next();
drop(first);
drop(second);
}Sourcepub fn textures_count(&self) -> usize
pub fn textures_count(&self) -> usize
Returns the number of textures in the texture list
Sourcepub fn texture(&self, index: usize) -> Option<&TextureData>
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.
Sourcepub fn texture_mut(&mut self, index: usize) -> Option<&mut TextureData>
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.