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