mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-23 19:38:27 +00:00
Merge pull request #326 from filnet/expose-more-drawdata-members
Make cmd_lists_count public in DrawData struct
This commit is contained in:
commit
f05e3d666c
@ -4,15 +4,18 @@ use crate::internal::{RawCast, RawWrapper};
|
|||||||
use crate::render::renderer::TextureId;
|
use crate::render::renderer::TextureId;
|
||||||
use crate::sys;
|
use crate::sys;
|
||||||
|
|
||||||
/// All draw data required to render a frame.
|
/// All draw data to render a Dear ImGui frame.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct DrawData {
|
pub struct DrawData {
|
||||||
|
/// Only valid after render() is called and before the next new frame() is called.
|
||||||
valid: bool,
|
valid: bool,
|
||||||
|
// Array of DrawList.
|
||||||
cmd_lists: *mut *mut DrawList,
|
cmd_lists: *mut *mut DrawList,
|
||||||
|
/// Number of DrawList to render.
|
||||||
cmd_lists_count: i32,
|
cmd_lists_count: i32,
|
||||||
/// For convenience, sum of all draw list index buffer sizes
|
/// For convenience, sum of all draw list index buffer sizes.
|
||||||
pub total_idx_count: i32,
|
pub total_idx_count: i32,
|
||||||
/// For convenience, sum of all draw list vertex buffer sizes
|
/// For convenience, sum of all draw list vertex buffer sizes.
|
||||||
pub total_vtx_count: i32,
|
pub total_vtx_count: i32,
|
||||||
/// Upper-left position of the viewport to render.
|
/// Upper-left position of the viewport to render.
|
||||||
///
|
///
|
||||||
@ -32,7 +35,7 @@ pub struct DrawData {
|
|||||||
unsafe impl RawCast<sys::ImDrawData> for DrawData {}
|
unsafe impl RawCast<sys::ImDrawData> for DrawData {}
|
||||||
|
|
||||||
impl DrawData {
|
impl DrawData {
|
||||||
/// Returns an iterator over the draw lists included in the draw data
|
/// Returns an iterator over the draw lists included in the draw data.
|
||||||
pub fn draw_lists(&self) -> DrawListIterator {
|
pub fn draw_lists(&self) -> DrawListIterator {
|
||||||
unsafe {
|
unsafe {
|
||||||
DrawListIterator {
|
DrawListIterator {
|
||||||
@ -40,6 +43,11 @@ impl DrawData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Returns the number of draw lists included in the draw data.
|
||||||
|
pub fn draw_lists_count(&self) -> usize {
|
||||||
|
use std::convert::TryInto;
|
||||||
|
self.cmd_lists_count.try_into().unwrap()
|
||||||
|
}
|
||||||
pub(crate) unsafe fn cmd_lists(&self) -> &[*const DrawList] {
|
pub(crate) unsafe fn cmd_lists(&self) -> &[*const DrawList] {
|
||||||
slice::from_raw_parts(
|
slice::from_raw_parts(
|
||||||
self.cmd_lists as *const *const DrawList,
|
self.cmd_lists as *const *const DrawList,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user