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::{ffi, GLBaseMemory, GLContext};
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
86mod sealed {
87    pub trait Sealed {}
88    impl<T: super::IsA<super::GLFramebuffer>> Sealed for T {}
89}
90
91/// Trait containing all [`struct@GLFramebuffer`] methods.
92///
93/// # Implementors
94///
95/// [`GLFramebuffer`][struct@crate::GLFramebuffer]
96pub trait GLFramebufferExt: IsA<GLFramebuffer> + sealed::Sealed + 'static {
97    /// attach `mem` to `attachment_point`
98    ///
99    /// Must be called with the same OpenGL context current that `self` was created
100    /// with.
101    /// ## `attachment_point`
102    /// the OpenGL attachment point to bind `mem` to
103    /// ## `mem`
104    /// the memory object to bind to `attachment_point`
105    #[doc(alias = "gst_gl_framebuffer_attach")]
106    unsafe fn attach(&self, attachment_point: u32, mem: &mut GLBaseMemory) {
107        ffi::gst_gl_framebuffer_attach(
108            self.as_ref().to_glib_none().0,
109            attachment_point,
110            mem.to_glib_none_mut().0,
111        );
112    }
113
114    /// Bind `self` into the current thread
115    ///
116    /// Must be called with the same OpenGL context current that `self` was created
117    /// with.
118    #[doc(alias = "gst_gl_framebuffer_bind")]
119    fn bind(&self) {
120        unsafe {
121            ffi::gst_gl_framebuffer_bind(self.as_ref().to_glib_none().0);
122        }
123    }
124
125    /// Retrieve the effective dimensions from the current attachments attached to
126    /// `self`.
127    ///
128    /// # Returns
129    ///
130    ///
131    /// ## `width`
132    /// output width
133    ///
134    /// ## `height`
135    /// output height
136    #[doc(alias = "gst_gl_framebuffer_get_effective_dimensions")]
137    #[doc(alias = "get_effective_dimensions")]
138    fn effective_dimensions(&self) -> (u32, u32) {
139        unsafe {
140            let mut width = std::mem::MaybeUninit::uninit();
141            let mut height = std::mem::MaybeUninit::uninit();
142            ffi::gst_gl_framebuffer_get_effective_dimensions(
143                self.as_ref().to_glib_none().0,
144                width.as_mut_ptr(),
145                height.as_mut_ptr(),
146            );
147            (width.assume_init(), height.assume_init())
148        }
149    }
150
151    ///
152    /// # Returns
153    ///
154    /// the OpenGL id for `self`
155    #[doc(alias = "gst_gl_framebuffer_get_id")]
156    #[doc(alias = "get_id")]
157    fn id(&self) -> u32 {
158        unsafe { ffi::gst_gl_framebuffer_get_id(self.as_ref().to_glib_none().0) }
159    }
160}
161
162impl<O: IsA<GLFramebuffer>> GLFramebufferExt for O {}