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 // DO NOT EDIT
4 
5 use crate::Display;
6 use crate::Window;
7 use glib::translate::*;
8 use std::fmt;
9 use std::mem;
10 use std::ptr;
11 
12 glib::wrapper! {
13     #[doc(alias = "GdkGLContext")]
14     pub struct GLContext(Object<ffi::GdkGLContext>);
15 
16     match fn {
17         type_ => || ffi::gdk_gl_context_get_type(),
18     }
19 }
20 
21 impl GLContext {
22     #[doc(alias = "gdk_gl_context_get_debug_enabled")]
23     #[doc(alias = "get_debug_enabled")]
is_debug_enabled(&self) -> bool24     pub fn is_debug_enabled(&self) -> bool {
25         unsafe { from_glib(ffi::gdk_gl_context_get_debug_enabled(self.to_glib_none().0)) }
26     }
27 
28     #[doc(alias = "gdk_gl_context_get_display")]
29     #[doc(alias = "get_display")]
display(&self) -> Option<Display>30     pub fn display(&self) -> Option<Display> {
31         unsafe { from_glib_none(ffi::gdk_gl_context_get_display(self.to_glib_none().0)) }
32     }
33 
34     #[doc(alias = "gdk_gl_context_get_forward_compatible")]
35     #[doc(alias = "get_forward_compatible")]
is_forward_compatible(&self) -> bool36     pub fn is_forward_compatible(&self) -> bool {
37         unsafe {
38             from_glib(ffi::gdk_gl_context_get_forward_compatible(
39                 self.to_glib_none().0,
40             ))
41         }
42     }
43 
44     #[doc(alias = "gdk_gl_context_get_required_version")]
45     #[doc(alias = "get_required_version")]
required_version(&self) -> (i32, i32)46     pub fn required_version(&self) -> (i32, i32) {
47         unsafe {
48             let mut major = mem::MaybeUninit::uninit();
49             let mut minor = mem::MaybeUninit::uninit();
50             ffi::gdk_gl_context_get_required_version(
51                 self.to_glib_none().0,
52                 major.as_mut_ptr(),
53                 minor.as_mut_ptr(),
54             );
55             let major = major.assume_init();
56             let minor = minor.assume_init();
57             (major, minor)
58         }
59     }
60 
61     #[doc(alias = "gdk_gl_context_get_shared_context")]
62     #[doc(alias = "get_shared_context")]
shared_context(&self) -> Option<GLContext>63     pub fn shared_context(&self) -> Option<GLContext> {
64         unsafe {
65             from_glib_none(ffi::gdk_gl_context_get_shared_context(
66                 self.to_glib_none().0,
67             ))
68         }
69     }
70 
71     #[cfg(any(feature = "v3_22", feature = "dox"))]
72     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
73     #[doc(alias = "gdk_gl_context_get_use_es")]
74     #[doc(alias = "get_use_es")]
uses_es(&self) -> bool75     pub fn uses_es(&self) -> bool {
76         unsafe { from_glib(ffi::gdk_gl_context_get_use_es(self.to_glib_none().0)) }
77     }
78 
79     #[doc(alias = "gdk_gl_context_get_version")]
80     #[doc(alias = "get_version")]
version(&self) -> (i32, i32)81     pub fn version(&self) -> (i32, i32) {
82         unsafe {
83             let mut major = mem::MaybeUninit::uninit();
84             let mut minor = mem::MaybeUninit::uninit();
85             ffi::gdk_gl_context_get_version(
86                 self.to_glib_none().0,
87                 major.as_mut_ptr(),
88                 minor.as_mut_ptr(),
89             );
90             let major = major.assume_init();
91             let minor = minor.assume_init();
92             (major, minor)
93         }
94     }
95 
96     #[doc(alias = "gdk_gl_context_get_window")]
97     #[doc(alias = "get_window")]
window(&self) -> Option<Window>98     pub fn window(&self) -> Option<Window> {
99         unsafe { from_glib_none(ffi::gdk_gl_context_get_window(self.to_glib_none().0)) }
100     }
101 
102     #[cfg(any(feature = "v3_20", feature = "dox"))]
103     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
104     #[doc(alias = "gdk_gl_context_is_legacy")]
is_legacy(&self) -> bool105     pub fn is_legacy(&self) -> bool {
106         unsafe { from_glib(ffi::gdk_gl_context_is_legacy(self.to_glib_none().0)) }
107     }
108 
109     #[doc(alias = "gdk_gl_context_make_current")]
make_current(&self)110     pub fn make_current(&self) {
111         unsafe {
112             ffi::gdk_gl_context_make_current(self.to_glib_none().0);
113         }
114     }
115 
116     #[doc(alias = "gdk_gl_context_realize")]
realize(&self) -> Result<(), glib::Error>117     pub fn realize(&self) -> Result<(), glib::Error> {
118         unsafe {
119             let mut error = ptr::null_mut();
120             let _ = ffi::gdk_gl_context_realize(self.to_glib_none().0, &mut error);
121             if error.is_null() {
122                 Ok(())
123             } else {
124                 Err(from_glib_full(error))
125             }
126         }
127     }
128 
129     #[doc(alias = "gdk_gl_context_set_debug_enabled")]
set_debug_enabled(&self, enabled: bool)130     pub fn set_debug_enabled(&self, enabled: bool) {
131         unsafe {
132             ffi::gdk_gl_context_set_debug_enabled(self.to_glib_none().0, enabled.into_glib());
133         }
134     }
135 
136     #[doc(alias = "gdk_gl_context_set_forward_compatible")]
set_forward_compatible(&self, compatible: bool)137     pub fn set_forward_compatible(&self, compatible: bool) {
138         unsafe {
139             ffi::gdk_gl_context_set_forward_compatible(
140                 self.to_glib_none().0,
141                 compatible.into_glib(),
142             );
143         }
144     }
145 
146     #[doc(alias = "gdk_gl_context_set_required_version")]
set_required_version(&self, major: i32, minor: i32)147     pub fn set_required_version(&self, major: i32, minor: i32) {
148         unsafe {
149             ffi::gdk_gl_context_set_required_version(self.to_glib_none().0, major, minor);
150         }
151     }
152 
153     #[cfg(any(feature = "v3_22", feature = "dox"))]
154     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
155     #[doc(alias = "gdk_gl_context_set_use_es")]
set_use_es(&self, use_es: i32)156     pub fn set_use_es(&self, use_es: i32) {
157         unsafe {
158             ffi::gdk_gl_context_set_use_es(self.to_glib_none().0, use_es);
159         }
160     }
161 
162     #[doc(alias = "gdk_gl_context_clear_current")]
clear_current()163     pub fn clear_current() {
164         assert_initialized_main_thread!();
165         unsafe {
166             ffi::gdk_gl_context_clear_current();
167         }
168     }
169 
170     #[doc(alias = "gdk_gl_context_get_current")]
171     #[doc(alias = "get_current")]
current() -> Option<GLContext>172     pub fn current() -> Option<GLContext> {
173         assert_initialized_main_thread!();
174         unsafe { from_glib_none(ffi::gdk_gl_context_get_current()) }
175     }
176 }
177 
178 impl fmt::Display for GLContext {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result179     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
180         f.write_str("GLContext")
181     }
182 }
183