X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Fsurface.hpp;h=07280817b69fb913fd003cb2cae4d61199976531;hb=7124036c70cf7e99e67518f3527934672811442d;hp=a9358fbbac92b3dea875fe6deef721bc2804bbba;hpb=99cf62c2d44b4555e9761f1c8f1b10cf880c33fb;p=supertux.git diff --git a/src/video/surface.hpp b/src/video/surface.hpp index a9358fbba..07280817b 100644 --- a/src/video/surface.hpp +++ b/src/video/surface.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,115 +12,65 @@ // 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. -#ifndef __SURFACE_HPP__ -#define __SURFACE_HPP__ +// along with this program. If not, see . -#include +#ifndef HEADER_SUPERTUX_VIDEO_SURFACE_HPP +#define HEADER_SUPERTUX_VIDEO_SURFACE_HPP #include -#include +#include + #include "math/vector.hpp" -#include "file_system.hpp" -#include +#include "math/rect.hpp" +#include "video/surface_ptr.hpp" +#include "video/texture_ptr.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 -}; +class SurfaceData; -/** - * A rectangular image. - * The class basically holds a reference to a texture with additional UV - * coordinates that specify a rectangular area on this texture - */ +/** A rectangular image. The class basically holds a reference to a + texture with additional UV coordinates that specify a rectangular + area on this texture */ class Surface { +public: + static SurfacePtr create(const std::string& file); + static SurfacePtr create(const std::string& file, const Rect& rect); + private: - Unison::Video::TextureSection texture; + TexturePtr texture; + SurfaceData* surface_data; + Rect rect; bool flipx; -public: - Surface(const std::string& file) : - texture(FileSystem::normalize(file)), - flipx(false) - { - } - - Surface(const std::string& file, int x, int y, int w, int h) : - texture(FileSystem::normalize(file), Unison::Video::Rect(x, y, w, h)), - flipx(false) - { - } +private: + Surface(const std::string& file); + Surface(const std::string& file, const Rect& rect); + Surface(const Surface&); - Surface(const Surface& other) : - texture(other.texture), - flipx(false) - { - } +public: + ~Surface(); - ~Surface() - { - } + SurfacePtr clone() const; /** flip the surface horizontally */ - void hflip() - { - flipx = !flipx; - } + void hflip(); + bool get_flipx() const; - bool get_flipx() const - { - return flipx; - } + TexturePtr get_texture() const; + SurfaceData* get_surface_data() const; + int get_x() const; + int get_y() const; + int get_width() const; + int get_height() const; + Vector get_position() const; - const Surface& operator= (const Surface& other) - { - texture = other.texture; - return *this; - } + /** returns a vector containing width and height */ + Vector get_size() const; - Unison::Video::TextureSection get_texture() const - { - return texture; - } - - int get_x() const - { - return texture.clip_rect.pos.x; - } - - int get_y() const - { - return texture.clip_rect.pos.y; - } - - int get_width() const - { - return texture.clip_rect.size.x ? texture.clip_rect.size.x : texture.image.get_size().x; - } - - int get_height() const - { - return texture.clip_rect.size.y ? texture.clip_rect.size.y : texture.image.get_size().y; - } - - Vector get_position() const - { return Vector(get_x(), get_y()); } - - /** - * returns a vector containing width and height - */ - Vector get_size() const - { return Vector(get_width(), get_height()); } +private: + Surface& operator=(const Surface&); }; #endif + +/* EOF */