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_GL_SURFACE_DATA_HPP 00018 #define HEADER_SUPERTUX_VIDEO_GL_SURFACE_DATA_HPP 00019 00020 #include "video/surface.hpp" 00021 #include "video/surface_data.hpp" 00022 00023 class GLSurfaceData : public SurfaceData 00024 { 00025 private: 00026 const Surface &surface; 00027 float uv_left; 00028 float uv_top; 00029 float uv_right; 00030 float uv_bottom; 00031 00032 public: 00033 GLSurfaceData(const Surface &surface) : 00034 surface(surface), 00035 uv_left((float) surface.get_x() / surface.get_texture()->get_texture_width()), 00036 uv_top((float) surface.get_y() / surface.get_texture()->get_texture_height()), 00037 uv_right((float) (surface.get_x() + surface.get_width()) / surface.get_texture()->get_texture_width()), 00038 uv_bottom((float) (surface.get_y() + surface.get_height()) / surface.get_texture()->get_texture_height()) 00039 { 00040 } 00041 00042 float get_uv_left() const 00043 { 00044 return surface.get_flipx() ? uv_right : uv_left; 00045 } 00046 00047 float get_uv_top() const 00048 { 00049 return uv_top; 00050 } 00051 00052 float get_uv_right() const 00053 { 00054 return surface.get_flipx() ? uv_left : uv_right; 00055 } 00056 00057 float get_uv_bottom() const 00058 { 00059 return uv_bottom; 00060 } 00061 }; 00062 00063 #endif 00064 00065 /* EOF */