]> git.tdb.fi Git - libs/gltk.git/blob - source/graphic.h
a9722ad97ff3e498187fffae3ff229a4654e66ae
[libs/gltk.git] / source / graphic.h
1 #ifndef MSP_GLTK_GRAPHIC_H_
2 #define MSP_GLTK_GRAPHIC_H_
3
4 #include <msp/gl/texture2d.h>
5 #include <msp/datafile/loader.h>
6 #include "geometry.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 class Resources;
12
13 class Graphic
14 {
15 public:
16         class Loader: public DataFile::Loader
17         {
18         private:
19                 Graphic &graph;
20                 Resources &res;
21
22         public:
23                 typedef Resources Collection;
24
25                 Loader(Graphic &, Resources &);
26         private:
27                 void texture(const std::string &);
28                 void slice(unsigned, unsigned, unsigned, unsigned);
29                 void border();
30                 void shadow();
31         };
32
33         Graphic();
34         const Sides &get_border() const { return border; }
35         const Sides &get_shadow() const { return shadow; }
36         const GL::Texture2D *get_texture() const { return texture; }
37         unsigned get_width() const  { return slice.w; }
38         unsigned get_height() const { return slice.h; }
39         void render(unsigned, unsigned) const;
40 private:
41         Sides border;
42         Sides shadow;
43         const GL::Texture2D *texture;
44         Geometry slice;
45 };
46
47 } // namespace GLtk
48 } // namespace Msp
49
50 #endif