mtl_gpu/encoder/render_encoder/
viewport.rs1use mtl_foundation::{Referencing, UInteger};
4use mtl_sys::{msg_send_1, sel};
5
6use crate::types::{ScissorRect, Viewport};
7
8use super::RenderCommandEncoder;
9
10impl RenderCommandEncoder {
11 #[inline]
19 pub fn set_viewport(&self, viewport: Viewport) {
20 unsafe {
21 msg_send_1::<(), Viewport>(self.as_ptr(), sel!(setViewport:), viewport);
22 }
23 }
24
25 #[inline]
29 pub fn set_viewports(&self, viewports: &[Viewport]) {
30 unsafe {
31 mtl_sys::msg_send_2::<(), *const Viewport, UInteger>(
32 self.as_ptr(),
33 sel!(setViewports: count:),
34 viewports.as_ptr(),
35 viewports.len() as UInteger,
36 );
37 }
38 }
39
40 #[inline]
44 pub fn set_scissor_rect(&self, rect: ScissorRect) {
45 unsafe {
46 msg_send_1::<(), ScissorRect>(self.as_ptr(), sel!(setScissorRect:), rect);
47 }
48 }
49
50 #[inline]
54 pub fn set_scissor_rects(&self, rects: &[ScissorRect]) {
55 unsafe {
56 mtl_sys::msg_send_2::<(), *const ScissorRect, UInteger>(
57 self.as_ptr(),
58 sel!(setScissorRects: count:),
59 rects.as_ptr(),
60 rects.len() as UInteger,
61 );
62 }
63 }
64}