X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphic.h;h=1ae0d5e22d8766a718bbd828329be7bb334663dd;hb=HEAD;hp=f4cc907223a3ea6fd9a009fefb0f4b0013bbd6f9;hpb=c062ca892fc6e10f74a76991b5d4b4349c046b5f;p=libs%2Fgltk.git diff --git a/source/graphic.h b/source/graphic.h index f4cc907..32a0686 100644 --- a/source/graphic.h +++ b/source/graphic.h @@ -1,45 +1,52 @@ #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 Parser::Loader + class Loader: public DataFile::CollectionObjectLoader { public: - Loader(Graphic &); - private: - Graphic &graph; + Loader(Graphic &, Resources &); + private: void texture(const std::string &); void slice(unsigned, unsigned, unsigned, unsigned); void border(); void shadow(); }; - Graphic(const Resources &, const std::string &); +private: + Sides border; + Sides shadow; + const GL::Texture2D *texture = nullptr; + Geometry slice; + bool repeat = false; + +public: 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; + void build(unsigned, unsigned, GL::PrimitiveBuilder &) const; private: - const Resources &res; - std::string name; - Sides border; - Sides shadow; - const GL::Texture2D *texture; - Geometry slice; + void create_coords(float, float, float, float, float, std::vector &) const; + void create_texcoords(float, float, float, float, float, std::vector &) const; }; } // namespace GLtk