X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Ftexture.hpp;h=589fd95921936a005343961349428d93c130bea3;hb=c1277f5b7db9f55d1d28f658b4e804f32b76f0ce;hp=8322e3c7a13051cfe6c52dbba7e1697b32e8748c;hpb=efc61e9d05b077f13a76982590fb0bd6a9d8dc61;p=supertux.git diff --git a/src/video/texture.hpp b/src/video/texture.hpp index 8322e3c7a..589fd9592 100644 --- a/src/video/texture.hpp +++ b/src/video/texture.hpp @@ -1,12 +1,10 @@ -// $Id$ +// SuperTux +// Copyright (C) 2006 Matthias Braun // -// SuperTux - A Jump'n Run -// Copyright (C) 2004 Matthias Braun . + +#ifndef HEADER_SUPERTUX_VIDEO_TEXTURE_HPP +#define HEADER_SUPERTUX_VIDEO_TEXTURE_HPP + +#include + +#include +#include -#include -#include +#include "video/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 very simple wrapper around a texture handle + * This class is a wrapper around a texture handle. It stores the texture width + * and height and provides convenience functions for uploading SDL_Surfaces + * into the texture */ class Texture { +protected: + int refcount; + std::string filename; + public: - GLuint handle; - unsigned int width; - unsigned int height; - - Texture(unsigned int width, unsigned int height, GLenum glformat); - Texture(SDL_Surface* surface, GLenum glformat); - ~Texture(); - - void upload_texture(SDL_Surface* image, int src_x, int src_y, int dst_x, int dst_y, - int width, int height); + 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 filename; + } + + void set_filename(std::string filename) + { + this->filename = filename; + } + + void ref() + { + refcount++; + } + + void unref() + { + assert(refcount > 0); + refcount--; + if(refcount == 0) + release(); + } + private: - void set_texture_params(); -}; + void release() + { + texture_manager->release(this); + } +private: + Texture(const Texture&); + Texture& operator=(const Texture&); +}; #endif +/* EOF */