dear_imgui/render/
renderer.rs

1//! Renderer abstractions and texture management
2//!
3//! This module provides renderer trait definitions for integrating with various graphics APIs.
4//! For texture management, use the types from the `texture` module.
5
6// Re-export texture types for backward compatibility
7pub use crate::texture::{RawTextureId, TextureData, TextureFormat, TextureRect, TextureStatus};
8
9#[cfg(test)]
10mod tests {
11    use super::*;
12    use crate::texture::TextureId;
13    use std::ffi::c_void;
14    use std::mem;
15
16    #[test]
17    fn test_texture_id_memory_layout() {
18        // Ensure TextureId has the same size as a pointer
19        assert_eq!(mem::size_of::<TextureId>(), mem::size_of::<*const c_void>());
20        assert_eq!(
21            mem::align_of::<TextureId>(),
22            mem::align_of::<*const c_void>()
23        );
24    }
25
26    #[test]
27    fn test_texture_id_conversions() {
28        let id = TextureId::new(12345);
29        assert_eq!(id.id(), 12345);
30
31        let ptr = 0x1000 as *const u8;
32        let id_from_ptr = TextureId::from(ptr);
33        assert_eq!(id_from_ptr.id(), 0x1000);
34
35        let raw: RawTextureId = id.into();
36        let id_back: TextureId = raw.into();
37        assert_eq!(id, id_back);
38    }
39
40    #[test]
41    fn test_null_texture_id() {
42        let null_id = TextureId::null();
43        assert!(null_id.is_null());
44        assert_eq!(null_id.id(), 0);
45
46        let non_null = TextureId::new(1);
47        assert!(!non_null.is_null());
48    }
49}