src/video/texture.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_VIDEO_TEXTURE_HPP
00018 #define HEADER_SUPERTUX_VIDEO_TEXTURE_HPP
00019 
00020 #include <config.h>
00021 
00022 #include <assert.h>
00023 #include <string>
00024 
00025 #include "supertux/globals.hpp"
00026 #include "video/texture_manager.hpp"
00027 
00029 enum DrawingEffect {
00031   NO_EFFECT,
00033   VERTICAL_FLIP,
00035   HORIZONTAL_FLIP,
00036   NUM_EFFECTS
00037 };
00038 
00044 class Texture
00045 {
00046 private:
00047   friend class TextureManager;
00048   /* The name under which this texture is cached by the texture manager,
00049    * or the empty string if not. */
00050   std::string cache_filename;
00051 
00052 public:
00053   Texture() : cache_filename() {}
00054   virtual ~Texture() 
00055   {
00056     if (texture_manager && cache_filename != "")
00057       /* The cache entry is now useless: its weak pointer to us has been
00058        * cleared.  Remove the entry altogether to save memory. */
00059       texture_manager->reap_cache_entry(cache_filename);
00060   }
00061 
00062   virtual unsigned int get_texture_width() const = 0;
00063   virtual unsigned int get_texture_height() const = 0;
00064   virtual unsigned int get_image_width() const = 0;
00065   virtual unsigned int get_image_height() const = 0;
00066 
00067 private:
00068   Texture(const Texture&);
00069   Texture& operator=(const Texture&);
00070 };
00071 
00072 #endif
00073 
00074 /* EOF */

Generated on Mon Apr 21 03:38:19 2014 for SuperTux by  doxygen 1.5.1