1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
use crate::{GLContext, GLSLProfile, GLSLVersion};
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// [`GLSLStage`][crate::GLSLStage] holds and represents a single OpenGL shader stage.
///
/// # Implements
///
/// [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
#[doc(alias = "GstGLSLStage")]
pub struct GLSLStage(Object<ffi::GstGLSLStage, ffi::GstGLSLStageClass>) @extends gst::Object;
match fn {
type_ => || ffi::gst_glsl_stage_get_type(),
}
}
impl GLSLStage {
/// ## `context`
/// a [`GLContext`][crate::GLContext]
/// ## `type_`
/// the GL enum shader stage type
///
/// # Returns
///
/// a new [`GLSLStage`][crate::GLSLStage] of the specified `type_`
#[doc(alias = "gst_glsl_stage_new")]
pub fn new(context: &impl IsA<GLContext>, type_: u32) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new(
context.as_ref().to_glib_none().0,
type_,
))
}
}
/// ## `context`
/// a [`GLContext`][crate::GLContext]
///
/// # Returns
///
/// a new [`GLSLStage`][crate::GLSLStage] with the default fragment shader
#[doc(alias = "gst_glsl_stage_new_default_fragment")]
pub fn new_default_fragment(context: &impl IsA<GLContext>) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_default_fragment(
context.as_ref().to_glib_none().0,
))
}
}
/// ## `context`
/// a [`GLContext`][crate::GLContext]
///
/// # Returns
///
/// a new [`GLSLStage`][crate::GLSLStage] with the default vertex shader
#[doc(alias = "gst_glsl_stage_new_default_vertex")]
pub fn new_default_vertex(context: &impl IsA<GLContext>) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_default_vertex(
context.as_ref().to_glib_none().0,
))
}
}
/// ## `context`
/// a [`GLContext`][crate::GLContext]
/// ## `type_`
/// the GL enum shader stage type
/// ## `version`
/// the [`GLSLVersion`][crate::GLSLVersion]
/// ## `profile`
/// the [`GLSLProfile`][crate::GLSLProfile]
/// ## `str`
/// a shader string
///
/// # Returns
///
/// a new [`GLSLStage`][crate::GLSLStage] of the specified `type_`
#[doc(alias = "gst_glsl_stage_new_with_string")]
#[doc(alias = "new_with_string")]
pub fn with_string(
context: &impl IsA<GLContext>,
type_: u32,
version: GLSLVersion,
profile: GLSLProfile,
str: &str,
) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_with_string(
context.as_ref().to_glib_none().0,
type_,
version.into_glib(),
profile.into_glib(),
str.to_glib_none().0,
))
}
}
/// ## `context`
/// a [`GLContext`][crate::GLContext]
/// ## `type_`
/// the GL enum shader stage type
/// ## `version`
/// the [`GLSLVersion`][crate::GLSLVersion]
/// ## `profile`
/// the [`GLSLProfile`][crate::GLSLProfile]
/// ## `str`
///
/// an array of strings concatted together to produce a shader
///
/// # Returns
///
/// a new [`GLSLStage`][crate::GLSLStage] of the specified `type_`
#[doc(alias = "gst_glsl_stage_new_with_strings")]
#[doc(alias = "new_with_strings")]
pub fn with_strings(
context: &impl IsA<GLContext>,
type_: u32,
version: GLSLVersion,
profile: GLSLProfile,
str: &[&str],
) -> GLSLStage {
skip_assert_initialized!();
let n_strings = str.len() as _;
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_with_strings(
context.as_ref().to_glib_none().0,
type_,
version.into_glib(),
profile.into_glib(),
n_strings,
str.to_glib_none().0,
))
}
}
///
/// # Returns
///
/// whether the compilation succeeded
#[doc(alias = "gst_glsl_stage_compile")]
pub fn compile(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::gst_glsl_stage_compile(self.to_glib_none().0, &mut error);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
///
/// # Returns
///
/// The GL handle for this shader stage
#[doc(alias = "gst_glsl_stage_get_handle")]
#[doc(alias = "get_handle")]
pub fn handle(&self) -> u32 {
unsafe { ffi::gst_glsl_stage_get_handle(self.to_glib_none().0) }
}
///
/// # Returns
///
/// The GLSL profile for the current shader stage
#[doc(alias = "gst_glsl_stage_get_profile")]
#[doc(alias = "get_profile")]
pub fn profile(&self) -> GLSLProfile {
unsafe { from_glib(ffi::gst_glsl_stage_get_profile(self.to_glib_none().0)) }
}
///
/// # Returns
///
/// The GL shader type for this shader stage
#[doc(alias = "gst_glsl_stage_get_shader_type")]
#[doc(alias = "get_shader_type")]
pub fn shader_type(&self) -> u32 {
unsafe { ffi::gst_glsl_stage_get_shader_type(self.to_glib_none().0) }
}
///
/// # Returns
///
/// The GLSL version for the current shader stage
#[doc(alias = "gst_glsl_stage_get_version")]
#[doc(alias = "get_version")]
pub fn version(&self) -> GLSLVersion {
unsafe { from_glib(ffi::gst_glsl_stage_get_version(self.to_glib_none().0)) }
}
/// Replaces the current shader string with `str`.
/// ## `version`
/// a [`GLSLVersion`][crate::GLSLVersion]
/// ## `profile`
/// a [`GLSLProfile`][crate::GLSLProfile]
/// ## `str`
/// a GLSL shader string
#[doc(alias = "gst_glsl_stage_set_strings")]
pub fn set_strings(
&self,
version: GLSLVersion,
profile: GLSLProfile,
str: &[&str],
) -> Result<(), glib::error::BoolError> {
let n_strings = str.len() as _;
unsafe {
glib::result_from_gboolean!(
ffi::gst_glsl_stage_set_strings(
self.to_glib_none().0,
version.into_glib(),
profile.into_glib(),
n_strings,
str.to_glib_none().0
),
"Failed to attach stage to set strings"
)
}
}
}
unsafe impl Send for GLSLStage {}
unsafe impl Sync for GLSLStage {}