pub struct Uniforms {
pub viewport_size: [f32; 2],
pub texture_size: [f32; 2],
pub time: f32,
pub pixel_format: u32,
/* private fields */
}Expand description
Uniforms structure for Metal shaders
This matches the layout expected by SHADER_SOURCE.
Fields§
§viewport_size: [f32; 2]Viewport width and height
texture_size: [f32; 2]Texture width and height
time: f32Animation time (optional)
pixel_format: u32Pixel format (raw u32 for GPU compatibility)
Implementations§
Source§impl Uniforms
impl Uniforms
Sourcepub fn new(
viewport_width: f32,
viewport_height: f32,
texture_width: f32,
texture_height: f32,
) -> Self
pub fn new( viewport_width: f32, viewport_height: f32, texture_width: f32, texture_height: f32, ) -> Self
Create uniforms for a given viewport and texture size
Sourcepub fn from_captured_textures<T>(
viewport_width: f32,
viewport_height: f32,
textures: &CapturedTextures<T>,
) -> Self
pub fn from_captured_textures<T>( viewport_width: f32, viewport_height: f32, textures: &CapturedTextures<T>, ) -> Self
Create uniforms from viewport size and captured textures
Automatically extracts texture dimensions and pixel format.
§Example
use screencapturekit::metal::{MetalDevice, Uniforms};
use screencapturekit::cm::IOSurface;
fn example(surface: &IOSurface, device: &MetalDevice) {
if let Some(textures) = surface.create_metal_textures(device) {
let uniforms = Uniforms::from_captured_textures(1920.0, 1080.0, &textures);
}
}Sourcepub fn with_pixel_format(self, format: impl Into<FourCharCode>) -> Self
pub fn with_pixel_format(self, format: impl Into<FourCharCode>) -> Self
Set the pixel format
Accepts either a FourCharCode or a raw u32:
use screencapturekit::metal::{Uniforms, pixel_format};
let uniforms = Uniforms::new(1920.0, 1080.0, 1920.0, 1080.0)
.with_pixel_format(pixel_format::BGRA);Trait Implementations§
impl Copy for Uniforms
Auto Trait Implementations§
impl Freeze for Uniforms
impl RefUnwindSafe for Uniforms
impl Send for Uniforms
impl Sync for Uniforms
impl Unpin for Uniforms
impl UnwindSafe for Uniforms
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