X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Fsurface.hpp;h=07280817b69fb913fd003cb2cae4d61199976531;hb=dfaf28adf2756d68091c7e54ab16fcb174dfcc5c;hp=0945253edff8810bed4124303e1bd8314aa5b226;hpb=6b50afc6cdd8d3555901b02ce12f15b5bac32aa8;p=supertux.git diff --git a/src/video/surface.hpp b/src/video/surface.hpp index 0945253ed..07280817b 100644 --- a/src/video/surface.hpp +++ b/src/video/surface.hpp @@ -1,86 +1,76 @@ -// $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 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 . + +#ifndef HEADER_SUPERTUX_VIDEO_SURFACE_HPP +#define HEADER_SUPERTUX_VIDEO_SURFACE_HPP #include +#include -class Color; -class Blend; -class ImageTexture; +#include "math/vector.hpp" +#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 = 0x0000, - /** Draw the Surface upside down */ - VERTICAL_FLIP = 0x0001, - /** Draw the Surface from left to down */ - HORIZONTAL_FLIP = 0x0002, -}; +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 { -private: - friend class DrawingContext; - friend class Font; - ImageTexture* texture; +public: + static SurfacePtr create(const std::string& file); + static SurfacePtr create(const std::string& file, const Rect& rect); - float uv_left; - float uv_top; - float uv_right; - float uv_bottom; +private: + TexturePtr texture; + SurfaceData* surface_data; + Rect rect; + bool flipx; - void draw(float x, float y, float alpha, float angle, const Color& color, const Blend& blend, DrawingEffect effect) const; - void draw(float x, float y, float alpha, DrawingEffect effect) const; - void draw_part(float src_x, float src_y, float dst_x, float dst_y, - float width, float height, - float alpha, DrawingEffect effect) const; +private: + Surface(const std::string& file); + Surface(const std::string& file, const Rect& rect); + Surface(const Surface&); - float width; - float height; public: - Surface(const std::string& file); - Surface(const std::string& file, int x, int y, int w, int h); - Surface(const Surface& other); ~Surface(); + SurfacePtr clone() const; + /** flip the surface horizontally */ void hflip(); - - const Surface& operator= (const Surface& other); + bool get_flipx() const; - float get_width() const - { - return width; - } + 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; - float get_height() const - { - return height; - } + /** returns a vector containing width and height */ + Vector get_size() const; + +private: + Surface& operator=(const Surface&); }; #endif + +/* EOF */