first git commit: scene, object, mesh, texture, shader, material etc
[demo] / src / texture.cc
1 #include "imago2.h"
2 #include "texture.h"
3
4 Texture::Texture()
5 {
6         w = 0;
7         h = 0;
8
9         pixels = 0;
10 }
11
12 Texture::~Texture()
13 {
14         img_free_pixels(pixels);
15 }
16
17 bool Texture::load(const char *fname)
18 {
19         if(!(pixels = (unsigned char *)img_load_pixels(fname, &w, &h))) {
20                 fprintf(stderr, "Failed to load pixels from file: %s.\n", fname);
21                 return false;
22         }
23         update();
24         return true;
25 }