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
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        ffi::gst_gl_framebuffer_attach(
103            self.as_ref().to_glib_none().0,
104            attachment_point,
105            mem.to_glib_none_mut().0,
106        );
107    }
108
109    /// Bind `self` into the current thread
110    ///
111    /// Must be called with the same OpenGL context current that `self` was created
112    /// with.
113    #[doc(alias = "gst_gl_framebuffer_bind")]
114    fn bind(&self) {
115        unsafe {
116            ffi::gst_gl_framebuffer_bind(self.as_ref().to_glib_none().0);
117        }
118    }
119
120    /// Retrieve the effective dimensions from the current attachments attached to
121    /// `self`.
122    ///
123    /// # Returns
124    ///
125    ///
126    /// ## `width`
127    /// output width
128    ///
129    /// ## `height`
130    /// output height
131    #[doc(alias = "gst_gl_framebuffer_get_effective_dimensions")]
132    #[doc(alias = "get_effective_dimensions")]
133    fn effective_dimensions(&self) -> (u32, u32) {
134        unsafe {
135            let mut width = std::mem::MaybeUninit::uninit();
136            let mut height = std::mem::MaybeUninit::uninit();
137            ffi::gst_gl_framebuffer_get_effective_dimensions(
138                self.as_ref().to_glib_none().0,
139                width.as_mut_ptr(),
140                height.as_mut_ptr(),
141            );
142            (width.assume_init(), height.assume_init())
143        }
144    }
145
146    ///
147    /// # Returns
148    ///
149    /// the OpenGL id for `self`
150    #[doc(alias = "gst_gl_framebuffer_get_id")]
151    #[doc(alias = "get_id")]
152    fn id(&self) -> u32 {
153        unsafe { ffi::gst_gl_framebuffer_get_id(self.as_ref().to_glib_none().0) }
154    }
155}
156
157impl<O: IsA<GLFramebuffer>> GLFramebufferExt for O {}