]> git.tdb.fi Git - libs/gltk.git/blob - source/graphic.h
f4cc907223a3ea6fd9a009fefb0f4b0013bbd6f9
[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/parser/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 Parser::Loader
17         {
18         public:
19                 Loader(Graphic &);
20         private:
21                 Graphic &graph;
22
23                 void texture(const std::string &);
24                 void slice(unsigned, unsigned, unsigned, unsigned);
25                 void border();
26                 void shadow();
27         };
28
29         Graphic(const Resources &, const std::string &);
30         const Sides &get_border() const { return border; }
31         const Sides &get_shadow() const { return shadow; }
32         const GL::Texture2D *get_texture() const { return texture; }
33         unsigned get_width() const  { return slice.w; }
34         unsigned get_height() const { return slice.h; }
35         void render(unsigned, unsigned) const;
36 private:
37         const Resources &res;
38         std::string name;
39         Sides border;
40         Sides shadow;
41         const GL::Texture2D *texture;
42         Geometry slice;
43 };
44
45 } // namespace GLtk
46 } // namespace Msp
47
48 #endif