cogl/auto/
pipeline.rs

1use crate::{
2    Color, ColorMask, Context, DepthState, Matrix, Object, PipelineAlphaFunc, PipelineCullFaceMode,
3    PipelineFilter, PipelineWrapMode, Snippet, Texture, TextureType, Winding,
4};
5
6use glib::object::IsA;
7use glib::translate::*;
8use std::{fmt, ptr};
9
10glib_wrapper! {
11    pub struct Pipeline(Object<ffi::CoglPipeline, PipelineClass>) @extends Object;
12
13    match fn {
14        get_type => || ffi::cogl_pipeline_get_gtype(),
15    }
16}
17
18impl Pipeline {
19    /// Allocates and initializes a default simple pipeline that will color
20    /// a primitive white.
21    ///
22    /// ## `context`
23    /// a `Context`
24    ///
25    /// # Returns
26    ///
27    /// a pointer to a new `Pipeline`
28    pub fn new(context: &Context) -> Pipeline {
29        unsafe { from_glib_full(ffi::cogl_pipeline_new(context.to_glib_none().0)) }
30    }
31
32    /// Adds a shader snippet that will hook on to the given layer of the
33    /// pipeline. The exact part of the pipeline that the snippet wraps
34    /// around depends on the hook that is given to
35    /// `Snippet::new`. Note that some hooks can't be used with a layer
36    /// and need to be added with `Pipeline::add_snippet` instead.
37    /// ## `layer`
38    /// The layer to hook the snippet to
39    /// ## `snippet`
40    /// A `Snippet`
41    pub fn add_layer_snippet(&self, layer: i32, snippet: &Snippet) {
42        unsafe {
43            ffi::cogl_pipeline_add_layer_snippet(
44                self.to_glib_none().0,
45                layer,
46                snippet.to_glib_none().0,
47            );
48        }
49    }
50
51    /// Adds a shader snippet to `self`. The snippet will wrap around or
52    /// replace some part of the pipeline as defined by the hook point in
53    /// `snippet`. Note that some hook points are specific to a layer and
54    /// must be added with `Pipeline::add_layer_snippet` instead.
55    /// ## `snippet`
56    /// The `Snippet` to add to the vertex processing hook
57    pub fn add_snippet(&self, snippet: &Snippet) {
58        unsafe {
59            ffi::cogl_pipeline_add_snippet(self.to_glib_none().0, snippet.to_glib_none().0);
60        }
61    }
62
63    /// Creates a new pipeline with the configuration copied from the
64    /// source pipeline.
65    ///
66    /// We would strongly advise developers to always aim to use
67    /// `Pipeline::copy` instead of `Pipeline::new` whenever there will
68    /// be any similarity between two pipelines. Copying a pipeline helps Cogl
69    /// keep track of a pipelines ancestry which we may use to help minimize GPU
70    /// state changes.
71    ///
72    ///
73    /// # Returns
74    ///
75    /// a pointer to the newly allocated `Pipeline`
76    pub fn copy(&self) -> Option<Pipeline> {
77        unsafe { from_glib_full(ffi::cogl_pipeline_copy(self.to_glib_none().0)) }
78    }
79
80    /// Iterates all the layer indices of the given `self`.
81    ///
82    /// ## `callback`
83    /// A `CoglPipelineLayerCallback` to be
84    ///  called for each layer index
85    /// ## `user_data`
86    /// Private data that will be passed to the
87    ///  callback
88    pub fn foreach_layer<P: FnMut(&Pipeline, i32) -> i32>(&self, callback: P) {
89        //TODO: should replace i32 to bool in callback
90        let callback_data: P = callback;
91        unsafe extern "C" fn callback_func<P: FnMut(&Pipeline, i32) -> i32>(
92            pipeline: *mut ffi::CoglPipeline,
93            layer_index: libc::c_int,
94            user_data: glib_sys::gpointer,
95        ) -> ffi::CoglBool {
96            let pipeline = from_glib_borrow(pipeline);
97            let callback: *mut P = user_data as *const _ as usize as *mut P;
98            (*callback)(&pipeline, layer_index)
99        }
100        let callback = Some(callback_func::<P> as _);
101        let super_callback0: &P = &callback_data;
102        unsafe {
103            ffi::cogl_pipeline_foreach_layer(
104                self.to_glib_none().0,
105                callback,
106                super_callback0 as *const _ as usize as *mut _,
107            );
108        }
109    }
110
111    ///
112    ///
113    /// # Returns
114    ///
115    /// The alpha test function of `self`.
116    pub fn get_alpha_test_function(&self) -> PipelineAlphaFunc {
117        unsafe {
118            from_glib(ffi::cogl_pipeline_get_alpha_test_function(
119                self.to_glib_none().0,
120            ))
121        }
122    }
123
124    ///
125    ///
126    /// # Returns
127    ///
128    /// The alpha test reference value of `self`.
129    pub fn get_alpha_test_reference(&self) -> f32 {
130        unsafe { ffi::cogl_pipeline_get_alpha_test_reference(self.to_glib_none().0) }
131    }
132
133    /// Retrieves the current ambient color for `self`
134    ///
135    /// ## `ambient`
136    /// The location to store the ambient color
137    pub fn get_ambient(&self, ambient: &mut Color) {
138        unsafe {
139            ffi::cogl_pipeline_get_ambient(self.to_glib_none().0, ambient.to_glib_none_mut().0);
140        }
141    }
142
143    /// Retrieves the current pipeline color.
144    ///
145    /// ## `color`
146    /// The location to store the color
147    pub fn get_color(&self) -> Color {
148        unsafe {
149            let mut color = Color::uninitialized();
150            ffi::cogl_pipeline_get_color(self.to_glib_none().0, color.to_glib_none_mut().0);
151            color
152        }
153    }
154
155    /// Gets the current `ColorMask` of which channels would be written to the
156    /// current framebuffer. Each bit set in the mask means that the
157    /// corresponding color would be written.
158    ///
159    /// # Returns
160    ///
161    /// A `ColorMask`
162    pub fn get_color_mask(&self) -> ColorMask {
163        unsafe { from_glib(ffi::cogl_pipeline_get_color_mask(self.to_glib_none().0)) }
164    }
165
166    ///
167    ///
168    /// # Returns
169    ///
170    /// the cull face mode that was previously set with
171    /// `Pipeline::set_cull_face_mode`.
172    ///
173    /// Status: Unstable
174    pub fn get_cull_face_mode(&self) -> PipelineCullFaceMode {
175        unsafe { from_glib(ffi::cogl_pipeline_get_cull_face_mode(self.to_glib_none().0)) }
176    }
177
178    /// Retrieves the current depth state configuration for the given
179    /// `self` as previously set using `Pipeline::set_depth_state`.
180    ///
181    /// ## `state_out`
182    /// A destination `DepthState` struct
183    pub fn get_depth_state(&self) -> DepthState {
184        unsafe {
185            let mut state_out = DepthState::uninitialized();
186            ffi::cogl_pipeline_get_depth_state(
187                self.to_glib_none().0,
188                state_out.to_glib_none_mut().0,
189            );
190            state_out
191        }
192    }
193
194    /// Retrieves the current diffuse color for `self`
195    ///
196    /// ## `diffuse`
197    /// The location to store the diffuse color
198    pub fn get_diffuse(&self, diffuse: &mut Color) {
199        unsafe {
200            ffi::cogl_pipeline_get_diffuse(self.to_glib_none().0, diffuse.to_glib_none_mut().0);
201        }
202    }
203
204    /// Retrieves the pipelines current emission color.
205    ///
206    /// ## `emission`
207    /// The location to store the emission color
208    pub fn get_emission(&self, emission: &mut Color) {
209        unsafe {
210            ffi::cogl_pipeline_get_emission(self.to_glib_none().0, emission.to_glib_none_mut().0);
211        }
212    }
213
214    /// The order of the vertices within a primitive specifies whether it
215    /// is considered to be front or back facing. This function specifies
216    /// which order is considered to be the front
217    /// faces. `Winding::CounterClockwise` sets the front faces to
218    /// primitives with vertices in a counter-clockwise order and
219    /// `Winding::Clockwise` sets them to be clockwise. The default is
220    /// `Winding::CounterClockwise`.
221    ///
222    ///
223    /// # Returns
224    ///
225    /// The `self` front face winding
226    ///
227    /// Status: Unstable
228    pub fn get_front_face_winding(&self) -> Winding {
229        unsafe {
230            from_glib(ffi::cogl_pipeline_get_front_face_winding(
231                self.to_glib_none().0,
232            ))
233        }
234    }
235
236    /// Retrieves the currently set magnification `PipelineFilter` set on
237    /// the specified layer. The magnification filter determines how the
238    /// layer should be sampled when up-scaled.
239    ///
240    /// The default filter is `PipelineFilter::Linear` but this can be
241    /// changed using `Pipeline::set_layer_filters`.
242    /// ## `layer_index`
243    /// the layer number to change.
244    ///
245    /// # Returns
246    ///
247    /// The magnification `PipelineFilter` for the
248    ///  specified layer.
249    pub fn get_layer_mag_filter(&self, layer_index: i32) -> PipelineFilter {
250        unsafe {
251            from_glib(ffi::cogl_pipeline_get_layer_mag_filter(
252                self.to_glib_none().0,
253                layer_index,
254            ))
255        }
256    }
257
258    /// Retrieves the currently set minification `PipelineFilter` set on
259    /// the specified layer. The miniifcation filter determines how the
260    /// layer should be sampled when down-scaled.
261    ///
262    /// The default filter is `PipelineFilter::Linear` but this can be
263    /// changed using `Pipeline::set_layer_filters`.
264    /// ## `layer_index`
265    /// the layer number to change.
266    ///
267    /// # Returns
268    ///
269    /// The minification `PipelineFilter` for the
270    ///  specified layer.
271    pub fn get_layer_min_filter(&self, layer_index: i32) -> PipelineFilter {
272        unsafe {
273            from_glib(ffi::cogl_pipeline_get_layer_min_filter(
274                self.to_glib_none().0,
275                layer_index,
276            ))
277        }
278    }
279
280    /// Gets whether point sprite coordinate generation is enabled for this
281    /// texture layer.
282    ///
283    /// ## `layer_index`
284    /// the layer number to check.
285    ///
286    /// # Returns
287    ///
288    /// whether the texture coordinates will be replaced with
289    /// point sprite coordinates.
290    pub fn get_layer_point_sprite_coords_enabled(&self, layer_index: i32) -> bool {
291        unsafe {
292            ffi::cogl_pipeline_get_layer_point_sprite_coords_enabled(
293                self.to_glib_none().0,
294                layer_index,
295            ) == crate::TRUE
296        }
297    }
298
299    /// ## `layer_index`
300    /// the index of the layer
301    ///
302    /// # Returns
303    ///
304    /// the texture that was set for the
305    ///  given layer of the pipeline or `None` if no texture was set.
306    pub fn get_layer_texture(&self, layer_index: i32) -> Option<Texture> {
307        unsafe {
308            from_glib_none(ffi::cogl_pipeline_get_layer_texture(
309                self.to_glib_none().0,
310                layer_index,
311            ))
312        }
313    }
314
315    /// Returns the wrap mode for the 'p' coordinate of texture lookups on this
316    /// layer.
317    ///
318    /// ## `layer_index`
319    /// the layer number to change.
320    ///
321    /// # Returns
322    ///
323    /// the wrap mode for the 'p' coordinate of texture lookups on
324    /// this layer.
325    pub fn get_layer_wrap_mode_p(&self, layer_index: i32) -> PipelineWrapMode {
326        unsafe {
327            from_glib(ffi::cogl_pipeline_get_layer_wrap_mode_p(
328                self.to_glib_none().0,
329                layer_index,
330            ))
331        }
332    }
333
334    /// Returns the wrap mode for the 's' coordinate of texture lookups on this
335    /// layer.
336    ///
337    /// ## `layer_index`
338    /// the layer number to change.
339    ///
340    /// # Returns
341    ///
342    /// the wrap mode for the 's' coordinate of texture lookups on
343    /// this layer.
344    pub fn get_layer_wrap_mode_s(&self, layer_index: i32) -> PipelineWrapMode {
345        unsafe {
346            from_glib(ffi::cogl_pipeline_get_layer_wrap_mode_s(
347                self.to_glib_none().0,
348                layer_index,
349            ))
350        }
351    }
352
353    /// Returns the wrap mode for the 't' coordinate of texture lookups on this
354    /// layer.
355    ///
356    /// ## `layer_index`
357    /// the layer number to change.
358    ///
359    /// # Returns
360    ///
361    /// the wrap mode for the 't' coordinate of texture lookups on
362    /// this layer.
363    pub fn get_layer_wrap_mode_t(&self, layer_index: i32) -> PipelineWrapMode {
364        unsafe {
365            from_glib(ffi::cogl_pipeline_get_layer_wrap_mode_t(
366                self.to_glib_none().0,
367                layer_index,
368            ))
369        }
370    }
371
372    /// Retrieves the number of layers defined for the given `self`
373    ///
374    ///
375    /// # Returns
376    ///
377    /// the number of layers
378    pub fn get_n_layers(&self) -> i32 {
379        unsafe { ffi::cogl_pipeline_get_n_layers(self.to_glib_none().0) }
380    }
381
382    ///
383    ///
384    /// # Returns
385    ///
386    /// `true` if the pipeline has per-vertex point size
387    ///  enabled or `false` otherwise. The per-vertex point size can be
388    ///  enabled with `Pipeline::set_per_vertex_point_size`.
389    pub fn get_per_vertex_point_size(&self) -> bool {
390        unsafe {
391            ffi::cogl_pipeline_get_per_vertex_point_size(self.to_glib_none().0) == crate::TRUE
392        }
393    }
394
395    /// Get the size of points drawn when `VerticesMode::Points` is
396    /// used with the vertex buffer API.
397    ///
398    ///
399    /// # Returns
400    ///
401    /// the point size of the `self`.
402    pub fn get_point_size(&self) -> f32 {
403        unsafe { ffi::cogl_pipeline_get_point_size(self.to_glib_none().0) }
404    }
405
406    /// Retrieves the pipelines current emission color.
407    ///
408    ///
409    /// # Returns
410    ///
411    /// The pipelines current shininess value
412    pub fn get_shininess(&self) -> f32 {
413        unsafe { ffi::cogl_pipeline_get_shininess(self.to_glib_none().0) }
414    }
415
416    /// Retrieves the pipelines current specular color.
417    ///
418    /// ## `specular`
419    /// The location to store the specular color
420    pub fn get_specular(&self, specular: &mut Color) {
421        unsafe {
422            ffi::cogl_pipeline_get_specular(self.to_glib_none().0, specular.to_glib_none_mut().0);
423        }
424    }
425
426    /// This is used to get an integer representing the uniform with the
427    /// name `uniform_name`. The integer can be passed to functions such as
428    /// `Pipeline::set_uniform_1f` to set the value of a uniform.
429    ///
430    /// This function will always return a valid integer. Ie, unlike
431    /// OpenGL, it does not return -1 if the uniform is not available in
432    /// this pipeline so it can not be used to test whether uniforms are
433    /// present. It is not necessary to set the program on the pipeline
434    /// before calling this function.
435    ///
436    /// ## `uniform_name`
437    /// The name of a uniform
438    ///
439    /// # Returns
440    ///
441    /// A integer representing the location of the given uniform.
442    pub fn get_uniform_location(&self, uniform_name: &str) -> i32 {
443        unsafe {
444            ffi::cogl_pipeline_get_uniform_location(
445                self.to_glib_none().0,
446                uniform_name.to_glib_none().0,
447            )
448        }
449    }
450
451    //pub fn get_user_program(&self) -> /*Unimplemented*/Option<Handle> {
452    //    unsafe { TODO: call cogl_sys:cogl_pipeline_get_user_program() }
453    //}
454
455    /// This function removes a layer from your pipeline
456    /// ## `layer_index`
457    /// Specifies the layer you want to remove
458    pub fn remove_layer(&self, layer_index: i32) {
459        unsafe {
460            ffi::cogl_pipeline_remove_layer(self.to_glib_none().0, layer_index);
461        }
462    }
463
464    /// Before a primitive is blended with the framebuffer, it goes through an
465    /// alpha test stage which lets you discard fragments based on the current
466    /// alpha value. This function lets you change the function used to evaluate
467    /// the alpha channel, and thus determine which fragments are discarded
468    /// and which continue on to the blending stage.
469    ///
470    /// The default is `PipelineAlphaFunc::Always`
471    ///
472    /// ## `alpha_func`
473    /// A `PipelineAlphaFunc` constant
474    /// ## `alpha_reference`
475    /// A reference point that the chosen alpha function uses
476    ///  to compare incoming fragments to.
477    pub fn set_alpha_test_function(&self, alpha_func: PipelineAlphaFunc, alpha_reference: f32) {
478        unsafe {
479            ffi::cogl_pipeline_set_alpha_test_function(
480                self.to_glib_none().0,
481                alpha_func.to_glib(),
482                alpha_reference,
483            );
484        }
485    }
486
487    /// Sets the pipeline's ambient color, in the standard OpenGL lighting
488    /// model. The ambient color affects the overall color of the object.
489    ///
490    /// Since the diffuse color will be intense when the light hits the surface
491    /// directly, the ambient will be most apparent where the light hits at a
492    /// slant.
493    ///
494    /// The default value is (0.2, 0.2, 0.2, 1.0)
495    ///
496    /// ## `ambient`
497    /// The components of the desired ambient color
498    pub fn set_ambient(&self, ambient: &Color) {
499        unsafe {
500            ffi::cogl_pipeline_set_ambient(self.to_glib_none().0, ambient.to_glib_none().0);
501        }
502    }
503
504    /// Conveniently sets the diffuse and ambient color of `self` at the same
505    /// time. See `Pipeline::set_ambient` and `Pipeline::set_diffuse`.
506    ///
507    /// The default ambient color is (0.2, 0.2, 0.2, 1.0)
508    ///
509    /// The default diffuse color is (0.8, 0.8, 0.8, 1.0)
510    ///
511    /// ## `color`
512    /// The components of the desired ambient and diffuse colors
513    pub fn set_ambient_and_diffuse(&self, color: &Color) {
514        unsafe {
515            ffi::cogl_pipeline_set_ambient_and_diffuse(
516                self.to_glib_none().0,
517                color.to_glib_none().0,
518            );
519        }
520    }
521
522    /// If not already familiar; please refer <link linkend="cogl-Blend-Strings">here`</link>`
523    /// for an overview of what blend strings are, and their syntax.
524    ///
525    /// Blending occurs after the alpha test function, and combines fragments with
526    /// the framebuffer.
527    ///
528    /// Currently the only blend function Cogl exposes is ADD(). So any valid
529    /// blend statements will be of the form:
530    ///
531    ///
532    /// ```text
533    ///   &lt;channel-mask&gt;=ADD(SRC_COLOR*(&lt;factor&gt;), DST_COLOR*(&lt;factor&gt;))
534    /// ```
535    ///
536    /// This is the list of source-names usable as blend factors:
537    /// `<itemizedlist>`
538    ///  `<listitem>``<para>`SRC_COLOR: The color of the in comming fragment`</para>``</listitem>`
539    ///  `<listitem>``<para>`DST_COLOR: The color of the framebuffer`</para>``</listitem>`
540    ///  `<listitem>``<para>`CONSTANT: The constant set via `Pipeline::set_blend_constant``</para>``</listitem>`
541    /// `</itemizedlist>`
542    ///
543    /// The source names can be used according to the
544    /// <link linkend="cogl-Blend-String-syntax">color-source and factor syntax`</link>`,
545    /// so for example "(1-SRC_COLOR[A])" would be a valid factor, as would
546    /// "(CONSTANT[RGB])"
547    ///
548    /// These can also be used as factors:
549    /// `<itemizedlist>`
550    ///  `<listitem>`0: (0, 0, 0, 0)`</listitem>`
551    ///  `<listitem>`1: (1, 1, 1, 1)`</listitem>`
552    ///  `<listitem>`SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A])`</listitem>`
553    /// `</itemizedlist>`
554    ///
555    /// `<note>`Remember; all color components are normalized to the range [0, 1]
556    /// before computing the result of blending.`</note>`
557    ///
558    /// <example id="cogl-Blend-Strings-blend-unpremul">
559    ///  `<title>`Blend Strings/1`</title>`
560    ///  `<para>`Blend a non-premultiplied source over a destination with
561    ///  premultiplied alpha:`</para>`
562    ///  `<programlisting>`
563    /// "RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))"
564    /// "A = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
565    ///  `</programlisting>`
566    /// `</example>`
567    ///
568    /// <example id="cogl-Blend-Strings-blend-premul">
569    ///  `<title>`Blend Strings/2`</title>`
570    ///  `<para>`Blend a premultiplied source over a destination with
571    ///  premultiplied alpha`</para>`
572    ///  `<programlisting>`
573    /// "RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
574    ///  `</programlisting>`
575    /// `</example>`
576    ///
577    /// The default blend string is:
578    ///
579    /// ```text
580    ///    RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))
581    /// ```
582    ///
583    /// That gives normal alpha-blending when the calculated color for the pipeline
584    /// is in premultiplied form.
585    ///
586    /// ## `blend_string`
587    /// A <link linkend="cogl-Blend-Strings">Cogl blend string`</link>`
588    ///  describing the desired blend function.
589    ///
590    /// # Returns
591    ///
592    /// `true` if the blend string was successfully parsed, and the
593    ///  described blending is supported by the underlying driver/hardware. If
594    ///  there was an error, `false` is returned and `error` is set accordingly (if
595    ///  present).
596    pub fn set_blend(&self, blend_string: &str) -> Result<bool, glib::Error> {
597        unsafe {
598            let mut error = ptr::null_mut();
599            let ret = ffi::cogl_pipeline_set_blend(
600                self.to_glib_none().0,
601                blend_string.to_glib_none().0,
602                &mut error,
603            );
604            if error.is_null() {
605                Ok(ret == crate::TRUE)
606            } else {
607                Err(from_glib_full(error))
608            }
609        }
610    }
611
612    /// When blending is setup to reference a CONSTANT blend factor then
613    /// blending will depend on the constant set with this function.
614    ///
615    /// ## `constant_color`
616    /// The constant color you want
617    pub fn set_blend_constant(&self, constant_color: &Color) {
618        unsafe {
619            ffi::cogl_pipeline_set_blend_constant(
620                self.to_glib_none().0,
621                constant_color.to_glib_none().0,
622            );
623        }
624    }
625
626    /// Sets the basic color of the pipeline, used when no lighting is enabled.
627    ///
628    /// Note that if you don't add any layers to the pipeline then the color
629    /// will be blended unmodified with the destination; the default blend
630    /// expects premultiplied colors: for example, use (0.5, 0.0, 0.0, 0.5) for
631    /// semi-transparent red. See `Color::premultiply`.
632    ///
633    /// The default value is (1.0, 1.0, 1.0, 1.0)
634    ///
635    /// ## `color`
636    /// The components of the color
637    pub fn set_color(&self, color: &Color) {
638        unsafe {
639            ffi::cogl_pipeline_set_color(self.to_glib_none().0, color.to_glib_none().0);
640        }
641    }
642
643    /// Sets the basic color of the pipeline, used when no lighting is enabled.
644    ///
645    /// The default value is (1.0, 1.0, 1.0, 1.0)
646    ///
647    /// ## `red`
648    /// The red component
649    /// ## `green`
650    /// The green component
651    /// ## `blue`
652    /// The blue component
653    /// ## `alpha`
654    /// The alpha component
655    pub fn set_color4f(&self, red: f32, green: f32, blue: f32, alpha: f32) {
656        unsafe {
657            ffi::cogl_pipeline_set_color4f(self.to_glib_none().0, red, green, blue, alpha);
658        }
659    }
660
661    /// Sets the basic color of the pipeline, used when no lighting is enabled.
662    ///
663    /// The default value is (0xff, 0xff, 0xff, 0xff)
664    ///
665    /// ## `red`
666    /// The red component
667    /// ## `green`
668    /// The green component
669    /// ## `blue`
670    /// The blue component
671    /// ## `alpha`
672    /// The alpha component
673    pub fn set_color4ub(&self, red: u8, green: u8, blue: u8, alpha: u8) {
674        unsafe {
675            ffi::cogl_pipeline_set_color4ub(self.to_glib_none().0, red, green, blue, alpha);
676        }
677    }
678
679    /// Defines a bit mask of which color channels should be written to the
680    /// current framebuffer. If a bit is set in `color_mask` that means that
681    /// color will be written.
682    /// ## `color_mask`
683    /// A `ColorMask` of which color channels to write to
684    ///  the current framebuffer.
685    pub fn set_color_mask(&self, color_mask: ColorMask) {
686        unsafe {
687            ffi::cogl_pipeline_set_color_mask(self.to_glib_none().0, color_mask.to_glib());
688        }
689    }
690
691    /// Sets which faces will be culled when drawing. Face culling can be
692    /// used to increase efficiency by avoiding drawing faces that would
693    /// get overridden. For example, if a model has gaps so that it is
694    /// impossible to see the inside then faces which are facing away from
695    /// the screen will never be seen so there is no point in drawing
696    /// them. This can be acheived by setting the cull face mode to
697    /// `PipelineCullFaceMode::Back`.
698    ///
699    /// Face culling relies on the primitives being drawn with a specific
700    /// order to represent which faces are facing inside and outside the
701    /// model. This order can be specified by calling
702    /// `Pipeline::set_front_face_winding`.
703    ///
704    /// Status: Unstable
705    ///
706    /// ## `cull_face_mode`
707    /// The new mode to set
708    pub fn set_cull_face_mode(&self, cull_face_mode: PipelineCullFaceMode) {
709        unsafe {
710            ffi::cogl_pipeline_set_cull_face_mode(self.to_glib_none().0, cull_face_mode.to_glib());
711        }
712    }
713
714    /// This commits all the depth state configured in `state` struct to the
715    /// given `self`. The configuration values are copied into the
716    /// pipeline so there is no requirement to keep the `DepthState`
717    /// struct around if you don't need it any more.
718    ///
719    /// Note: Since some platforms do not support the depth range feature
720    /// it is possible for this function to fail and report an `error`.
721    ///
722    /// ## `state`
723    /// A `DepthState` struct
724    ///
725    /// # Returns
726    ///
727    /// TRUE if the GPU supports all the given `state` else `false`
728    ///  and returns an `error`.
729    pub fn set_depth_state(&self, state: &DepthState) -> Result<bool, glib::Error> {
730        unsafe {
731            let mut error = ptr::null_mut();
732            let ret = ffi::cogl_pipeline_set_depth_state(
733                self.to_glib_none().0,
734                state.to_glib_none().0,
735                &mut error,
736            );
737            if error.is_null() {
738                Ok(ret == crate::TRUE)
739            } else {
740                Err(from_glib_full(error))
741            }
742        }
743    }
744
745    /// Sets the pipeline's diffuse color, in the standard OpenGL lighting
746    /// model. The diffuse color is most intense where the light hits the
747    /// surface directly - perpendicular to the surface.
748    ///
749    /// The default value is (0.8, 0.8, 0.8, 1.0)
750    ///
751    /// ## `diffuse`
752    /// The components of the desired diffuse color
753    pub fn set_diffuse(&self, diffuse: &Color) {
754        unsafe {
755            ffi::cogl_pipeline_set_diffuse(self.to_glib_none().0, diffuse.to_glib_none().0);
756        }
757    }
758
759    /// Sets the pipeline's emissive color, in the standard OpenGL lighting
760    /// model. It will look like the surface is a light source emitting this
761    /// color.
762    ///
763    /// The default value is (0.0, 0.0, 0.0, 1.0)
764    ///
765    /// ## `emission`
766    /// The components of the desired emissive color
767    pub fn set_emission(&self, emission: &Color) {
768        unsafe {
769            ffi::cogl_pipeline_set_emission(self.to_glib_none().0, emission.to_glib_none().0);
770        }
771    }
772
773    /// The order of the vertices within a primitive specifies whether it
774    /// is considered to be front or back facing. This function specifies
775    /// which order is considered to be the front
776    /// faces. `Winding::CounterClockwise` sets the front faces to
777    /// primitives with vertices in a counter-clockwise order and
778    /// `Winding::Clockwise` sets them to be clockwise. The default is
779    /// `Winding::CounterClockwise`.
780    ///
781    /// Status: Unstable
782    ///
783    /// ## `front_winding`
784    /// the winding order
785    pub fn set_front_face_winding(&self, front_winding: Winding) {
786        unsafe {
787            ffi::cogl_pipeline_set_front_face_winding(
788                self.to_glib_none().0,
789                front_winding.to_glib(),
790            );
791        }
792    }
793
794    /// If not already familiar; you can refer
795    /// <link linkend="cogl-Blend-Strings">here`</link>` for an overview of what blend
796    /// strings are and there syntax.
797    ///
798    /// These are all the functions available for texture combining:
799    /// `<itemizedlist>`
800    ///  `<listitem>`REPLACE(arg0) = arg0`</listitem>`
801    ///  `<listitem>`MODULATE(arg0, arg1) = arg0 x arg1`</listitem>`
802    ///  `<listitem>`ADD(arg0, arg1) = arg0 + arg1`</listitem>`
803    ///  `<listitem>`ADD_SIGNED(arg0, arg1) = arg0 + arg1 - 0.5`</listitem>`
804    ///  `<listitem>`INTERPOLATE(arg0, arg1, arg2) = arg0 x arg2 + arg1 x (1 - arg2)`</listitem>`
805    ///  `<listitem>`SUBTRACT(arg0, arg1) = arg0 - arg1`</listitem>`
806    ///  `<listitem>`
807    ///  `<programlisting>`
808    ///  DOT3_RGB(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
809    ///  (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
810    ///  (arg0[B] - 0.5)) * (arg1[B] - 0.5))
811    ///  `</programlisting>`
812    ///  `</listitem>`
813    ///  `<listitem>`
814    ///  `<programlisting>`
815    ///  DOT3_RGBA(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
816    ///  (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
817    ///  (arg0[B] - 0.5)) * (arg1[B] - 0.5))
818    ///  `</programlisting>`
819    ///  `</listitem>`
820    /// `</itemizedlist>`
821    ///
822    /// Refer to the
823    /// <link linkend="cogl-Blend-String-syntax">color-source syntax`</link>` for
824    /// describing the arguments. The valid source names for texture combining
825    /// are:
826    /// `<variablelist>`
827    ///  `<varlistentry>`
828    ///  `<term>`TEXTURE`</term>`
829    ///  `<listitem>`Use the color from the current texture layer`</listitem>`
830    ///  `</varlistentry>`
831    ///  `<varlistentry>`
832    ///  `<term>`TEXTURE_0, TEXTURE_1, etc`</term>`
833    ///  `<listitem>`Use the color from the specified texture layer`</listitem>`
834    ///  `</varlistentry>`
835    ///  `<varlistentry>`
836    ///  `<term>`CONSTANT`</term>`
837    ///  `<listitem>`Use the color from the constant given with
838    ///  `Pipeline::set_layer_combine_constant``</listitem>`
839    ///  `</varlistentry>`
840    ///  `<varlistentry>`
841    ///  `<term>`PRIMARY`</term>`
842    ///  `<listitem>`Use the color of the pipeline as set with
843    ///  `Pipeline::set_color``</listitem>`
844    ///  `</varlistentry>`
845    ///  `<varlistentry>`
846    ///  `<term>`PREVIOUS`</term>`
847    ///  `<listitem>`Either use the texture color from the previous layer, or
848    ///  if this is layer 0, use the color of the pipeline as set with
849    ///  `Pipeline::set_color``</listitem>`
850    ///  `</varlistentry>`
851    /// `</variablelist>`
852    ///
853    /// <refsect2 id="cogl-Layer-Combine-Examples">
854    ///  `<title>`Layer Combine Examples`</title>`
855    ///  `<para>`This is effectively what the default blending is:`</para>`
856    ///  `<informalexample>``<programlisting>`
857    ///  RGBA = MODULATE (PREVIOUS, TEXTURE)
858    ///  `</programlisting>``</informalexample>`
859    ///  `<para>`This could be used to cross-fade between two images, using
860    ///  the alpha component of a constant as the interpolator. The constant
861    ///  color is given by calling
862    ///  `Pipeline::set_layer_combine_constant`.`</para>`
863    ///  `<informalexample>``<programlisting>`
864    ///  RGBA = INTERPOLATE (PREVIOUS, TEXTURE, CONSTANT[A])
865    ///  `</programlisting>``</informalexample>`
866    /// `</refsect2>`
867    ///
868    /// `<note>`You can't give a multiplication factor for arguments as you can
869    /// with blending.`</note>`
870    ///
871    /// ## `layer_index`
872    /// Specifies the layer you want define a combine function for
873    /// ## `blend_string`
874    /// A <link linkend="cogl-Blend-Strings">Cogl blend string`</link>`
875    ///  describing the desired texture combine function.
876    ///
877    /// # Returns
878    ///
879    /// `true` if the blend string was successfully parsed, and the
880    ///  described texture combining is supported by the underlying driver and
881    ///  or hardware. On failure, `false` is returned and `error` is set
882    pub fn set_layer_combine(
883        &self,
884        layer_index: i32,
885        blend_string: &str,
886    ) -> Result<bool, glib::Error> {
887        unsafe {
888            let mut error = ptr::null_mut();
889            let ret = ffi::cogl_pipeline_set_layer_combine(
890                self.to_glib_none().0,
891                layer_index,
892                blend_string.to_glib_none().0,
893                &mut error,
894            );
895            if error.is_null() {
896                Ok(ret == crate::TRUE)
897            } else {
898                Err(from_glib_full(error))
899            }
900        }
901    }
902
903    /// When you are using the 'CONSTANT' color source in a layer combine
904    /// description then you can use this function to define its value.
905    ///
906    /// ## `layer_index`
907    /// Specifies the layer you want to specify a constant used
908    ///  for texture combining
909    /// ## `constant`
910    /// The constant color you want
911    pub fn set_layer_combine_constant(&self, layer_index: i32, constant: &Color) {
912        unsafe {
913            ffi::cogl_pipeline_set_layer_combine_constant(
914                self.to_glib_none().0,
915                layer_index,
916                constant.to_glib_none().0,
917            );
918        }
919    }
920
921    /// Changes the decimation and interpolation filters used when a texture is
922    /// drawn at other scales than 100%.
923    ///
924    /// `<note>`It is an error to pass anything other than
925    /// `PipelineFilter::Nearest` or `PipelineFilter::Linear` as
926    /// magnification filters since magnification doesn't ever need to
927    /// reference values stored in the mipmap chain.`</note>`
928    /// ## `layer_index`
929    /// the layer number to change.
930    /// ## `min_filter`
931    /// the filter used when scaling a texture down.
932    /// ## `mag_filter`
933    /// the filter used when magnifying a texture.
934    pub fn set_layer_filters(
935        &self,
936        layer_index: i32,
937        min_filter: PipelineFilter,
938        mag_filter: PipelineFilter,
939    ) {
940        unsafe {
941            ffi::cogl_pipeline_set_layer_filters(
942                self.to_glib_none().0,
943                layer_index,
944                min_filter.to_glib(),
945                mag_filter.to_glib(),
946            );
947        }
948    }
949
950    /// This function lets you set a matrix that can be used to e.g. translate
951    /// and rotate a single layer of a pipeline used to fill your geometry.
952    /// ## `layer_index`
953    /// the index for the layer inside `self`
954    /// ## `matrix`
955    /// the transformation matrix for the layer
956    pub fn set_layer_matrix(&self, layer_index: i32, matrix: &Matrix) {
957        unsafe {
958            ffi::cogl_pipeline_set_layer_matrix(
959                self.to_glib_none().0,
960                layer_index,
961                matrix.to_glib_none().0,
962            );
963        }
964    }
965
966    /// Sets the texture for this layer to be the default texture for the
967    /// given type. This is equivalent to calling
968    /// `Pipeline::set_layer_texture` with `None` for the texture
969    /// argument except that you can also specify the type of default
970    /// texture to use. The default texture is a 1x1 pixel white texture.
971    ///
972    /// This function is mostly useful if you want to create a base
973    /// pipeline that you want to create multiple copies from using
974    /// `Pipeline::copy`. In that case this function can be used to
975    /// specify the texture type so that any pipeline copies can share the
976    /// internal texture type state for efficiency.
977    /// ## `layer_index`
978    /// The layer number to modify
979    /// ## `texture_type`
980    /// The type of the default texture to use
981    pub fn set_layer_null_texture(&self, layer_index: i32, texture_type: TextureType) {
982        unsafe {
983            ffi::cogl_pipeline_set_layer_null_texture(
984                self.to_glib_none().0,
985                layer_index,
986                texture_type.to_glib(),
987            );
988        }
989    }
990
991    /// When rendering points, if `enable` is `true` then the texture
992    /// coordinates for this layer will be replaced with coordinates that
993    /// vary from 0.0 to 1.0 across the primitive. The top left of the
994    /// point will have the coordinates 0.0,0.0 and the bottom right will
995    /// have 1.0,1.0. If `enable` is `false` then the coordinates will be
996    /// fixed for the entire point.
997    ///
998    /// This function will only work if `FeatureID::OglFeatureIdPointSprite` is
999    /// available. If the feature is not available then the function will
1000    /// return `false` and set `error`.
1001    ///
1002    /// ## `layer_index`
1003    /// the layer number to change.
1004    /// ## `enable`
1005    /// whether to enable point sprite coord generation.
1006    ///
1007    /// # Returns
1008    ///
1009    /// `true` if the function succeeds, `false` otherwise.
1010    pub fn set_layer_point_sprite_coords_enabled(
1011        &self,
1012        layer_index: i32,
1013        enable: bool,
1014    ) -> Result<bool, glib::Error> {
1015        unsafe {
1016            let mut error = ptr::null_mut();
1017            let ret = ffi::cogl_pipeline_set_layer_point_sprite_coords_enabled(
1018                self.to_glib_none().0,
1019                layer_index,
1020                enable as i32,
1021                &mut error,
1022            );
1023            if error.is_null() {
1024                Ok(ret == crate::TRUE)
1025            } else {
1026                Err(from_glib_full(error))
1027            }
1028        }
1029    }
1030
1031    pub fn set_layer_texture<P: IsA<Texture>>(&self, layer_index: i32, texture: &P) {
1032        unsafe {
1033            ffi::cogl_pipeline_set_layer_texture(
1034                self.to_glib_none().0,
1035                layer_index,
1036                texture.as_ref().to_glib_none().0,
1037            );
1038        }
1039    }
1040
1041    /// Sets the wrap mode for all three coordinates of texture lookups on
1042    /// this layer. This is equivalent to calling
1043    /// `Pipeline::set_layer_wrap_mode_s`,
1044    /// `Pipeline::set_layer_wrap_mode_t` and
1045    /// `Pipeline::set_layer_wrap_mode_p` separately.
1046    ///
1047    /// ## `layer_index`
1048    /// the layer number to change.
1049    /// ## `mode`
1050    /// the new wrap mode
1051    pub fn set_layer_wrap_mode(&self, layer_index: i32, mode: PipelineWrapMode) {
1052        unsafe {
1053            ffi::cogl_pipeline_set_layer_wrap_mode(
1054                self.to_glib_none().0,
1055                layer_index,
1056                mode.to_glib(),
1057            );
1058        }
1059    }
1060
1061    /// Sets the wrap mode for the 'p' coordinate of texture lookups on
1062    /// this layer. 'p' is the third coordinate.
1063    ///
1064    /// ## `layer_index`
1065    /// the layer number to change.
1066    /// ## `mode`
1067    /// the new wrap mode
1068    pub fn set_layer_wrap_mode_p(&self, layer_index: i32, mode: PipelineWrapMode) {
1069        unsafe {
1070            ffi::cogl_pipeline_set_layer_wrap_mode_p(
1071                self.to_glib_none().0,
1072                layer_index,
1073                mode.to_glib(),
1074            );
1075        }
1076    }
1077
1078    /// Sets the wrap mode for the 's' coordinate of texture lookups on this layer.
1079    ///
1080    /// ## `layer_index`
1081    /// the layer number to change.
1082    /// ## `mode`
1083    /// the new wrap mode
1084    pub fn set_layer_wrap_mode_s(&self, layer_index: i32, mode: PipelineWrapMode) {
1085        unsafe {
1086            ffi::cogl_pipeline_set_layer_wrap_mode_s(
1087                self.to_glib_none().0,
1088                layer_index,
1089                mode.to_glib(),
1090            );
1091        }
1092    }
1093
1094    /// Sets the wrap mode for the 't' coordinate of texture lookups on this layer.
1095    ///
1096    /// ## `layer_index`
1097    /// the layer number to change.
1098    /// ## `mode`
1099    /// the new wrap mode
1100    pub fn set_layer_wrap_mode_t(&self, layer_index: i32, mode: PipelineWrapMode) {
1101        unsafe {
1102            ffi::cogl_pipeline_set_layer_wrap_mode_t(
1103                self.to_glib_none().0,
1104                layer_index,
1105                mode.to_glib(),
1106            );
1107        }
1108    }
1109
1110    /// Sets whether to use a per-vertex point size or to use the value set
1111    /// by `Pipeline::set_point_size`. If per-vertex point size is
1112    /// enabled then the point size can be set for an individual point
1113    /// either by drawing with a `Attribute` with the name
1114    /// ‘cogl_point_size_in’ or by writing to the GLSL builtin
1115    /// ‘cogl_point_size_out’ from a vertex shader snippet.
1116    ///
1117    /// If per-vertex point size is enabled and this attribute is not used
1118    /// and cogl_point_size_out is not written to then the results are
1119    /// undefined.
1120    ///
1121    /// Note that enabling this will only work if the
1122    /// `FeatureID::OglFeatureIdPerVertexPointSize` feature is available. If
1123    /// this is not available then the function will return `false` and set
1124    /// a `CoglError`.
1125    ///
1126    /// ## `enable`
1127    /// whether to enable per-vertex point size
1128    ///
1129    /// # Returns
1130    ///
1131    /// `true` if the change suceeded or `false` otherwise
1132    pub fn set_per_vertex_point_size(&self, enable: bool) -> Result<bool, glib::Error> {
1133        unsafe {
1134            let mut error = ptr::null_mut();
1135            let ret = ffi::cogl_pipeline_set_per_vertex_point_size(
1136                self.to_glib_none().0,
1137                enable as i32,
1138                &mut error,
1139            );
1140            if error.is_null() {
1141                Ok(ret == crate::TRUE)
1142            } else {
1143                Err(from_glib_full(error))
1144            }
1145        }
1146    }
1147
1148    /// Changes the size of points drawn when `VerticesMode::Points` is
1149    /// used with the attribute buffer API. Note that typically the GPU
1150    /// will only support a limited minimum and maximum range of point
1151    /// sizes. If the chosen point size is outside that range then the
1152    /// nearest value within that range will be used instead. The size of a
1153    /// point is in screen space so it will be the same regardless of any
1154    /// transformations.
1155    ///
1156    /// If the point size is set to 0.0 then drawing points with the
1157    /// pipeline will have undefined results. This is the default value so
1158    /// if an application wants to draw points it must make sure to use a
1159    /// pipeline that has an explicit point size set on it.
1160    ///
1161    /// ## `point_size`
1162    /// the new point size.
1163    pub fn set_point_size(&self, point_size: f32) {
1164        unsafe {
1165            ffi::cogl_pipeline_set_point_size(self.to_glib_none().0, point_size);
1166        }
1167    }
1168
1169    /// Sets the shininess of the pipeline, in the standard OpenGL lighting
1170    /// model, which determines the size of the specular highlights. A
1171    /// higher `shininess` will produce smaller highlights which makes the
1172    /// object appear more shiny.
1173    ///
1174    /// The default value is 0.0
1175    ///
1176    /// ## `shininess`
1177    /// The desired shininess; must be >= 0.0
1178    pub fn set_shininess(&self, shininess: f32) {
1179        unsafe {
1180            ffi::cogl_pipeline_set_shininess(self.to_glib_none().0, shininess);
1181        }
1182    }
1183
1184    /// Sets the pipeline's specular color, in the standard OpenGL lighting
1185    /// model. The intensity of the specular color depends on the viewport
1186    /// position, and is brightest along the lines of reflection.
1187    ///
1188    /// The default value is (0.0, 0.0, 0.0, 1.0)
1189    ///
1190    /// ## `specular`
1191    /// The components of the desired specular color
1192    pub fn set_specular(&self, specular: &Color) {
1193        unsafe {
1194            ffi::cogl_pipeline_set_specular(self.to_glib_none().0, specular.to_glib_none().0);
1195        }
1196    }
1197
1198    /// Sets a new value for the uniform at `uniform_location`. If this
1199    /// pipeline has a user program attached and is later used as a source
1200    /// for drawing, the given value will be assigned to the uniform which
1201    /// can be accessed from the shader's source. The value for
1202    /// `uniform_location` should be retrieved from the string name of the
1203    /// uniform by calling `Pipeline::get_uniform_location`.
1204    ///
1205    /// This function should be used to set uniforms that are of type
1206    /// float. It can also be used to set a single member of a float array
1207    /// uniform.
1208    ///
1209    /// ## `uniform_location`
1210    /// The uniform's location identifier
1211    /// ## `value`
1212    /// The new value for the uniform
1213    pub fn set_uniform_1f(&self, uniform_location: i32, value: f32) {
1214        unsafe {
1215            ffi::cogl_pipeline_set_uniform_1f(self.to_glib_none().0, uniform_location, value);
1216        }
1217    }
1218
1219    /// Sets a new value for the uniform at `uniform_location`. If this
1220    /// pipeline has a user program attached and is later used as a source
1221    /// for drawing, the given value will be assigned to the uniform which
1222    /// can be accessed from the shader's source. The value for
1223    /// `uniform_location` should be retrieved from the string name of the
1224    /// uniform by calling `Pipeline::get_uniform_location`.
1225    ///
1226    /// This function should be used to set uniforms that are of type
1227    /// int. It can also be used to set a single member of a int array
1228    /// uniform or a sampler uniform.
1229    ///
1230    /// ## `uniform_location`
1231    /// The uniform's location identifier
1232    /// ## `value`
1233    /// The new value for the uniform
1234    pub fn set_uniform_1i(&self, uniform_location: i32, value: i32) {
1235        unsafe {
1236            ffi::cogl_pipeline_set_uniform_1i(self.to_glib_none().0, uniform_location, value);
1237        }
1238    }
1239
1240    /// Sets new values for the uniform at `uniform_location`. If this
1241    /// pipeline has a user program attached and is later used as a source
1242    /// for drawing, the given values will be assigned to the uniform which
1243    /// can be accessed from the shader's source. The value for
1244    /// `uniform_location` should be retrieved from the string name of the
1245    /// uniform by calling `Pipeline::get_uniform_location`.
1246    ///
1247    /// This function can be used to set any floating point type uniform,
1248    /// including float arrays and float vectors. For example, to set a
1249    /// single vec4 uniform you would use 4 for `n_components` and 1 for
1250    /// `count`. To set an array of 8 float values, you could use 1 for
1251    /// `n_components` and 8 for `count`.
1252    ///
1253    /// ## `uniform_location`
1254    /// The uniform's location identifier
1255    /// ## `n_components`
1256    /// The number of components in the corresponding uniform's type
1257    /// ## `count`
1258    /// The number of values to set
1259    /// ## `value`
1260    /// Pointer to the new values to set
1261    pub fn set_uniform_float(
1262        &self,
1263        uniform_location: i32,
1264        n_components: i32,
1265        count: i32,
1266        value: &[f32],
1267    ) {
1268        unsafe {
1269            ffi::cogl_pipeline_set_uniform_float(
1270                self.to_glib_none().0,
1271                uniform_location,
1272                n_components,
1273                count,
1274                value.as_ptr(),
1275            );
1276        }
1277    }
1278
1279    /// Sets new values for the uniform at `uniform_location`. If this
1280    /// pipeline has a user program attached and is later used as a source
1281    /// for drawing, the given values will be assigned to the uniform which
1282    /// can be accessed from the shader's source. The value for
1283    /// `uniform_location` should be retrieved from the string name of the
1284    /// uniform by calling `Pipeline::get_uniform_location`.
1285    ///
1286    /// This function can be used to set any integer type uniform,
1287    /// including int arrays and int vectors. For example, to set a single
1288    /// ivec4 uniform you would use 4 for `n_components` and 1 for
1289    /// `count`. To set an array of 8 int values, you could use 1 for
1290    /// `n_components` and 8 for `count`.
1291    ///
1292    /// ## `uniform_location`
1293    /// The uniform's location identifier
1294    /// ## `n_components`
1295    /// The number of components in the corresponding uniform's type
1296    /// ## `count`
1297    /// The number of values to set
1298    /// ## `value`
1299    /// Pointer to the new values to set
1300    pub fn set_uniform_int(
1301        &self,
1302        uniform_location: i32,
1303        n_components: i32,
1304        count: i32,
1305        value: &[i32],
1306    ) {
1307        unsafe {
1308            ffi::cogl_pipeline_set_uniform_int(
1309                self.to_glib_none().0,
1310                uniform_location,
1311                n_components,
1312                count,
1313                value.as_ptr(),
1314            );
1315        }
1316    }
1317
1318    /// Sets new values for the uniform at `uniform_location`. If this
1319    /// pipeline has a user program attached and is later used as a source
1320    /// for drawing, the given values will be assigned to the uniform which
1321    /// can be accessed from the shader's source. The value for
1322    /// `uniform_location` should be retrieved from the string name of the
1323    /// uniform by calling `Pipeline::get_uniform_location`.
1324    ///
1325    /// This function can be used to set any matrix type uniform, including
1326    /// matrix arrays. For example, to set a single mat4 uniform you would
1327    /// use 4 for `dimensions` and 1 for `count`. To set an array of 8
1328    /// mat3 values, you could use 3 for `dimensions` and 8 for `count`.
1329    ///
1330    /// If `transpose` is `false` then the matrix is expected to be in
1331    /// column-major order or if it is `true` then the matrix is in
1332    /// row-major order. You can pass a `Matrix` by calling by passing
1333    /// the result of `Matrix::get_array` in `value` and setting
1334    /// `transpose` to `false`.
1335    ///
1336    /// ## `uniform_location`
1337    /// The uniform's location identifier
1338    /// ## `dimensions`
1339    /// The size of the matrix
1340    /// ## `count`
1341    /// The number of values to set
1342    /// ## `transpose`
1343    /// Whether to transpose the matrix
1344    /// ## `value`
1345    /// Pointer to the new values to set
1346    pub fn set_uniform_matrix(
1347        &self,
1348        uniform_location: i32,
1349        dimensions: i32,
1350        count: i32,
1351        transpose: bool,
1352        value: &[f32],
1353    ) {
1354        unsafe {
1355            ffi::cogl_pipeline_set_uniform_matrix(
1356                self.to_glib_none().0,
1357                uniform_location,
1358                dimensions,
1359                count,
1360                transpose as i32,
1361                value.as_ptr(),
1362            );
1363        }
1364    }
1365
1366    //pub fn set_user_program(&self, program: /*Unimplemented*/Handle) {
1367    //    unsafe { TODO: call cogl_sys:cogl_pipeline_set_user_program() }
1368    //}
1369}
1370
1371impl fmt::Display for Pipeline {
1372    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1373        write!(f, "Pipeline")
1374    }
1375}