X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphic.h;h=4fed368938016e8613e4a6132155d932889d48a0;hb=56c41b294aa47a38ac3e1be70d4868f260cb4274;hp=b93111348175874150190c1666c5d6896d6efe61;hpb=a38c924ff32081f5cd67c2b0e2d5ca61f0e99de2;p=libs%2Fgltk.git diff --git a/source/graphic.h b/source/graphic.h index b931113..4fed368 100644 --- a/source/graphic.h +++ b/source/graphic.h @@ -1,29 +1,28 @@ #ifndef MSP_GLTK_GRAPHIC_H_ #define MSP_GLTK_GRAPHIC_H_ +#include #include -#include +#include #include "geometry.h" +#include "mspgltk_api.h" namespace Msp { namespace GLtk { class Resources; -class Graphic +/** +Stores a single graphical element. Graphics are used as parts of widgets. +*/ +class MSPGLTK_API Graphic { public: - class Loader: public DataFile::Loader + class Loader: public DataFile::CollectionObjectLoader { - private: - Graphic &graph; - Resources &res; - public: - typedef Resources Collection; - Loader(Graphic &, Resources &); - Graphic &get_object() const { return graph; } + private: void texture(const std::string &); void slice(unsigned, unsigned, unsigned, unsigned); @@ -31,13 +30,6 @@ public: void shadow(); }; - Graphic(); - const Sides &get_border() const { return border; } - const Sides &get_shadow() const { return shadow; } - const GL::Texture2D *get_texture() const { return texture; } - unsigned get_width() const { return slice.w; } - unsigned get_height() const { return slice.h; } - void render(unsigned, unsigned) const; private: Sides border; Sides shadow; @@ -45,6 +37,15 @@ private: Geometry slice; bool repeat; +public: + Graphic(); + const Sides &get_border() const { return border; } + const Sides &get_shadow() const { return shadow; } + const GL::Texture2D *get_texture() const { return texture; } + unsigned get_width() const { return slice.w; } + unsigned get_height() const { return slice.h; } + void build(unsigned, unsigned, GL::PrimitiveBuilder &) const; +private: void create_coords(float, float, float, float, float, std::vector &) const; void create_texcoords(float, float, float, float, float, std::vector &) const; };