cogl/auto/onscreen_template.rs
1use crate::{Object, SwapChain};
2
3use glib::translate::*;
4use std::fmt;
5
6glib_wrapper! {
7 pub struct OnscreenTemplate(Object<ffi::CoglOnscreenTemplate, OnscreenTemplateClass>) @extends Object;
8
9 match fn {
10 get_type => || ffi::cogl_onscreen_template_get_gtype(),
11 }
12}
13
14impl OnscreenTemplate {
15 pub fn new(swap_chain: &SwapChain) -> OnscreenTemplate {
16 unsafe { from_glib_full(ffi::cogl_onscreen_template_new(swap_chain.to_glib_none().0)) }
17 }
18
19 /// Requires that any future CoglOnscreen framebuffers derived from
20 /// this template must support making at least `n` samples per pixel
21 /// which will all contribute to the final resolved color for that
22 /// pixel.
23 ///
24 /// By default this value is usually set to 0 and that is referred to
25 /// as "single-sample" rendering. A value of 1 or greater is referred
26 /// to as "multisample" rendering.
27 ///
28 /// `<note>`There are some semantic differences between single-sample
29 /// rendering and multisampling with just 1 point sample such as it
30 /// being redundant to use the `Framebuffer::resolve_samples` and
31 /// `Framebuffer::resolve_samples_region` apis with single-sample
32 /// rendering.`</note>`
33 /// ## `n`
34 /// The minimum number of samples per pixel
35 pub fn set_samples_per_pixel(&self, n: i32) {
36 unsafe {
37 ffi::cogl_onscreen_template_set_samples_per_pixel(self.to_glib_none().0, n);
38 }
39 }
40
41 /// Sets whether future `Onscreen` framebuffers derived from this
42 /// template are attempted to be created with both left and right
43 /// buffers, for use with stereo display. If the display system
44 /// does not support stereo, then creation of the framebuffer will
45 /// fail.
46 /// ## `enabled`
47 /// Whether framebuffers are created with stereo buffers
48 pub fn set_stereo_enabled(&self, enabled: bool) {
49 unsafe {
50 ffi::cogl_onscreen_template_set_stereo_enabled(self.to_glib_none().0, enabled as i32);
51 }
52 }
53
54 /// Requests that any future `Onscreen` framebuffers derived from this
55 /// template should enable or disable swap throttling according to the given
56 /// `throttled` argument.
57 /// ## `throttled`
58 /// Whether throttling should be enabled
59 pub fn set_swap_throttled(&self, throttled: bool) {
60 unsafe {
61 ffi::cogl_onscreen_template_set_swap_throttled(self.to_glib_none().0, throttled as i32);
62 }
63 }
64}
65
66impl fmt::Display for OnscreenTemplate {
67 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
68 write!(f, "OnscreenTemplate")
69 }
70}