pub struct XrAndroidDepthTexture { /* private fields */ }
Expand description
Main extension handler for Android depth texture functionality
This struct manages the XR_ANDROID_depth_texture extension, providing access to:
- Depth and confidence texture data from device sensors
- Multiple resolution options (quarter, half, full)
- Both raw and processed depth information
- Swapchain management for efficient rendering
###Examples
use stereokit_rust::tools::xr_android_depth_texture::*;
number_of_steps = 50;
test_steps!( // !!!! Get a proper main loop !!!!
if iter == 10 {
// Initialize extension and check system support
if let Some(depth_ext) = XrAndroidDepthTexture::new() {
// Check system support with logging
match depth_ext.check_system_support(true) {
Ok(_system_props) => {
stereokit_rust::system::Log::info("✅ System supports depth tracking");
// Continue with depth texture operations...
let session = openxr_sys::Session::from_raw(
stereokit_rust::system::BackendOpenXR::session()
);
// Create depth swapchain with smooth and raw depth images
let swapchain_info = create_depth_swapchain_info(
XR_DEPTH_RESOLUTION_HALF_ANDROID,
XR_DEPTH_SWAPCHAIN_CREATE_SMOOTH_DEPTH_IMAGE_BIT_ANDROID
| XR_DEPTH_SWAPCHAIN_CREATE_RAW_DEPTH_IMAGE_BIT_ANDROID
);
match depth_ext.create_depth_swapchain(session, &swapchain_info) {
Ok(swapchain) => {
stereokit_rust::system::Log::info("✅ Depth swapchain created!");
// Enumerate swapchain images
if let Ok(images) = depth_ext.enumerate_depth_swapchain_images(swapchain) {
stereokit_rust::system::Log::info(
format!("Found {} swapchain images", images.len())
);
}
// Test image acquisition
if let Ok(index) = depth_ext.acquire_depth_swapchain_image(session, swapchain) {
stereokit_rust::system::Log::info(
format!("Acquired image at index: {}", index)
);
}
// Cleanup
let _ = depth_ext.destroy_depth_swapchain(swapchain);
stereokit_rust::system::Log::info("✅ Swapchain test completed!");
}
Err(e) => stereokit_rust::system::Log::err(format!("Swapchain creation failed: {}", e)),
}
}
Err(e) => stereokit_rust::system::Log::err(format!("System support check failed: {:?}", e)),
}
}
}
);
§Depth Resolution Enumeration Example
use stereokit_rust::tools::xr_android_depth_texture::*;
number_of_steps = 20;
test_steps!( // !!!! Get a proper main loop !!!!
if iter == 5 {
// Test depth resolution enumeration and analysis
if let Some(depth_ext) = XrAndroidDepthTexture::new() {
let session = openxr_sys::Session::from_raw(
stereokit_rust::system::BackendOpenXR::session()
);
match depth_ext.enumerate_depth_resolutions(session) {
Ok(resolutions) => {
stereokit_rust::system::Log::info(
format!("✅ Found {} supported depth resolutions", resolutions.len())
);
for (i, resolution) in resolutions.iter().enumerate() {
let (width, height) = get_resolution_dimensions(*resolution);
let resolution_name = match *resolution {
XR_DEPTH_RESOLUTION_QUARTER_ANDROID => "Quarter",
XR_DEPTH_RESOLUTION_HALF_ANDROID => "Half",
XR_DEPTH_RESOLUTION_FULL_ANDROID => "Full",
_ => "Unknown",
};
stereokit_rust::system::Log::info(format!(
" Resolution {}: {} ({}x{}) - enum: {}",
i, resolution_name, width, height, resolution
));
}
stereokit_rust::system::Log::info("✅ Resolution enumeration completed!");
}
Err(e) => stereokit_rust::system::Log::err(
format!("Resolution enumeration failed: {}", e)
),
}
}
}
);
Implementations§
Source§impl XrAndroidDepthTexture
impl XrAndroidDepthTexture
Sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Create and initialize a new AndroidDepthTextureExtension instance
This method combines creation and initialization, checking extension availability and loading all necessary OpenXR functions for depth texture operations.
§Returns
Some(Self)
if extension is available and initialization succeedsNone
if extension is not available or initialization fails
Sourcepub fn check_system_support(
&self,
with_log: bool,
) -> Result<SystemProperties, Result>
pub fn check_system_support( &self, with_log: bool, ) -> Result<SystemProperties, Result>
Sourcepub fn enumerate_depth_resolutions(
&self,
session: Session,
) -> Result<Vec<DepthResolutionAndroid>, String>
pub fn enumerate_depth_resolutions( &self, session: Session, ) -> Result<Vec<DepthResolutionAndroid>, String>
Sourcepub fn create_depth_swapchain(
&self,
session: Session,
create_info: &DepthSwapchainCreateInfoAndroid,
) -> Result<Swapchain, String>
pub fn create_depth_swapchain( &self, session: Session, create_info: &DepthSwapchainCreateInfoAndroid, ) -> Result<Swapchain, String>
Sourcepub fn enumerate_depth_swapchain_images(
&self,
swapchain: Swapchain,
) -> Result<Vec<DepthSwapchainImageAndroid>, String>
pub fn enumerate_depth_swapchain_images( &self, swapchain: Swapchain, ) -> Result<Vec<DepthSwapchainImageAndroid>, String>
Trait Implementations§
Source§impl Debug for XrAndroidDepthTexture
impl Debug for XrAndroidDepthTexture
Auto Trait Implementations§
impl Freeze for XrAndroidDepthTexture
impl RefUnwindSafe for XrAndroidDepthTexture
impl Send for XrAndroidDepthTexture
impl Sync for XrAndroidDepthTexture
impl Unpin for XrAndroidDepthTexture
impl UnwindSafe for XrAndroidDepthTexture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.