X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Ftexture.hpp;h=6e4c462fec9d84e14f40d7ebc5ae1ed370d4b8cf;hb=4f423b9bbb6fa694b8c6bcc338e069aad45db3e3;hp=3c8b4f7086eae8923a416e0eb3904acf2e19399b;hpb=86181b0a14d89cf45daf97199c3556c4dd1ee7b7;p=supertux.git diff --git a/src/video/texture.hpp b/src/video/texture.hpp index 3c8b4f708..6e4c462fe 100644 --- a/src/video/texture.hpp +++ b/src/video/texture.hpp @@ -1,7 +1,7 @@ // $Id$ // -// SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -16,11 +16,27 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + #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 @@ -30,34 +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(); - - GLuint get_handle() const + 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; + + 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 -