00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __SGL_TEXTURE_2D_HPP
00026 #define __SGL_TEXTURE_2D_HPP
00027
00028 #include <sgl.h>
00029 #include <vector>
00030 #include <sglObject.hpp>
00031 #include <sglVector.hpp>
00032 #include <sglTexture.hpp>
00033
00034
00035
00039 class SGL_DLL_API sglTexture2D : public sglTexture
00040 {
00041 public:
00043 sglTexture2D();
00045 virtual ~sglTexture2D();
00046
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 bool setImage(void *image, ExternalFormatEnum format, TypeEnum type,
00062 unsigned int num_s, unsigned int num_t,
00063 bool border = false);
00065 void getImage(void *&image, ExternalFormatEnum &format, TypeEnum &type,
00066 unsigned int &num_s, unsigned int &num_t,
00067 bool &border) const;
00068
00073 bool setMipmapLevels(const vector<void *> &images);
00074
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 bool subloadImage(void *sub_image,
00086 GLint level,
00087 GLint offset_x, GLint offset_y,
00088 GLint width, GLint height);
00089
00095 virtual bool replaceImage(void *new_image, GLint level = 0);
00096
00098 inline void getSize(unsigned int &width, unsigned int &height) const
00099 {
00100 width = m_width; height = m_height;
00101 }
00102
00106 virtual unsigned int getIdealInternalSize() const;
00111 virtual unsigned int getLikelyInternalSize() const;
00112
00114 void setWrapMode(WrapEnum s_repeat_flag, WrapEnum t_repeat_flag);
00116 void getWrapMode(WrapEnum &s_repeat_flag, WrapEnum &t_repeat_flag) const;
00117
00123 virtual bool checkProxy();
00124
00130 virtual void bind();
00131
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 bool copyTexSubImage(GLint level,
00146 GLint offset_x, GLint offset_y,
00147 GLint win_x, GLint win_y,
00148 GLint width, GLint height);
00149
00155 virtual bool buildMipmaps(vector<void*> &mipmaps);
00156
00172 static bool resizeImage(sglTexture::ExternalFormatEnum format,
00173 sglTexture::TypeEnum type,
00174 unsigned int old_s, unsigned int old_t,
00175 bool border,
00176 unsigned int new_s, unsigned int new_t,
00177 void *old_image, void *&new_image);
00178
00194 static bool halveImage(sglTexture::ExternalFormatEnum format,
00195 sglTexture::TypeEnum type,
00196 unsigned int &num_s, unsigned int &num_t,
00197 bool border,
00198 void *old_image, void *&new_image);
00199
00200
00201 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00202
00203 private:
00204 sglTexture2D(const sglTexture2D&);
00205 sglTexture2D& operator=(const sglTexture2D &);
00206
00207
00208 unsigned int getNumTexels() const;
00209
00210
00211 struct SubloadImageStruct
00212 {
00213 SubloadImageStruct(void* sub_image,
00214 GLint level,
00215 GLint offset_x, GLint offset_y,
00216 GLint width, GLint height)
00217 : m_sub_image(sub_image), m_level(level),
00218 m_offset_x(offset_x), m_offset_y(offset_y),
00219 m_width(width), m_height(height) {};
00220
00221 void *m_sub_image;
00222 GLint m_level;
00223 GLint m_offset_x, m_offset_y;
00224 GLint m_width, m_height;
00225 };
00226
00227 private:
00228 unsigned int m_width, m_height;
00229 GLint m_repeat_flag[2];
00230 GLint m_pow_s, m_pow_t;
00231
00232 vector <SubloadImageStruct*> m_subload_list;
00233 };
00234
00235 #endif