cogl/auto/
framebuffer.rs

1use crate::{
2    Bitmap, Color, ColorMask, Context, Euler, Fence, FenceClosure, Matrix, Object, Pipeline,
3    PixelFormat, Primitive, ReadPixelsFlags, StereoMode, Texture,
4};
5
6use crate::Quaternion;
7
8use glib::object::IsA;
9use glib::translate::*;
10
11use std::boxed::Box as Box_;
12use std::{fmt, ptr};
13
14glib_wrapper! {
15    pub struct Framebuffer(Interface<ffi::CoglFramebuffer>) @requires Object;
16
17    match fn {
18        get_type => || ffi::cogl_framebuffer_get_gtype(),
19    }
20}
21
22impl Framebuffer {
23    pub fn error_quark() -> u32 {
24        unsafe { ffi::cogl_framebuffer_error_quark() }
25    }
26}
27
28pub const NONE_FRAMEBUFFER: Option<&Framebuffer> = None;
29
30/// Trait containing all `Framebuffer` methods.
31///
32/// # Implementors
33///
34/// [`Framebuffer`](struct.Framebuffer.html), [`Onscreen`](struct.Onscreen.html)
35pub trait FramebufferExt: 'static {
36    /// Calls the provided callback when all previously-submitted commands have
37    /// been executed by the GPU.
38    ///
39    /// Returns non-NULL if the fence succeeded, or `None` if it was unable to
40    /// be inserted and the callback will never be called. The user does not
41    /// need to free the closure; it will be freed automatically when the
42    /// callback is called, or cancelled.
43    ///
44    /// ## `callback`
45    /// A `CoglFenceCallback` to be called when
46    ///  all commands submitted to Cogl have been executed
47    /// ## `user_data`
48    /// Private data that will be passed to the callback
49    fn add_fence_callback<P: Fn(&Fence) + 'static>(&self, callback: P) -> Option<FenceClosure>;
50
51    /// Explicitly allocates a configured `Framebuffer` allowing developers to
52    /// check and handle any errors that might arise from an unsupported
53    /// configuration so that fallback configurations may be tried.
54    ///
55    /// `<note>`Many applications don't support any fallback options at least when
56    /// they are initially developed and in that case the don't need to use this API
57    /// since Cogl will automatically allocate a framebuffer when it first gets
58    /// used. The disadvantage of relying on automatic allocation is that the
59    /// program will abort with an error message if there is an error during
60    /// automatic allocation.`</note>`
61    ///
62    /// # Returns
63    ///
64    /// `true` if there were no error allocating the framebuffer, else `false`.
65    fn allocate(&self) -> Result<bool, glib::Error>;
66
67    /// Removes a fence previously submitted with
68    /// `Framebuffer::add_fence_callback`; the callback will not be
69    /// called.
70    ///
71    /// ## `closure`
72    /// The `FenceClosure` returned from
73    ///  `Framebuffer::add_fence_callback`
74    fn cancel_fence_callback(&self, closure: &mut FenceClosure);
75
76    /// Clears all the auxiliary buffers identified in the `buffers` mask, and if
77    /// that includes the color buffer then the specified `color` is used.
78    /// ## `buffers`
79    /// A mask of `BufferBit`<!-- -->'s identifying which auxiliary
80    ///  buffers to clear
81    /// ## `color`
82    /// The color to clear the color buffer too if specified in
83    ///  `buffers`.
84    fn clear(&self, buffers: libc::c_ulong, color: &Color);
85
86    /// Clears all the auxiliary buffers identified in the `buffers` mask, and if
87    /// that includes the color buffer then the specified `color` is used.
88    /// ## `buffers`
89    /// A mask of `BufferBit`<!-- -->'s identifying which auxiliary
90    ///  buffers to clear
91    /// ## `red`
92    /// The red component of color to clear the color buffer too if
93    ///  specified in `buffers`.
94    /// ## `green`
95    /// The green component of color to clear the color buffer too if
96    ///  specified in `buffers`.
97    /// ## `blue`
98    /// The blue component of color to clear the color buffer too if
99    ///  specified in `buffers`.
100    /// ## `alpha`
101    /// The alpha component of color to clear the color buffer too if
102    ///  specified in `buffers`.
103    fn clear4f(&self, buffers: libc::c_ulong, red: f32, green: f32, blue: f32, alpha: f32);
104
105    /// Declares that the specified `buffers` no longer need to be referenced
106    /// by any further rendering commands. This can be an important
107    /// optimization to avoid subsequent frames of rendering depending on
108    /// the results of a previous frame.
109    ///
110    /// For example; some tile-based rendering GPUs are able to avoid allocating and
111    /// accessing system memory for the depth and stencil buffer so long as these
112    /// buffers are not required as input for subsequent frames and that can save a
113    /// significant amount of memory bandwidth used to save and restore their
114    /// contents to system memory between frames.
115    ///
116    /// It is currently considered an error to try and explicitly discard the color
117    /// buffer by passing `BufferBit::Color`. This is because the color buffer is
118    /// already implicitly discard when you finish rendering to a `Onscreen`
119    /// framebuffer, and it's not meaningful to try and discard the color buffer of
120    /// a `CoglOffscreen` framebuffer since they are single-buffered.
121    /// ## `buffers`
122    /// A `BufferBit` mask of which ancillary buffers you want
123    ///  to discard.
124    fn discard_buffers(&self, buffers: libc::c_ulong);
125
126    /// Draws a textured rectangle to `self` with the given `pipeline`
127    /// state with the top left corner positioned at (`x_1`, `y_1`) and the
128    /// bottom right corner positioned at (`x_2`, `y_2`). As a pipeline may
129    /// contain multiple texture layers this interface lets you supply
130    /// texture coordinates for each layer of the pipeline.
131    ///
132    /// `<note>`The position is the position before the rectangle has been
133    /// transformed by the model-view matrix and the projection
134    /// matrix.`</note>`
135    ///
136    /// This is a high level drawing api that can handle any kind of
137    /// `MetaTexture` texture for the first layer such as
138    /// `Texture2DSliced` textures which may internally be comprised of
139    /// multiple low-level textures. This is unlike low-level drawing apis
140    /// such as `Primitive::draw` which only support low level texture
141    /// types that are directly supported by GPUs such as `Texture2D`.
142    ///
143    /// `<note>`This api can not currently handle multiple high-level meta
144    /// texture layers. The first layer may be a high level meta texture
145    /// such as `Texture2DSliced` but all other layers much be low
146    /// level textures such as `Texture2D` and additionally they
147    /// should be textures that can be sampled using normalized coordinates
148    /// (so not `TextureRectangle` textures).`</note>`
149    ///
150    /// The top left texture coordinate for layer 0 of any pipeline will be
151    /// (tex_coords[0], tex_coords[1]) and the bottom right coordinate will
152    /// be (tex_coords[2], tex_coords[3]). The coordinates for layer 1
153    /// would be (tex_coords[4], tex_coords[5]) (tex_coords[6],
154    /// tex_coords[7]) and so on...
155    ///
156    /// The given texture coordinates should always be normalized such that
157    /// (0, 0) corresponds to the top left and (1, 1) corresponds to the
158    /// bottom right. To map an entire texture across the rectangle pass
159    /// in tex_coords[0]=0, tex_coords[1]=0, tex_coords[2]=1,
160    /// tex_coords[3]=1.
161    ///
162    /// `<note>`Even if you have associated a `TextureRectangle` texture
163    /// which normally implies working with non-normalized texture
164    /// coordinates this api should still be passed normalized texture
165    /// coordinates.`</note>`
166    ///
167    /// The first pair of coordinates are for the first layer (with the
168    /// smallest layer index) and if you supply less texture coordinates
169    /// than there are layers in the current source material then default
170    /// texture coordinates (0.0, 0.0, 1.0, 1.0) are generated.
171    /// ## `pipeline`
172    /// A `Pipeline` state object
173    /// ## `x_1`
174    /// x coordinate upper left on screen.
175    /// ## `y_1`
176    /// y coordinate upper left on screen.
177    /// ## `x_2`
178    /// x coordinate lower right on screen.
179    /// ## `y_2`
180    /// y coordinate lower right on screen.
181    /// ## `tex_coords`
182    /// An array containing groups of
183    ///  4 float values: [s_1, t_1, s_2, t_2] that are interpreted as two texture
184    ///  coordinates; one for the top left texel, and one for the bottom right
185    ///  texel. Each value should be between 0.0 and 1.0, where the coordinate
186    ///  (0.0, 0.0) represents the top left of the texture, and (1.0, 1.0) the
187    ///  bottom right.
188    /// ## `tex_coords_len`
189    /// The length of the `tex_coords` array. (For one layer
190    ///  and one group of texture coordinates, this would be 4)
191    fn draw_multitextured_rectangle(
192        &self,
193        pipeline: &Pipeline,
194        x_1: f32,
195        y_1: f32,
196        x_2: f32,
197        y_2: f32,
198        tex_coords: &[f32],
199    );
200
201    /// Draws a rectangle to `self` with the given `pipeline` state
202    /// and with the top left corner positioned at (`x_1`, `y_1`) and the
203    /// bottom right corner positioned at (`x_2`, `y_2`).
204    ///
205    /// `<note>`The position is the position before the rectangle has been
206    /// transformed by the model-view matrix and the projection
207    /// matrix.`</note>`
208    ///
209    /// `<note>`If you want to describe a rectangle with a texture mapped on
210    /// it then you can use
211    /// `Framebuffer::draw_textured_rectangle`.`</note>`
212    /// ## `pipeline`
213    /// A `Pipeline` state object
214    /// ## `x_1`
215    /// X coordinate of the top-left corner
216    /// ## `y_1`
217    /// Y coordinate of the top-left corner
218    /// ## `x_2`
219    /// X coordinate of the bottom-right corner
220    /// ## `y_2`
221    /// Y coordinate of the bottom-right corner
222    fn draw_rectangle(&self, pipeline: &Pipeline, x_1: f32, y_1: f32, x_2: f32, y_2: f32);
223
224    //fn draw_rectangles(&self, pipeline: &Pipeline, coordinates: &[f32], n_rectangles: u32);
225
226    /// Draws a textured rectangle to `self` using the given
227    /// `pipeline` state with the top left corner positioned at (`x_1`, `y_1`)
228    /// and the bottom right corner positioned at (`x_2`, `y_2`). The top
229    /// left corner will have texture coordinates of (`s_1`, `t_1`) and the
230    /// bottom right corner will have texture coordinates of (`s_2`, `t_2`).
231    ///
232    /// `<note>`The position is the position before the rectangle has been
233    /// transformed by the model-view matrix and the projection
234    /// matrix.`</note>`
235    ///
236    /// This is a high level drawing api that can handle any kind of
237    /// `MetaTexture` texture such as `Texture2DSliced` textures
238    /// which may internally be comprised of multiple low-level textures.
239    /// This is unlike low-level drawing apis such as `Primitive::draw`
240    /// which only support low level texture types that are directly
241    /// supported by GPUs such as `Texture2D`.
242    ///
243    /// `<note>`The given texture coordinates will only be used for the first
244    /// texture layer of the pipeline and if your pipeline has more than
245    /// one layer then all other layers will have default texture
246    /// coordinates of `s_1`=0.0 `t_1`=0.0 `s_2`=1.0 `t_2`=1.0 `</note>`
247    ///
248    /// The given texture coordinates should always be normalized such that
249    /// (0, 0) corresponds to the top left and (1, 1) corresponds to the
250    /// bottom right. To map an entire texture across the rectangle pass
251    /// in `s_1`=0, `t_1`=0, `s_2`=1, `t_2`=1.
252    ///
253    /// `<note>`Even if you have associated a `TextureRectangle` texture
254    /// with one of your `pipeline` layers which normally implies working
255    /// with non-normalized texture coordinates this api should still be
256    /// passed normalized texture coordinates.`</note>`
257    /// ## `pipeline`
258    /// A `Pipeline` state object
259    /// ## `x_1`
260    /// x coordinate upper left on screen.
261    /// ## `y_1`
262    /// y coordinate upper left on screen.
263    /// ## `x_2`
264    /// x coordinate lower right on screen.
265    /// ## `y_2`
266    /// y coordinate lower right on screen.
267    /// ## `s_1`
268    /// S texture coordinate of the top-left coorner
269    /// ## `t_1`
270    /// T texture coordinate of the top-left coorner
271    /// ## `s_2`
272    /// S texture coordinate of the bottom-right coorner
273    /// ## `t_2`
274    /// T texture coordinate of the bottom-right coorner
275    fn draw_textured_rectangle(
276        &self,
277        pipeline: &Pipeline,
278        x_1: f32,
279        y_1: f32,
280        x_2: f32,
281        y_2: f32,
282        s_1: f32,
283        t_1: f32,
284        s_2: f32,
285        t_2: f32,
286    );
287
288    //fn draw_textured_rectangles(&self, pipeline: &Pipeline, coordinates: &[f32], n_rectangles: u32);
289
290    /// This blocks the CPU until all pending rendering associated with the
291    /// specified framebuffer has completed. It's very rare that developers should
292    /// ever need this level of synchronization with the GPU and should never be
293    /// used unless you clearly understand why you need to explicitly force
294    /// synchronization.
295    ///
296    /// One example might be for benchmarking purposes to be sure timing
297    /// measurements reflect the time that the GPU is busy for not just the time it
298    /// takes to queue rendering commands.
299    fn finish(&self);
300
301    /// Replaces the current projection matrix with a perspective matrix
302    /// for a given viewing frustum defined by 4 side clip planes that
303    /// all cross through the origin and 2 near and far clip planes.
304    /// ## `left`
305    /// X position of the left clipping plane where it
306    ///  intersects the near clipping plane
307    /// ## `right`
308    /// X position of the right clipping plane where it
309    ///  intersects the near clipping plane
310    /// ## `bottom`
311    /// Y position of the bottom clipping plane where it
312    ///  intersects the near clipping plane
313    /// ## `top`
314    /// Y position of the top clipping plane where it intersects
315    ///  the near clipping plane
316    /// ## `z_near`
317    /// The distance to the near clipping plane (Must be positive)
318    /// ## `z_far`
319    /// The distance to the far clipping plane (Must be positive)
320    fn frustum(&self, left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32);
321
322    /// Retrieves the number of alpha bits of `self`
323    ///
324    /// # Returns
325    ///
326    /// the number of bits
327    fn get_alpha_bits(&self) -> i32;
328
329    /// Retrieves the number of blue bits of `self`
330    ///
331    /// # Returns
332    ///
333    /// the number of bits
334    fn get_blue_bits(&self) -> i32;
335
336    /// Gets the current `ColorMask` of which channels would be written to the
337    /// current framebuffer. Each bit set in the mask means that the
338    /// corresponding color would be written.
339    ///
340    /// # Returns
341    ///
342    /// A `ColorMask`
343    fn get_color_mask(&self) -> ColorMask;
344
345    /// Can be used to query the `Context` a given `self` was
346    /// instantiated within. This is the `Context` that was passed to
347    /// `Onscreen::new` for example.
348    ///
349    /// # Returns
350    ///
351    /// The `Context` that the given
352    ///  `self` was instantiated within.
353    fn get_context(&self) -> Option<Context>;
354
355    /// Retrieves the number of depth bits of `self`
356    ///
357    ///
358    /// # Returns
359    ///
360    /// the number of bits
361    fn get_depth_bits(&self) -> i32;
362
363    /// Retrieves the depth buffer of `self` as a `Texture`. You need to
364    /// call cogl_framebuffer_get_depth_texture(fb, TRUE); before using this
365    /// function.
366    ///
367    /// `<note>`Calling this function implicitely allocates the framebuffer.`</note>`
368    /// `<note>`The texture returned stays valid as long as the framebuffer stays
369    /// valid.`</note>`
370    ///
371    /// # Returns
372    ///
373    /// the depth texture
374    fn get_depth_texture(&self) -> Option<Texture>;
375
376    /// Queries whether texture based depth buffer has been enabled via
377    /// `Framebuffer::set_depth_texture_enabled`.
378    ///
379    /// # Returns
380    ///
381    /// `true` if a depth texture has been enabled, else
382    ///  `false`.
383    fn get_depth_texture_enabled(&self) -> bool;
384
385    /// Queries whether depth buffer writing is enabled for `self`. This
386    /// can be controlled via `Framebuffer::set_depth_write_enabled`.
387    ///
388    /// # Returns
389    ///
390    /// `true` if depth writing is enabled or `false` if not.
391    fn get_depth_write_enabled(&self) -> bool;
392
393    /// Returns whether dithering has been requested for the given `self`.
394    /// See `Framebuffer::set_dither_enabled` for more details about dithering.
395    ///
396    /// `<note>`This may return `true` even when the underlying `self`
397    /// display pipeline does not support dithering. This value only represents
398    /// the user's request for dithering.`</note>`
399    ///
400    /// # Returns
401    ///
402    /// `true` if dithering has been requested or `false` if not.
403    fn get_dither_enabled(&self) -> bool;
404
405    /// Retrieves the number of green bits of `self`
406    ///
407    /// # Returns
408    ///
409    /// the number of bits
410    fn get_green_bits(&self) -> i32;
411
412    /// Queries the current height of the given `self`.
413    ///
414    /// # Returns
415    ///
416    /// The height of `self`.
417    fn get_height(&self) -> i32;
418
419    fn get_is_stereo(&self) -> bool;
420
421    /// Stores the current model-view matrix in `matrix`.
422    /// ## `matrix`
423    /// return location for the model-view matrix
424    fn get_modelview_matrix(&self) -> Matrix;
425
426    /// Stores the current projection matrix in `matrix`.
427    /// ## `matrix`
428    /// return location for the projection matrix
429    fn get_projection_matrix(&self) -> Matrix;
430
431    /// Retrieves the number of red bits of `self`
432    ///
433    /// # Returns
434    ///
435    /// the number of bits
436    fn get_red_bits(&self) -> i32;
437
438    /// Gets the number of points that are sampled per-pixel when
439    /// rasterizing geometry. Usually by default this will return 0 which
440    /// means that single-sample not multisample rendering has been chosen.
441    /// When using a GPU supporting multisample rendering it's possible to
442    /// increase the number of samples per pixel using
443    /// `Framebuffer::set_samples_per_pixel`.
444    ///
445    /// Calling `Framebuffer::get_samples_per_pixel` before the
446    /// framebuffer has been allocated will simply return the value set
447    /// using `Framebuffer::set_samples_per_pixel`. After the
448    /// framebuffer has been allocated the value will reflect the actual
449    /// number of samples that will be made by the GPU.
450    ///
451    /// # Returns
452    ///
453    /// The number of point samples made per pixel when
454    ///  rasterizing geometry or 0 if single-sample rendering
455    ///  has been chosen.
456    fn get_samples_per_pixel(&self) -> i32;
457
458    /// Gets the current `StereoMode`, which defines which stereo buffers
459    /// should be drawn to. See `Framebuffer::set_stereo_mode`.
460    ///
461    /// # Returns
462    ///
463    /// A `StereoMode`
464    fn get_stereo_mode(&self) -> StereoMode;
465
466    //fn get_viewport4fv(&self, viewport: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 20 }; 4);
467
468    /// Queries the height of the viewport as set using `Framebuffer::set_viewport`
469    /// or the default value which is the height of the framebuffer.
470    ///
471    /// # Returns
472    ///
473    /// The height of the viewport.
474    fn get_viewport_height(&self) -> f32;
475
476    /// Queries the width of the viewport as set using `Framebuffer::set_viewport`
477    /// or the default value which is the width of the framebuffer.
478    ///
479    /// # Returns
480    ///
481    /// The width of the viewport.
482    fn get_viewport_width(&self) -> f32;
483
484    /// Queries the x coordinate of the viewport origin as set using `Framebuffer::set_viewport`
485    /// or the default value which is 0.
486    ///
487    /// # Returns
488    ///
489    /// The x coordinate of the viewport origin.
490    fn get_viewport_x(&self) -> f32;
491
492    /// Queries the y coordinate of the viewport origin as set using `Framebuffer::set_viewport`
493    /// or the default value which is 0.
494    ///
495    /// # Returns
496    ///
497    /// The y coordinate of the viewport origin.
498    fn get_viewport_y(&self) -> f32;
499
500    /// Queries the current width of the given `self`.
501    ///
502    /// # Returns
503    ///
504    /// The width of `self`.
505    fn get_width(&self) -> i32;
506
507    /// Resets the current model-view matrix to the identity matrix.
508    fn identity_matrix(&self);
509
510    /// Replaces the current projection matrix with an orthographic projection
511    /// matrix.
512    /// ## `x_1`
513    /// The x coordinate for the first vertical clipping plane
514    /// ## `y_1`
515    /// The y coordinate for the first horizontal clipping plane
516    /// ## `x_2`
517    /// The x coordinate for the second vertical clipping plane
518    /// ## `y_2`
519    /// The y coordinate for the second horizontal clipping plane
520    /// ## `near`
521    /// The `<emphasis>`distance`</emphasis>` to the near clipping
522    ///  plane (will be `<emphasis>`negative`</emphasis>` if the plane is
523    ///  behind the viewer)
524    /// ## `far`
525    /// The `<emphasis>`distance`</emphasis>` to the far clipping
526    ///  plane (will be `<emphasis>`negative`</emphasis>` if the plane is
527    ///  behind the viewer)
528    fn orthographic(&self, x_1: f32, y_1: f32, x_2: f32, y_2: f32, near: f32, far: f32);
529
530    /// Replaces the current projection matrix with a perspective matrix
531    /// based on the provided values.
532    ///
533    /// `<note>`You should be careful not to have to great a `z_far` / `z_near`
534    /// ratio since that will reduce the effectiveness of depth testing
535    /// since there wont be enough precision to identify the depth of
536    /// objects near to each other.`</note>`
537    /// ## `fov_y`
538    /// Vertical field of view angle in degrees.
539    /// ## `aspect`
540    /// The (width over height) aspect ratio for display
541    /// ## `z_near`
542    /// The distance to the near clipping plane (Must be positive,
543    ///  and must not be 0)
544    /// ## `z_far`
545    /// The distance to the far clipping plane (Must be positive)
546    fn perspective(&self, fov_y: f32, aspect: f32, z_near: f32, z_far: f32);
547
548    /// Reverts the clipping region to the state before the last call to
549    /// `Framebuffer::push_scissor_clip`, `Framebuffer::push_rectangle_clip`
550    /// `cogl_framebuffer_push_path_clip`, or `Framebuffer::push_primitive_clip`.
551    fn pop_clip(&self);
552
553    /// Restores the model-view matrix on the top of the matrix stack.
554    fn pop_matrix(&self);
555
556    /// Copies the current model-view matrix onto the matrix stack. The matrix
557    /// can later be restored with `Framebuffer::pop_matrix`.
558    fn push_matrix(&self);
559
560    /// Sets a new clipping area using a 2D shaped described with a
561    /// `Primitive`. The shape must not contain self overlapping
562    /// geometry and must lie on a single 2D plane. A bounding box of the
563    /// 2D shape in local coordinates (the same coordinates used to
564    /// describe the shape) must be given. It is acceptable for the bounds
565    /// to be larger than the true bounds but behaviour is undefined if the
566    /// bounds are smaller than the true bounds.
567    ///
568    /// The primitive is transformed by the current model-view matrix and
569    /// the silhouette is intersected with the previous clipping area. To
570    /// restore the previous clipping area, call
571    /// `Framebuffer::pop_clip`.
572    /// ## `primitive`
573    /// A `Primitive` describing a flat 2D shape
574    /// ## `bounds_x1`
575    /// x coordinate for the top-left corner of the primitives
576    ///  bounds
577    /// ## `bounds_y1`
578    /// y coordinate for the top-left corner of the primitives
579    ///  bounds
580    /// ## `bounds_x2`
581    /// x coordinate for the bottom-right corner of the
582    ///  primitives bounds.
583    /// ## `bounds_y2`
584    /// y coordinate for the bottom-right corner of the
585    ///  primitives bounds.
586    fn push_primitive_clip(
587        &self,
588        primitive: &Primitive,
589        bounds_x1: f32,
590        bounds_y1: f32,
591        bounds_x2: f32,
592        bounds_y2: f32,
593    );
594
595    /// Specifies a modelview transformed rectangular clipping area for all
596    /// subsequent drawing operations. Any drawing commands that extend
597    /// outside the rectangle will be clipped so that only the portion
598    /// inside the rectangle will be displayed. The rectangle dimensions
599    /// are transformed by the current model-view matrix.
600    ///
601    /// The rectangle is intersected with the current clip region. To undo
602    /// the effect of this function, call `Framebuffer::pop_clip`.
603    /// ## `x_1`
604    /// x coordinate for top left corner of the clip rectangle
605    /// ## `y_1`
606    /// y coordinate for top left corner of the clip rectangle
607    /// ## `x_2`
608    /// x coordinate for bottom right corner of the clip rectangle
609    /// ## `y_2`
610    /// y coordinate for bottom right corner of the clip rectangle
611    fn push_rectangle_clip(&self, x_1: f32, y_1: f32, x_2: f32, y_2: f32);
612
613    /// Specifies a rectangular clipping area for all subsequent drawing
614    /// operations. Any drawing commands that extend outside the rectangle
615    /// will be clipped so that only the portion inside the rectangle will
616    /// be displayed. The rectangle dimensions are not transformed by the
617    /// current model-view matrix.
618    ///
619    /// The rectangle is intersected with the current clip region. To undo
620    /// the effect of this function, call `Framebuffer::pop_clip`.
621    /// ## `x`
622    /// left edge of the clip rectangle in window coordinates
623    /// ## `y`
624    /// top edge of the clip rectangle in window coordinates
625    /// ## `width`
626    /// width of the clip rectangle
627    /// ## `height`
628    /// height of the clip rectangle
629    fn push_scissor_clip(&self, x: i32, y: i32, width: i32, height: i32);
630
631    /// This is a convenience wrapper around
632    /// `Framebuffer::read_pixels_into_bitmap` which allocates a
633    /// temporary `Bitmap` to read pixel data directly into the given
634    /// buffer. The rowstride of the buffer is assumed to be the width of
635    /// the region times the bytes per pixel of the format. The source for
636    /// the data is always taken from the color buffer. If you want to use
637    /// any other rowstride or source, please use the
638    /// `Framebuffer::read_pixels_into_bitmap` function directly.
639    ///
640    /// The implementation of the function looks like this:
641    ///
642    ///
643    /// ```text
644    /// bitmap = cogl_bitmap_new_for_data (context,
645    ///                                    width, height,
646    ///                                    format,
647    ///                                    /<!-- -->* rowstride *<!-- -->/
648    ///                                    bpp * width,
649    ///                                    pixels);
650    /// cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
651    ///                                           x, y,
652    ///                                           COGL_READ_PIXELS_COLOR_BUFFER,
653    ///                                           bitmap);
654    /// cogl_object_unref (bitmap);
655    /// ```
656    /// ## `x`
657    /// The x position to read from
658    /// ## `y`
659    /// The y position to read from
660    /// ## `width`
661    /// The width of the region of rectangles to read
662    /// ## `height`
663    /// The height of the region of rectangles to read
664    /// ## `format`
665    /// The pixel format to store the data in
666    /// ## `pixels`
667    /// The address of the buffer to store the data in
668    ///
669    /// # Returns
670    ///
671    /// `true` if the read succeeded or `false` otherwise.
672    fn read_pixels(
673        &self,
674        x: i32,
675        y: i32,
676        width: i32,
677        height: i32,
678        format: PixelFormat,
679        pixels: &[u8],
680    ) -> bool;
681
682    /// This reads a rectangle of pixels from the given framebuffer where
683    /// position (0, 0) is the top left. The pixel at (x, y) is the first
684    /// read, and a rectangle of pixels with the same size as the bitmap is
685    /// read right and downwards from that point.
686    ///
687    /// Currently Cogl assumes that the framebuffer is in a premultiplied
688    /// format so if the format of `bitmap` is non-premultiplied it will
689    /// convert it. To read the pixel values without any conversion you
690    /// should either specify a format that doesn't use an alpha channel or
691    /// use one of the formats ending in PRE.
692    /// ## `x`
693    /// The x position to read from
694    /// ## `y`
695    /// The y position to read from
696    /// ## `source`
697    /// Identifies which auxillary buffer you want to read
698    ///  (only COGL_READ_PIXELS_COLOR_BUFFER supported currently)
699    /// ## `bitmap`
700    /// The bitmap to store the results in.
701    ///
702    /// # Returns
703    ///
704    /// `true` if the read succeeded or `false` otherwise. The
705    ///  function is only likely to fail if the bitmap points to a pixel
706    ///  buffer and it could not be mapped.
707    fn read_pixels_into_bitmap(
708        &self,
709        x: i32,
710        y: i32,
711        source: ReadPixelsFlags,
712        bitmap: &Bitmap,
713    ) -> bool;
714
715    /// When point sample rendering (also known as multisample rendering)
716    /// has been enabled via `Framebuffer::set_samples_per_pixel`
717    /// then you can optionally call this function (or
718    /// `Framebuffer::resolve_samples_region`) to explicitly resolve
719    /// the point samples into values for the final color buffer.
720    ///
721    /// Some GPUs will implicitly resolve the point samples during
722    /// rendering and so this function is effectively a nop, but with other
723    /// architectures it is desirable to defer the resolve step until the
724    /// end of the frame.
725    ///
726    /// Since Cogl will automatically ensure samples are resolved if the
727    /// target color buffer is used as a source this API only needs to be
728    /// used if explicit control is desired - perhaps because you want to
729    /// ensure that the resolve is completed in advance to avoid later
730    /// having to wait for the resolve to complete.
731    ///
732    /// If you are performing incremental updates to a framebuffer you
733    /// should consider using `Framebuffer::resolve_samples_region`
734    /// instead to avoid resolving redundant pixels.
735    fn resolve_samples(&self);
736
737    /// When point sample rendering (also known as multisample rendering)
738    /// has been enabled via `Framebuffer::set_samples_per_pixel`
739    /// then you can optionally call this function (or
740    /// `Framebuffer::resolve_samples`) to explicitly resolve the point
741    /// samples into values for the final color buffer.
742    ///
743    /// Some GPUs will implicitly resolve the point samples during
744    /// rendering and so this function is effectively a nop, but with other
745    /// architectures it is desirable to defer the resolve step until the
746    /// end of the frame.
747    ///
748    /// Use of this API is recommended if incremental, small updates to
749    /// a framebuffer are being made because by default Cogl will
750    /// implicitly resolve all the point samples of the framebuffer which
751    /// can result in redundant work if only a small number of samples have
752    /// changed.
753    ///
754    /// Because some GPUs implicitly resolve point samples this function
755    /// only guarantees that at-least the region specified will be resolved
756    /// and if you have rendered to a larger region then it's possible that
757    /// other samples may be implicitly resolved.
758    /// ## `x`
759    /// top-left x coordinate of region to resolve
760    /// ## `y`
761    /// top-left y coordinate of region to resolve
762    /// ## `width`
763    /// width of region to resolve
764    /// ## `height`
765    /// height of region to resolve
766    fn resolve_samples_region(&self, x: i32, y: i32, width: i32, height: i32);
767
768    /// Multiplies the current model-view matrix by one that rotates the
769    /// model around the axis-vector specified by `x`, `y` and `z`. The
770    /// rotation follows the right-hand thumb rule so for example rotating
771    /// by 10 degrees about the axis-vector (0, 0, 1) causes a small
772    /// counter-clockwise rotation.
773    /// ## `angle`
774    /// Angle in degrees to rotate.
775    /// ## `x`
776    /// X-component of vertex to rotate around.
777    /// ## `y`
778    /// Y-component of vertex to rotate around.
779    /// ## `z`
780    /// Z-component of vertex to rotate around.
781    fn rotate(&self, angle: f32, x: f32, y: f32, z: f32);
782
783    /// Multiplies the current model-view matrix by one that rotates
784    /// according to the rotation described by `euler`.
785    ///
786    /// ## `euler`
787    /// A `Euler`
788    fn rotate_euler(&self, euler: &Euler);
789
790    /// Multiplies the current model-view matrix by one that rotates
791    /// according to the rotation described by `quaternion`.
792    ///
793    /// ## `quaternion`
794    /// A `Quaternion`
795    fn rotate_quaternion(&self, quaternion: &Quaternion);
796
797    /// Multiplies the current model-view matrix by one that scales the x,
798    /// y and z axes by the given values.
799    /// ## `x`
800    /// Amount to scale along the x-axis
801    /// ## `y`
802    /// Amount to scale along the y-axis
803    /// ## `z`
804    /// Amount to scale along the z-axis
805    fn scale(&self, x: f32, y: f32, z: f32);
806
807    /// Defines a bit mask of which color channels should be written to the
808    /// given `self`. If a bit is set in `color_mask` that means that
809    /// color will be written.
810    /// ## `color_mask`
811    /// A `ColorMask` of which color channels to write to
812    ///  the current framebuffer.
813    fn set_color_mask(&self, color_mask: ColorMask);
814
815    /// If `enabled` is `true`, the depth buffer used when rendering to `self`
816    /// is available as a texture. You can retrieve the texture with
817    /// `Framebuffer::get_depth_texture`.
818    ///
819    /// `<note>`It's possible that your GPU does not support depth textures. You
820    /// should check the `FeatureID::OglFeatureIdDepthTexture` feature before using this
821    /// function.`</note>`
822    /// `<note>`It's not valid to call this function after the framebuffer has been
823    /// allocated as the creation of the depth texture is done at allocation time.
824    /// `</note>`
825    /// ## `enabled`
826    /// TRUE or FALSE
827    fn set_depth_texture_enabled(&self, enabled: bool);
828
829    /// Enables or disables depth buffer writing when rendering to `self`.
830    /// If depth writing is enabled for both the framebuffer and the rendering
831    /// pipeline, and the framebuffer has an associated depth buffer, depth
832    /// information will be written to this buffer during rendering.
833    ///
834    /// Depth buffer writing is enabled by default.
835    /// ## `depth_write_enabled`
836    /// `true` to enable depth writing or `false` to disable
837    fn set_depth_write_enabled(&self, depth_write_enabled: bool);
838
839    /// Enables or disabled dithering if supported by the hardware.
840    ///
841    /// Dithering is a hardware dependent technique to increase the visible
842    /// color resolution beyond what the underlying hardware supports by playing
843    /// tricks with the colors placed into the framebuffer to give the illusion
844    /// of other colors. (For example this can be compared to half-toning used
845    /// by some news papers to show varying levels of grey even though their may
846    /// only be black and white are available).
847    ///
848    /// If the current display pipeline for `self` does not support dithering
849    /// then this has no affect.
850    ///
851    /// Dithering is enabled by default.
852    /// ## `dither_enabled`
853    /// `true` to enable dithering or `false` to disable
854    fn set_dither_enabled(&self, dither_enabled: bool);
855
856    /// Sets `matrix` as the new model-view matrix.
857    /// ## `matrix`
858    /// the new model-view matrix
859    fn set_modelview_matrix(&self, matrix: &Matrix);
860
861    /// Sets `matrix` as the new projection matrix.
862    /// ## `matrix`
863    /// the new projection matrix
864    fn set_projection_matrix(&self, matrix: &Matrix);
865
866    /// Requires that when rendering to `self` then `n` point samples
867    /// should be made per pixel which will all contribute to the final
868    /// resolved color for that pixel. The idea is that the hardware aims
869    /// to get quality similar to what you would get if you rendered
870    /// everything twice as big (for 4 samples per pixel) and then scaled
871    /// that image back down with filtering. It can effectively remove the
872    /// jagged edges of polygons and should be more efficient than if you
873    /// were to manually render at a higher resolution and downscale
874    /// because the hardware is often able to take some shortcuts. For
875    /// example the GPU may only calculate a single texture sample for all
876    /// points of a single pixel, and for tile based architectures all the
877    /// extra sample data (such as depth and stencil samples) may be
878    /// handled on-chip and so avoid increased demand on system memory
879    /// bandwidth.
880    ///
881    /// By default this value is usually set to 0 and that is referred to
882    /// as "single-sample" rendering. A value of 1 or greater is referred
883    /// to as "multisample" rendering.
884    ///
885    /// `<note>`There are some semantic differences between single-sample
886    /// rendering and multisampling with just 1 point sample such as it
887    /// being redundant to use the `Framebuffer::resolve_samples` and
888    /// `Framebuffer::resolve_samples_region` apis with single-sample
889    /// rendering.`</note>`
890    ///
891    /// `<note>`It's recommended that
892    /// `Framebuffer::resolve_samples_region` be explicitly used at the
893    /// end of rendering to a point sample buffer to minimize the number of
894    /// samples that get resolved. By default Cogl will implicitly resolve
895    /// all framebuffer samples but if only a small region of a
896    /// framebuffer has changed this can lead to redundant work being
897    /// done.`</note>`
898    /// ## `samples_per_pixel`
899    /// The minimum number of samples per pixel
900    fn set_samples_per_pixel(&self, samples_per_pixel: i32);
901
902    /// Sets which stereo buffers should be drawn to. The default
903    /// is `StereoMode::Both`, which means that both the left and
904    /// right buffers will be affected by drawing. For this to have
905    /// an effect, the display system must support stereo drawables,
906    /// and the framebuffer must have been created with stereo
907    /// enabled. (See `OnscreenTemplate::set_stereo_enabled`,
908    /// `Framebuffer::get_is_stereo`.)
909    /// ## `stereo_mode`
910    /// A `StereoMode` specifying which stereo buffers
911    ///  should be drawn tow.
912    fn set_stereo_mode(&self, stereo_mode: StereoMode);
913
914    /// Defines a scale and offset for everything rendered relative to the
915    /// top-left of the destination framebuffer.
916    ///
917    /// By default the viewport has an origin of (0,0) and width and height
918    /// that match the framebuffer's size. Assuming a default projection and
919    /// modelview matrix then you could translate the contents of a window
920    /// down and right by leaving the viewport size unchanged by moving the
921    /// offset to (10,10). The viewport coordinates are measured in pixels.
922    /// If you left the x and y origin as (0,0) you could scale the windows
923    /// contents down by specify and width and height that's half the real
924    /// size of the framebuffer.
925    ///
926    /// `<note>`Although the function takes floating point arguments, existing
927    /// drivers only allow the use of integer values. In the future floating
928    /// point values will be exposed via a checkable feature.`</note>`
929    /// ## `x`
930    /// The top-left x coordinate of the viewport origin (only integers
931    ///  supported currently)
932    /// ## `y`
933    /// The top-left y coordinate of the viewport origin (only integers
934    ///  supported currently)
935    /// ## `width`
936    /// The width of the viewport (only integers supported currently)
937    /// ## `height`
938    /// The height of the viewport (only integers supported currently)
939    fn set_viewport(&self, x: f32, y: f32, width: f32, height: f32);
940
941    /// Multiplies the current model-view matrix by the given matrix.
942    /// ## `matrix`
943    /// the matrix to multiply with the current model-view
944    fn transform(&self, matrix: &Matrix);
945
946    /// Multiplies the current model-view matrix by one that translates the
947    /// model along all three axes according to the given values.
948    /// ## `x`
949    /// Distance to translate along the x-axis
950    /// ## `y`
951    /// Distance to translate along the y-axis
952    /// ## `z`
953    /// Distance to translate along the z-axis
954    fn translate(&self, x: f32, y: f32, z: f32);
955}
956
957impl<O: IsA<Framebuffer>> FramebufferExt for O {
958    fn add_fence_callback<P: Fn(&Fence) + 'static>(&self, callback: P) -> Option<FenceClosure> {
959        let callback_data: Box_<P> = Box_::new(callback);
960        unsafe extern "C" fn callback_func<P: Fn(&Fence) + 'static>(
961            fence: *mut ffi::CoglFence,
962            user_data: glib_sys::gpointer,
963        ) {
964            let fence = from_glib_borrow(fence);
965            let callback: &P = &*(user_data as *mut _);
966            (*callback)(&fence);
967        }
968        let callback = Some(callback_func::<P> as _);
969        let super_callback0: Box_<P> = callback_data;
970        unsafe {
971            from_glib_none(ffi::cogl_framebuffer_add_fence_callback(
972                self.as_ref().to_glib_none().0,
973                callback,
974                Box_::into_raw(super_callback0) as *mut _,
975            ))
976        }
977    }
978
979    fn allocate(&self) -> Result<bool, glib::Error> {
980        unsafe {
981            let mut error = ptr::null_mut();
982            let ret = ffi::cogl_framebuffer_allocate(self.as_ref().to_glib_none().0, &mut error);
983            if error.is_null() {
984                Ok(ret == crate::TRUE)
985            } else {
986                Err(from_glib_full(error))
987            }
988        }
989    }
990
991    fn cancel_fence_callback(&self, closure: &mut FenceClosure) {
992        unsafe {
993            ffi::cogl_framebuffer_cancel_fence_callback(
994                self.as_ref().to_glib_none().0,
995                closure.to_glib_none_mut().0,
996            );
997        }
998    }
999
1000    fn clear(&self, buffers: libc::c_ulong, color: &Color) {
1001        unsafe {
1002            ffi::cogl_framebuffer_clear(
1003                self.as_ref().to_glib_none().0,
1004                buffers,
1005                color.to_glib_none().0,
1006            );
1007        }
1008    }
1009
1010    fn clear4f(&self, buffers: libc::c_ulong, red: f32, green: f32, blue: f32, alpha: f32) {
1011        unsafe {
1012            ffi::cogl_framebuffer_clear4f(
1013                self.as_ref().to_glib_none().0,
1014                buffers,
1015                red,
1016                green,
1017                blue,
1018                alpha,
1019            );
1020        }
1021    }
1022
1023    fn discard_buffers(&self, buffers: libc::c_ulong) {
1024        unsafe {
1025            ffi::cogl_framebuffer_discard_buffers(self.as_ref().to_glib_none().0, buffers);
1026        }
1027    }
1028
1029    fn draw_multitextured_rectangle(
1030        &self,
1031        pipeline: &Pipeline,
1032        x_1: f32,
1033        y_1: f32,
1034        x_2: f32,
1035        y_2: f32,
1036        tex_coords: &[f32],
1037    ) {
1038        let tex_coords_len = tex_coords.len() as i32;
1039        unsafe {
1040            ffi::cogl_framebuffer_draw_multitextured_rectangle(
1041                self.as_ref().to_glib_none().0,
1042                pipeline.to_glib_none().0,
1043                x_1,
1044                y_1,
1045                x_2,
1046                y_2,
1047                tex_coords.to_glib_none().0,
1048                tex_coords_len,
1049            );
1050        }
1051    }
1052
1053    fn draw_rectangle(&self, pipeline: &Pipeline, x_1: f32, y_1: f32, x_2: f32, y_2: f32) {
1054        unsafe {
1055            ffi::cogl_framebuffer_draw_rectangle(
1056                self.as_ref().to_glib_none().0,
1057                pipeline.to_glib_none().0,
1058                x_1,
1059                y_1,
1060                x_2,
1061                y_2,
1062            );
1063        }
1064    }
1065
1066    //fn draw_rectangles(&self, pipeline: &Pipeline, coordinates: &[f32], n_rectangles: u32) {
1067    //    unsafe { TODO: call cogl_sys:cogl_framebuffer_draw_rectangles() }
1068    //}
1069
1070    fn draw_textured_rectangle(
1071        &self,
1072        pipeline: &Pipeline,
1073        x_1: f32,
1074        y_1: f32,
1075        x_2: f32,
1076        y_2: f32,
1077        s_1: f32,
1078        t_1: f32,
1079        s_2: f32,
1080        t_2: f32,
1081    ) {
1082        unsafe {
1083            ffi::cogl_framebuffer_draw_textured_rectangle(
1084                self.as_ref().to_glib_none().0,
1085                pipeline.to_glib_none().0,
1086                x_1,
1087                y_1,
1088                x_2,
1089                y_2,
1090                s_1,
1091                t_1,
1092                s_2,
1093                t_2,
1094            );
1095        }
1096    }
1097
1098    //fn draw_textured_rectangles(&self, pipeline: &Pipeline, coordinates: &[f32], n_rectangles: u32) {
1099    //    unsafe { TODO: call cogl_sys:cogl_framebuffer_draw_textured_rectangles() }
1100    //}
1101
1102    fn finish(&self) {
1103        unsafe {
1104            ffi::cogl_framebuffer_finish(self.as_ref().to_glib_none().0);
1105        }
1106    }
1107
1108    fn frustum(&self, left: f32, right: f32, bottom: f32, top: f32, z_near: f32, z_far: f32) {
1109        unsafe {
1110            ffi::cogl_framebuffer_frustum(
1111                self.as_ref().to_glib_none().0,
1112                left,
1113                right,
1114                bottom,
1115                top,
1116                z_near,
1117                z_far,
1118            );
1119        }
1120    }
1121
1122    fn get_alpha_bits(&self) -> i32 {
1123        unsafe { ffi::cogl_framebuffer_get_alpha_bits(self.as_ref().to_glib_none().0) }
1124    }
1125
1126    fn get_blue_bits(&self) -> i32 {
1127        unsafe { ffi::cogl_framebuffer_get_blue_bits(self.as_ref().to_glib_none().0) }
1128    }
1129
1130    fn get_color_mask(&self) -> ColorMask {
1131        unsafe {
1132            from_glib(ffi::cogl_framebuffer_get_color_mask(
1133                self.as_ref().to_glib_none().0,
1134            ))
1135        }
1136    }
1137
1138    fn get_context(&self) -> Option<Context> {
1139        unsafe {
1140            from_glib_none(ffi::cogl_framebuffer_get_context(
1141                self.as_ref().to_glib_none().0,
1142            ))
1143        }
1144    }
1145
1146    fn get_depth_bits(&self) -> i32 {
1147        unsafe { ffi::cogl_framebuffer_get_depth_bits(self.as_ref().to_glib_none().0) }
1148    }
1149
1150    fn get_depth_texture(&self) -> Option<Texture> {
1151        unsafe {
1152            from_glib_none(ffi::cogl_framebuffer_get_depth_texture(
1153                self.as_ref().to_glib_none().0,
1154            ))
1155        }
1156    }
1157
1158    fn get_depth_texture_enabled(&self) -> bool {
1159        unsafe {
1160            ffi::cogl_framebuffer_get_depth_texture_enabled(self.as_ref().to_glib_none().0)
1161                == crate::TRUE
1162        }
1163    }
1164
1165    fn get_depth_write_enabled(&self) -> bool {
1166        unsafe {
1167            ffi::cogl_framebuffer_get_depth_write_enabled(self.as_ref().to_glib_none().0)
1168                == crate::TRUE
1169        }
1170    }
1171
1172    fn get_dither_enabled(&self) -> bool {
1173        unsafe {
1174            ffi::cogl_framebuffer_get_dither_enabled(self.as_ref().to_glib_none().0) == crate::TRUE
1175        }
1176    }
1177
1178    fn get_green_bits(&self) -> i32 {
1179        unsafe { ffi::cogl_framebuffer_get_green_bits(self.as_ref().to_glib_none().0) }
1180    }
1181
1182    fn get_height(&self) -> i32 {
1183        unsafe { ffi::cogl_framebuffer_get_height(self.as_ref().to_glib_none().0) }
1184    }
1185
1186    fn get_is_stereo(&self) -> bool {
1187        unsafe {
1188            ffi::cogl_framebuffer_get_is_stereo(self.as_ref().to_glib_none().0) == crate::TRUE
1189        }
1190    }
1191
1192    fn get_modelview_matrix(&self) -> Matrix {
1193        unsafe {
1194            let mut matrix = Matrix::uninitialized();
1195            ffi::cogl_framebuffer_get_modelview_matrix(
1196                self.as_ref().to_glib_none().0,
1197                matrix.to_glib_none_mut().0,
1198            );
1199            matrix
1200        }
1201    }
1202
1203    fn get_projection_matrix(&self) -> Matrix {
1204        unsafe {
1205            let mut matrix = Matrix::uninitialized();
1206            ffi::cogl_framebuffer_get_projection_matrix(
1207                self.as_ref().to_glib_none().0,
1208                matrix.to_glib_none_mut().0,
1209            );
1210            matrix
1211        }
1212    }
1213
1214    fn get_red_bits(&self) -> i32 {
1215        unsafe { ffi::cogl_framebuffer_get_red_bits(self.as_ref().to_glib_none().0) }
1216    }
1217
1218    fn get_samples_per_pixel(&self) -> i32 {
1219        unsafe { ffi::cogl_framebuffer_get_samples_per_pixel(self.as_ref().to_glib_none().0) }
1220    }
1221
1222    fn get_stereo_mode(&self) -> StereoMode {
1223        unsafe {
1224            from_glib(ffi::cogl_framebuffer_get_stereo_mode(
1225                self.as_ref().to_glib_none().0,
1226            ))
1227        }
1228    }
1229
1230    //fn get_viewport4fv(&self, viewport: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 20 }; 4) {
1231    //    unsafe { TODO: call cogl_sys:cogl_framebuffer_get_viewport4fv() }
1232    //}
1233
1234    fn get_viewport_height(&self) -> f32 {
1235        unsafe { ffi::cogl_framebuffer_get_viewport_height(self.as_ref().to_glib_none().0) }
1236    }
1237
1238    fn get_viewport_width(&self) -> f32 {
1239        unsafe { ffi::cogl_framebuffer_get_viewport_width(self.as_ref().to_glib_none().0) }
1240    }
1241
1242    fn get_viewport_x(&self) -> f32 {
1243        unsafe { ffi::cogl_framebuffer_get_viewport_x(self.as_ref().to_glib_none().0) }
1244    }
1245
1246    fn get_viewport_y(&self) -> f32 {
1247        unsafe { ffi::cogl_framebuffer_get_viewport_y(self.as_ref().to_glib_none().0) }
1248    }
1249
1250    fn get_width(&self) -> i32 {
1251        unsafe { ffi::cogl_framebuffer_get_width(self.as_ref().to_glib_none().0) }
1252    }
1253
1254    fn identity_matrix(&self) {
1255        unsafe {
1256            ffi::cogl_framebuffer_identity_matrix(self.as_ref().to_glib_none().0);
1257        }
1258    }
1259
1260    fn orthographic(&self, x_1: f32, y_1: f32, x_2: f32, y_2: f32, near: f32, far: f32) {
1261        unsafe {
1262            ffi::cogl_framebuffer_orthographic(
1263                self.as_ref().to_glib_none().0,
1264                x_1,
1265                y_1,
1266                x_2,
1267                y_2,
1268                near,
1269                far,
1270            );
1271        }
1272    }
1273
1274    fn perspective(&self, fov_y: f32, aspect: f32, z_near: f32, z_far: f32) {
1275        unsafe {
1276            ffi::cogl_framebuffer_perspective(
1277                self.as_ref().to_glib_none().0,
1278                fov_y,
1279                aspect,
1280                z_near,
1281                z_far,
1282            );
1283        }
1284    }
1285
1286    fn pop_clip(&self) {
1287        unsafe {
1288            ffi::cogl_framebuffer_pop_clip(self.as_ref().to_glib_none().0);
1289        }
1290    }
1291
1292    fn pop_matrix(&self) {
1293        unsafe {
1294            ffi::cogl_framebuffer_pop_matrix(self.as_ref().to_glib_none().0);
1295        }
1296    }
1297
1298    fn push_matrix(&self) {
1299        unsafe {
1300            ffi::cogl_framebuffer_push_matrix(self.as_ref().to_glib_none().0);
1301        }
1302    }
1303
1304    fn push_primitive_clip(
1305        &self,
1306        primitive: &Primitive,
1307        bounds_x1: f32,
1308        bounds_y1: f32,
1309        bounds_x2: f32,
1310        bounds_y2: f32,
1311    ) {
1312        unsafe {
1313            ffi::cogl_framebuffer_push_primitive_clip(
1314                self.as_ref().to_glib_none().0,
1315                primitive.to_glib_none().0,
1316                bounds_x1,
1317                bounds_y1,
1318                bounds_x2,
1319                bounds_y2,
1320            );
1321        }
1322    }
1323
1324    fn push_rectangle_clip(&self, x_1: f32, y_1: f32, x_2: f32, y_2: f32) {
1325        unsafe {
1326            ffi::cogl_framebuffer_push_rectangle_clip(
1327                self.as_ref().to_glib_none().0,
1328                x_1,
1329                y_1,
1330                x_2,
1331                y_2,
1332            );
1333        }
1334    }
1335
1336    fn push_scissor_clip(&self, x: i32, y: i32, width: i32, height: i32) {
1337        unsafe {
1338            ffi::cogl_framebuffer_push_scissor_clip(
1339                self.as_ref().to_glib_none().0,
1340                x,
1341                y,
1342                width,
1343                height,
1344            );
1345        }
1346    }
1347
1348    fn read_pixels(
1349        &self,
1350        x: i32,
1351        y: i32,
1352        width: i32,
1353        height: i32,
1354        format: PixelFormat,
1355        pixels: &[u8],
1356    ) -> bool {
1357        unsafe {
1358            ffi::cogl_framebuffer_read_pixels(
1359                self.as_ref().to_glib_none().0,
1360                x,
1361                y,
1362                width,
1363                height,
1364                format.to_glib(),
1365                pixels.to_glib_none().0,
1366            ) == crate::TRUE
1367        }
1368    }
1369
1370    fn read_pixels_into_bitmap(
1371        &self,
1372        x: i32,
1373        y: i32,
1374        source: ReadPixelsFlags,
1375        bitmap: &Bitmap,
1376    ) -> bool {
1377        unsafe {
1378            ffi::cogl_framebuffer_read_pixels_into_bitmap(
1379                self.as_ref().to_glib_none().0,
1380                x,
1381                y,
1382                source.to_glib(),
1383                bitmap.to_glib_none().0,
1384            ) == crate::TRUE
1385        }
1386    }
1387
1388    fn resolve_samples(&self) {
1389        unsafe {
1390            ffi::cogl_framebuffer_resolve_samples(self.as_ref().to_glib_none().0);
1391        }
1392    }
1393
1394    fn resolve_samples_region(&self, x: i32, y: i32, width: i32, height: i32) {
1395        unsafe {
1396            ffi::cogl_framebuffer_resolve_samples_region(
1397                self.as_ref().to_glib_none().0,
1398                x,
1399                y,
1400                width,
1401                height,
1402            );
1403        }
1404    }
1405
1406    fn rotate(&self, angle: f32, x: f32, y: f32, z: f32) {
1407        unsafe {
1408            ffi::cogl_framebuffer_rotate(self.as_ref().to_glib_none().0, angle, x, y, z);
1409        }
1410    }
1411
1412    fn rotate_euler(&self, euler: &Euler) {
1413        unsafe {
1414            ffi::cogl_framebuffer_rotate_euler(
1415                self.as_ref().to_glib_none().0,
1416                euler.to_glib_none().0,
1417            );
1418        }
1419    }
1420
1421    fn rotate_quaternion(&self, quaternion: &Quaternion) {
1422        unsafe {
1423            ffi::cogl_framebuffer_rotate_quaternion(
1424                self.as_ref().to_glib_none().0,
1425                quaternion.to_glib_none().0,
1426            );
1427        }
1428    }
1429
1430    fn scale(&self, x: f32, y: f32, z: f32) {
1431        unsafe {
1432            ffi::cogl_framebuffer_scale(self.as_ref().to_glib_none().0, x, y, z);
1433        }
1434    }
1435
1436    fn set_color_mask(&self, color_mask: ColorMask) {
1437        unsafe {
1438            ffi::cogl_framebuffer_set_color_mask(
1439                self.as_ref().to_glib_none().0,
1440                color_mask.to_glib(),
1441            );
1442        }
1443    }
1444
1445    fn set_depth_texture_enabled(&self, enabled: bool) {
1446        unsafe {
1447            ffi::cogl_framebuffer_set_depth_texture_enabled(
1448                self.as_ref().to_glib_none().0,
1449                enabled as i32,
1450            );
1451        }
1452    }
1453
1454    fn set_depth_write_enabled(&self, depth_write_enabled: bool) {
1455        unsafe {
1456            ffi::cogl_framebuffer_set_depth_write_enabled(
1457                self.as_ref().to_glib_none().0,
1458                depth_write_enabled as i32,
1459            );
1460        }
1461    }
1462
1463    fn set_dither_enabled(&self, dither_enabled: bool) {
1464        unsafe {
1465            ffi::cogl_framebuffer_set_dither_enabled(
1466                self.as_ref().to_glib_none().0,
1467                dither_enabled as i32,
1468            );
1469        }
1470    }
1471
1472    fn set_modelview_matrix(&self, matrix: &Matrix) {
1473        unsafe {
1474            ffi::cogl_framebuffer_set_modelview_matrix(
1475                self.as_ref().to_glib_none().0,
1476                matrix.to_glib_none().0,
1477            );
1478        }
1479    }
1480
1481    fn set_projection_matrix(&self, matrix: &Matrix) {
1482        unsafe {
1483            ffi::cogl_framebuffer_set_projection_matrix(
1484                self.as_ref().to_glib_none().0,
1485                matrix.to_glib_none().0,
1486            );
1487        }
1488    }
1489
1490    fn set_samples_per_pixel(&self, samples_per_pixel: i32) {
1491        unsafe {
1492            ffi::cogl_framebuffer_set_samples_per_pixel(
1493                self.as_ref().to_glib_none().0,
1494                samples_per_pixel,
1495            );
1496        }
1497    }
1498
1499    fn set_stereo_mode(&self, stereo_mode: StereoMode) {
1500        unsafe {
1501            ffi::cogl_framebuffer_set_stereo_mode(
1502                self.as_ref().to_glib_none().0,
1503                stereo_mode.to_glib(),
1504            );
1505        }
1506    }
1507
1508    fn set_viewport(&self, x: f32, y: f32, width: f32, height: f32) {
1509        unsafe {
1510            ffi::cogl_framebuffer_set_viewport(self.as_ref().to_glib_none().0, x, y, width, height);
1511        }
1512    }
1513
1514    fn transform(&self, matrix: &Matrix) {
1515        unsafe {
1516            ffi::cogl_framebuffer_transform(
1517                self.as_ref().to_glib_none().0,
1518                matrix.to_glib_none().0,
1519            );
1520        }
1521    }
1522
1523    fn translate(&self, x: f32, y: f32, z: f32) {
1524        unsafe {
1525            ffi::cogl_framebuffer_translate(self.as_ref().to_glib_none().0, x, y, z);
1526        }
1527    }
1528}
1529
1530impl fmt::Display for Framebuffer {
1531    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1532        write!(f, "Framebuffer")
1533    }
1534}