00001 00002 /* 00003 TEDDY - General graphics application library 00004 Copyright (C) 1999-2002 Timo Suoranta 00005 tksuoran@cc.helsinki.fi 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 $Id: Texture.h,v 1.5 2002/01/17 18:57:37 tksuoran Exp $ 00022 */ 00023 00024 00025 #ifndef TEDDY__GRAPHICS__TEXTURE__H 00026 #define TEDDY__GRAPHICS__TEXTURE__H 00027 00028 00029 #include "Teddy/Graphics/Color.h" 00030 #include "Teddy/Graphics/Device.h" 00031 #include "Teddy/Maths/Vector2.h" 00032 #include "Teddy/MixIn/Named.h" 00033 #include "Teddy/MixIn/Options.h" 00034 00035 00036 namespace Teddy { 00037 namespace Graphics { 00038 00039 00041 class Texture : public Teddy::MixIn::Named, public Teddy::MixIn::Options { 00042 public: 00043 static const unsigned long TX_RESERVED ; 00044 static const unsigned long TX_BLIT_NO_SCALE ; 00045 static const unsigned long TX_GENERATE_ALPHA ; 00046 static const unsigned long TX_ALPHA_ONLY ; 00047 static const unsigned long TX_NO_ALPHA ; 00048 00049 static const unsigned long WRAP_REPEAT ; 00050 static const unsigned long WRAP_CLAMP ; 00051 00052 static const unsigned long ENV_BLEND ; 00053 static const unsigned long ENV_REPLACE ; 00054 static const unsigned long ENV_DECAL ; 00055 static const unsigned long ENV_MODULATE ; 00056 00057 static const unsigned long FORMAT_INTENSITY ; 00058 static const unsigned long FORMAT_LUMINANCE ; 00059 static const unsigned long FORMAT_LUMINANCE_ALPHA ; 00060 static const unsigned long FORMAT_ALPHA ; 00061 static const unsigned long FORMAT_RGB ; 00062 static const unsigned long FORMAT_RGBA ; 00063 00064 static const unsigned long FILTER_NEAREST ; 00065 static const unsigned long FILTER_LINEAR ; 00066 00067 public: 00068 Texture( const std::string &name ); 00069 virtual ~Texture(); 00070 00071 void putData ( unsigned char *data, const Teddy::Maths::IntVector2 &size, int format, unsigned long modify ); 00072 00073 void apply (); 00074 00075 bool isGood (); 00076 const Teddy::Maths::IntVector2 &getSize(); 00077 void setWrap ( int wrap_s, int wrap_t ); 00078 void setEnv ( int env ); 00079 void setEnv ( int env, const Color &c ); 00080 void setFilter ( int filter ); 00081 00082 public: 00083 bool doFormat (); 00084 bool doSize (); 00085 bool doBind (); 00086 void setWorkData ( void *data, bool alloc = true ); 00087 00088 void convert_to_a (); 00089 void convert_to_rgb (); 00090 void convert_rgba (); 00091 00092 void convert_rgb_to_a (); 00093 void convert_rgba_to_a (); 00094 void convert_a_to_rgb (); 00095 void convert_rgba_to_rgb(); 00096 void convert_rgb_to_rgba(); 00097 00098 protected: 00099 unsigned char *work_data; 00100 int work_data_pixel_format; 00101 bool work_data_allocated; 00102 bool is_good; 00103 Teddy::Maths::IntVector2 size; 00104 int wrap_s; 00105 int wrap_t; 00106 int filter_mode; 00107 int env_function; 00108 Color env_color; 00109 Teddy::MixIn::Options modify; 00110 int gl_internal_format; 00111 GLuint gl_texture_id; 00112 }; 00113 00114 00115 }; // namespace Graphics 00116 }; // namespace Teddy 00117 00118 00119 #endif // TEDDY__GRAPHICS__TEXTURE__H 00120