X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Ftexture.hpp;h=0a316cf6378f22ca458bdfcf20d8bc8fdf3419bf;hb=39b21a2b4a45fe80b4e08e59cdc61556f9da8b20;hp=0e4dd89d268e5baf2c52eac26f82cff7bfdf43fa;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/video/texture.hpp b/src/video/texture.hpp index 0e4dd89d2..0a316cf63 100644 --- a/src/video/texture.hpp +++ b/src/video/texture.hpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,14 +12,31 @@ // GNU General Public License for more details. // // 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. +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_VIDEO_TEXTURE_HPP +#define HEADER_SUPERTUX_VIDEO_TEXTURE_HPP + +#include -#ifndef __TEXTURE_HPP__ -#define __TEXTURE_HPP__ +#include +#include + +#include "supertux/globals.hpp" +#include "video/texture_manager.hpp" + +/// bitset for drawing effects +enum { + /** Don't apply anything */ + NO_EFFECT = 0, + /** Draw the Surface upside down */ + VERTICAL_FLIP = (1<<1), + /** Draw the Surface from left to down */ + HORIZONTAL_FLIP = (1<<2), + NUM_EFFECTS +}; -#include -#include +typedef unsigned int DrawingEffect; /** * This class is a wrapper around a texture handle. It stores the texture width @@ -30,35 +45,32 @@ */ class Texture { -protected: +private: friend class TextureManager; - GLuint handle; - unsigned int width; - unsigned int height; + /* The name under which this texture is cached by the texture manager, + * or the empty string if not. */ + std::string cache_filename; public: - Texture(unsigned int width, unsigned int height, GLenum glformat); - Texture(SDL_Surface* surface, GLenum glformat); - virtual ~Texture(); - - GLuint get_handle() const - { - return handle; - } - - unsigned int get_width() const + Texture() : cache_filename() {} + virtual ~Texture() { - return width; + if (texture_manager && cache_filename != "") + /* The cache entry is now useless: its weak pointer to us has been + * cleared. Remove the entry altogether to save memory. */ + texture_manager->reap_cache_entry(cache_filename); } - unsigned int get_height() const - { - return height; - } + 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; private: - void set_texture_params(); + Texture(const Texture&); + Texture& operator=(const Texture&); }; #endif +/* EOF */