X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Ftexture.hpp;h=6e4c462fec9d84e14f40d7ebc5ae1ed370d4b8cf;hb=4f423b9bbb6fa694b8c6bcc338e069aad45db3e3;hp=bf87c65df0a36d81c5d5045f24c39157df8f6f15;hpb=a113d3bd1feddd510e3b2852b0d42522735eee40;p=supertux.git diff --git a/src/video/texture.hpp b/src/video/texture.hpp index bf87c65df..6e4c462fe 100644 --- a/src/video/texture.hpp +++ b/src/video/texture.hpp @@ -20,8 +20,23 @@ #ifndef __TEXTURE_HPP__ #define __TEXTURE_HPP__ -#include -#include +#include + +#include +#include + +#include "texture_manager.hpp" + +/// bitset for drawing effects +enum DrawingEffect { + /** Don't apply anything */ + NO_EFFECT, + /** Draw the Surface upside down */ + VERTICAL_FLIP, + /** Draw the Surface from left to down */ + HORIZONTAL_FLIP, + NUM_EFFECTS +}; /** * This class is a wrapper around a texture handle. It stores the texture width @@ -31,33 +46,46 @@ class Texture { protected: - friend class TextureManager; - GLuint handle; - unsigned int width; - unsigned int height; + int refcount; + std::string filename; public: - Texture(unsigned int width, unsigned int height, GLenum glformat); - Texture(SDL_Surface* surface, GLenum glformat); - virtual ~Texture(); + Texture() : refcount(0), filename() {} + virtual ~Texture() {} + + virtual unsigned int get_texture_width() const = 0; + virtual unsigned int get_texture_height() const = 0; + virtual unsigned int get_image_width() const = 0; + virtual unsigned int get_image_height() const = 0; - GLuint get_handle() const + std::string get_filename() const { - return handle; + return filename; } - unsigned int get_width() const + void set_filename(std::string filename) { - return width; + this->filename = filename; } - unsigned int get_height() const + void ref() { - return height; + refcount++; + } + + void unref() + { + assert(refcount > 0); + refcount--; + if(refcount == 0) + release(); } private: - void set_texture_params(); + void release() + { + texture_manager->release(this); + } }; #endif