Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __TEXTURE_H__
00019 #define __TEXTURE_H__
00020
00021 #ifdef _WIN32
00022 #ifndef WIN32_LEAN_AND_MEAN
00023 #define WIN32_LEAN_AND_MEAN
00024 #endif // WIN32_LEAN_AND_MEAN
00025 #include <windows.h>
00026 #endif // _WIN32
00027
00028 #include <GL/gl.h>
00029 #include <memory>
00030 #include <stdexcept>
00031 #include <string>
00032 #include <vector>
00033 #include <map>
00034
00035 #include "Image.h"
00036
00037 using std::string;
00038 using std::vector;
00039 using std::map;
00040 using std::auto_ptr;
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 class Texture
00065 {
00066 public:
00067
00068 Texture ();
00069 virtual ~Texture ();
00070
00071 public:
00072
00073 enum {
00074
00075 kDefault = 0,
00076
00077
00078 kCompress = (1 << 0),
00079 };
00080
00081 typedef int TextureFlags;
00082
00083 public:
00084
00085 void bind () const;
00086 bool fail () const { return _fail; }
00087 bool stdCoordSystem () const { return _standardCoordSystem; }
00088
00089
00090 const string &name () const { return _name; }
00091 GLuint handle () const { return _handle; }
00092
00093 virtual GLenum target () const = 0;
00094
00095 private:
00096
00097
00098
00099
00100 Texture (const Texture &);
00101 Texture &operator= (const Texture &);
00102
00103 protected:
00104
00105 GLubyte *loadImageFile (const string &filename);
00106 GLint getCompressionFormat (GLint internalFormat);
00107 GLint getInternalFormat (GLint components);
00108
00109 protected:
00110
00111 string _name;
00112 GLuint _handle;
00113
00114 TextureFlags _flags;
00115 bool _standardCoordSystem;
00116 bool _fail;
00117 };
00118
00119
00120
00121
00122
00123
00124
00125
00126 class Texture2D : public Texture
00127 {
00128 public:
00129
00130 Texture2D (const string &filename, TextureFlags flags = kDefault);
00131 Texture2D (const Image *img, TextureFlags flags = kDefault);
00132
00133 protected:
00134
00135 Texture2D ();
00136
00137
00138 virtual void create (const Image *img, TextureFlags flags);
00139
00140 public:
00141
00142 virtual GLenum target () const { return GL_TEXTURE_2D; }
00143 };
00144
00145 #endif // __TEXTURE_H__