00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _SO_TEXTURE_IMAGE_ELEMENT_BASE
00023 #define _SO_TEXTURE_IMAGE_ELEMENT_BASE
00024
00025 #if defined(_WIN32)
00026 #pragma warning( push )
00027 #pragma warning( disable: 4251 ) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
00028 #endif
00029
00030 #define MAX_TEXTURE_NBR 6
00031
00032
00033
00034 #include <Inventor/SbColor.h>
00035 #include <Inventor/elements/SoReplacedTextureElement.h>
00036 #include <Inventor/fields/SoSFImage.h>
00037 #include <Inventor/SbPImpl.h>
00038
00039 #ifndef GL_TEXTURE_CUBE_MAP
00040 #define GL_TEXTURE_CUBE_MAP 0x8513
00041 #endif
00042 #ifndef GL_TEXTURE_2D
00043 #define GL_TEXTURE_2D 0x0DE1
00044 #endif
00045
00046
00047 class SoRenderToTextureProperty;
00048 class SoBufferObject;
00049 class SoGLTexture;
00050
00051 SO_PIMPL_BASE_PUBLIC_DECLARATION(SoTextureImageElementBase)
00052
00053
00066 SoEXTENDER_Documented class SoTextureImageElementBase : public SoReplacedTextureElement
00067 {
00068 SO_PIMPL_BASE_PUBLIC_HEADER(SoTextureImageElementBase);
00069
00070 SO_ELEMENT_ABSTRACT_HEADER(SoTextureImageElementBase);
00071
00072 public:
00073
00075 enum Target {
00077 TEXTURE2D = GL_TEXTURE_2D,
00079 TEXTURECUBEMAP = GL_TEXTURE_CUBE_MAP
00080 };
00081
00085 virtual void print(FILE *fp) const;
00086
00090 virtual void push(SoState *state) ;
00091
00092 private:
00094 virtual void commonInit();
00095
00097 virtual void init(SoState *state);
00098
00099 private:
00100
00101 static void initClass();
00102 static void exitClass();
00103
00104 SoTextureImageElementBase::Target getTargetTexture(){return m_target;}
00105
00106
00107
00108 struct SoTexImageData
00109 {
00110
00111 SoTexImageData();
00112
00114 static int getAutoMagFilter(float quality);
00115 static int getAutoMinFilter(float quality);
00116 static int getAutoMinFilter3D(float quality);
00117 bool isUsingMipmaps() const;
00118
00119 SoGLTexture* texture;
00120
00121 SbVec3i32 size;
00122 int numComponents;
00123 const void* buffer[MAX_TEXTURE_NBR];
00124 SoBufferObject* bufferObjects[MAX_TEXTURE_NBR];
00125 int wrapS, wrapT,wrapR, model;
00126 SbColor blendColor;
00127 int currentTexture;
00128 bool fistPassForCubeMap;
00129 float maxAnisotropy;
00130 bool enableBorder;
00131 SbVec4f borderColor;
00132 int minFilter;
00133 int magFilter;
00134
00135 SoSFImage::DataType dataType;
00136 GLint GLInternalFormat;
00137 SoRenderToTextureProperty* renderToTextureProperty;
00138 bool renderToTexturePropertyFirstPass;
00139
00140
00141 int hasTransparency;
00142 bool isCompressed;
00143 int numCompressedMipmaps;
00144 float quality;
00145
00147 int textureName;
00148 SbVec3i32 subSize;
00149 int xoffset, yoffset, zoffset;
00150 const void* subBytes ;
00151 bool isUsingFakeGLTexture;
00152 };
00153
00154 private:
00155 SoTextureImageElementBase::Target m_target;
00156
00157 SbBool hasTransparency(SoState *state, int unit) const;
00158 void getElt(SoState *state, int &_minFilter,int &_magFilter, float &_maxAnisotropy, int unit) const;
00159
00160 const void * getElt(SoState *state, SbVec2i32 &_size,
00161 int &_numComponents, SoSFImage::DataType &_dataType,
00162 GLint &_GLInternalFormat, int &_wrapS, int &_wrapT,
00163 int &_model, SbColor &_blendColor, int unit) const;
00164
00165 virtual void setElt(const SbVec2i32 &s, int nc,
00166 const void *buffer, SoBufferObject* bufferObject, SoSFImage::DataType dataType,
00167 GLint GLInternalFormat, SoRenderToTextureProperty* renderToTex,
00168 int wrapS, int wrapT, int wrapR, int model,
00169 const SbColor &blendColor, float _maxAnisotropy,
00170 SbBool _enableBorder, const SbVec4f &_borderColor,
00171 SbBool isCompressed, int numCompressedMipmaps,
00172 int hasTransparency = -1 ,
00173 int unit=0, int currentTexture=-1);
00174
00175 virtual void setSubElt(const SbVec2i32 &subSize,
00176 int xoffset, int yoffset,
00177 const void *buffer, int texname,
00178 int unit=0);
00179
00180 virtual void setFilterElt(int _minFilter, int _magFilter, int currUnit);
00181
00182
00183 virtual ~SoTextureImageElementBase();
00184
00185
00186 SoTexImageData& getTexImageData(const int unit) const;
00187
00188
00189
00190 typedef std::vector<SoTexImageData> SoTexImageDataList;
00191 mutable SoTexImageDataList m_texImageDataList;
00192
00193 friend class SoVRMLAppearance;
00194 friend class SoGLTextureImageElementImpl;
00195 };
00196
00197 #if defined(_WIN32)
00198 #pragma warning( pop )
00199 #endif
00200
00201 #endif
00202
00203
00204