cogl/auto/
indices.rs

1use crate::{IndexBuffer, IndicesType, Object};
2
3use glib::translate::*;
4use std::fmt;
5
6glib_wrapper! {
7    pub struct Indices(Object<ffi::CoglIndices, IndicesClass>) @extends Object;
8
9    match fn {
10        get_type => || ffi::cogl_indices_get_gtype(),
11    }
12}
13
14impl Indices {
15    //pub fn new(context: &Context, type_: IndicesType, indices_data: /*Unimplemented*/Option<Fundamental: Pointer>, n_indices: i32) -> Indices {
16    //    unsafe { TODO: call cogl_sys:cogl_indices_new() }
17    //}
18
19    pub fn new_for_buffer(type_: IndicesType, buffer: &IndexBuffer, offset: usize) -> Indices {
20        unsafe {
21            from_glib_full(ffi::cogl_indices_new_for_buffer(
22                type_.to_glib(),
23                buffer.to_glib_none().0,
24                offset,
25            ))
26        }
27    }
28
29    pub fn get_buffer(&self) -> Option<IndexBuffer> {
30        unsafe { from_glib_none(ffi::cogl_indices_get_buffer(self.to_glib_none().0)) }
31    }
32
33    pub fn get_offset(&self) -> usize {
34        unsafe { ffi::cogl_indices_get_offset(self.to_glib_none().0) }
35    }
36
37    pub fn get_type(&self) -> IndicesType {
38        unsafe { from_glib(ffi::cogl_indices_get_type(self.to_glib_none().0)) }
39    }
40
41    pub fn set_offset(&self, offset: usize) {
42        unsafe {
43            ffi::cogl_indices_set_offset(self.to_glib_none().0, offset);
44        }
45    }
46}
47
48impl fmt::Display for Indices {
49    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
50        write!(f, "Indices")
51    }
52}