gstreamer_gl/auto/gl_framebuffer.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{GLBaseMemory, GLContext, ffi};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 /// A [`GLFramebuffer`][crate::GLFramebuffer] represents and holds an OpenGL framebuffer object with
11 /// it's associated attachments.
12 ///
13 /// A [`GLFramebuffer`][crate::GLFramebuffer] can be created with [`new()`][Self::new()] or
14 /// [`with_default_depth()`][Self::with_default_depth()] and bound with
15 /// [`GLFramebufferExt::bind()`][crate::prelude::GLFramebufferExt::bind()]. Other resources can be bound with
16 /// [`GLFramebufferExt::attach()`][crate::prelude::GLFramebufferExt::attach()]
17 ///
18 /// Note: OpenGL framebuffers are not shareable resources so cannot be used
19 /// between multiple OpenGL contexts.
20 ///
21 /// # Implements
22 ///
23 /// [`GLFramebufferExt`][trait@crate::prelude::GLFramebufferExt], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`GLFramebufferExtManual`][trait@crate::prelude::GLFramebufferExtManual]
24 #[doc(alias = "GstGLFramebuffer")]
25 pub struct GLFramebuffer(Object<ffi::GstGLFramebuffer, ffi::GstGLFramebufferClass>) @extends gst::Object;
26
27 match fn {
28 type_ => || ffi::gst_gl_framebuffer_get_type(),
29 }
30}
31
32impl GLFramebuffer {
33 pub const NONE: Option<&'static GLFramebuffer> = None;
34
35 /// This function will internally create an OpenGL framebuffer object and must
36 /// be called on `context`'s OpenGL thread.
37 /// ## `context`
38 /// a [`GLContext`][crate::GLContext]
39 ///
40 /// # Returns
41 ///
42 /// a new [`GLFramebuffer`][crate::GLFramebuffer]
43 #[doc(alias = "gst_gl_framebuffer_new")]
44 pub fn new(context: &impl IsA<GLContext>) -> GLFramebuffer {
45 skip_assert_initialized!();
46 unsafe {
47 from_glib_full(ffi::gst_gl_framebuffer_new(
48 context.as_ref().to_glib_none().0,
49 ))
50 }
51 }
52
53 /// This function will internally create an OpenGL framebuffer object and must
54 /// be called on `context`'s OpenGL thread.
55 /// ## `context`
56 /// a [`GLContext`][crate::GLContext]
57 /// ## `width`
58 /// width for the depth buffer
59 /// ## `height`
60 /// for the depth buffer
61 ///
62 /// # Returns
63 ///
64 /// a new [`GLFramebuffer`][crate::GLFramebuffer] with a depth buffer of `width` and `height`
65 #[doc(alias = "gst_gl_framebuffer_new_with_default_depth")]
66 #[doc(alias = "new_with_default_depth")]
67 pub fn with_default_depth(
68 context: &impl IsA<GLContext>,
69 width: u32,
70 height: u32,
71 ) -> GLFramebuffer {
72 skip_assert_initialized!();
73 unsafe {
74 from_glib_none(ffi::gst_gl_framebuffer_new_with_default_depth(
75 context.as_ref().to_glib_none().0,
76 width,
77 height,
78 ))
79 }
80 }
81}
82
83unsafe impl Send for GLFramebuffer {}
84unsafe impl Sync for GLFramebuffer {}
85
86/// Trait containing all [`struct@GLFramebuffer`] methods.
87///
88/// # Implementors
89///
90/// [`GLFramebuffer`][struct@crate::GLFramebuffer]
91pub trait GLFramebufferExt: IsA<GLFramebuffer> + 'static {
92 /// attach `mem` to `attachment_point`
93 ///
94 /// Must be called with the same OpenGL context current that `self` was created
95 /// with.
96 /// ## `attachment_point`
97 /// the OpenGL attachment point to bind `mem` to
98 /// ## `mem`
99 /// the memory object to bind to `attachment_point`
100 #[doc(alias = "gst_gl_framebuffer_attach")]
101 unsafe fn attach(&self, attachment_point: u32, mem: &mut GLBaseMemory) {
102 unsafe {
103 ffi::gst_gl_framebuffer_attach(
104 self.as_ref().to_glib_none().0,
105 attachment_point,
106 mem.to_glib_none_mut().0,
107 );
108 }
109 }
110
111 /// Bind `self` into the current thread
112 ///
113 /// Must be called with the same OpenGL context current that `self` was created
114 /// with.
115 #[doc(alias = "gst_gl_framebuffer_bind")]
116 fn bind(&self) {
117 unsafe {
118 ffi::gst_gl_framebuffer_bind(self.as_ref().to_glib_none().0);
119 }
120 }
121
122 /// Retrieve the effective dimensions from the current attachments attached to
123 /// `self`.
124 ///
125 /// # Returns
126 ///
127 ///
128 /// ## `width`
129 /// output width
130 ///
131 /// ## `height`
132 /// output height
133 #[doc(alias = "gst_gl_framebuffer_get_effective_dimensions")]
134 #[doc(alias = "get_effective_dimensions")]
135 fn effective_dimensions(&self) -> (u32, u32) {
136 unsafe {
137 let mut width = std::mem::MaybeUninit::uninit();
138 let mut height = std::mem::MaybeUninit::uninit();
139 ffi::gst_gl_framebuffer_get_effective_dimensions(
140 self.as_ref().to_glib_none().0,
141 width.as_mut_ptr(),
142 height.as_mut_ptr(),
143 );
144 (width.assume_init(), height.assume_init())
145 }
146 }
147
148 ///
149 /// # Returns
150 ///
151 /// the OpenGL id for `self`
152 #[doc(alias = "gst_gl_framebuffer_get_id")]
153 #[doc(alias = "get_id")]
154 fn id(&self) -> u32 {
155 unsafe { ffi::gst_gl_framebuffer_get_id(self.as_ref().to_glib_none().0) }
156 }
157}
158
159impl<O: IsA<GLFramebuffer>> GLFramebufferExt for O {}