blob: cdaa3bab0a9037c4acc8c009934b2209d9e94d15 (
plain)
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
|
#include "../../include/mglpp/graphics/Texture.hpp"
#include "../../include/mglpp/graphics/Image.hpp"
namespace mgl {
Texture::Texture() {
texture.id = 0;
}
Texture::~Texture() {
if(owned)
mgl_texture_unload(&texture);
}
// static
Texture Texture::reference(mgl_texture ref) {
Texture instance;
instance.texture = ref;
instance.owned = false;
return instance;
}
bool Texture::load_from_file(const char *filepath) {
if(texture.id)
return false;
/* TODO: use the last arg (load options) */
return mgl_texture_load_from_file(&texture, filepath, nullptr) == 0;
}
bool Texture::load_from_image(Image &image) {
if(texture.id)
return false;
/* TODO: use the last arg (load options) */
return mgl_texture_load_from_image(&texture, image.internal_image(), nullptr) == 0;
}
vec2i Texture::get_size() const {
return { texture.width, texture.height };
}
bool Texture::is_valid() const {
return texture.id != 0;
}
mgl_texture* Texture::internal_texture() {
return &texture;
}
}
|