1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use crate::{Bitmap, Context, Object, PixelFormat};
use ffi;
use glib;
use glib::translate::*;
use std::{fmt, ptr};
glib_wrapper! {
pub struct AtlasTexture(Object<ffi::CoglAtlasTexture, AtlasTextureClass>) @extends Object;
match fn {
get_type => || ffi::cogl_atlas_texture_get_gtype(),
}
}
impl AtlasTexture {
pub fn from_bitmap(bmp: &Bitmap) -> AtlasTexture {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::cogl_atlas_texture_new_from_bitmap(
bmp.to_glib_none().0,
))
}
}
pub fn from_file(ctx: &Context, filename: &str) -> Result<AtlasTexture, glib::Error> {
skip_assert_initialized!();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::cogl_atlas_texture_new_from_file(
ctx.to_glib_none().0,
filename.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
pub fn with_size(ctx: &Context, width: i32, height: i32) -> AtlasTexture {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::cogl_atlas_texture_new_with_size(
ctx.to_glib_none().0,
width,
height,
))
}
}
}
impl fmt::Display for AtlasTexture {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "AtlasTexture")
}
}