00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SBRASTERIMAGE_
00025 #define _SBRASTERIMAGE_
00026
00027
00028 #include <SoDeprecationRules.h>
00029 #include <Inventor/SbLinear.h>
00030 #include <Inventor/sys/SoGLType.h>
00031 #include <Inventor/SbDataType.h>
00032 #include <Inventor/devices/SoBufferObject.h>
00033
00034 #ifdef _WIN32
00035 #pragma warning(push)
00036 #pragma warning(disable:4251)
00037 #endif
00038
00055 class INVENTOR SbRasterImage {
00056
00057
00058 public:
00059
00063 enum Components {
00067 UNKNOWN = -1,
00068
00072 LUMINANCE = 1,
00073
00077 LUMINANCE_TRANSPARENCY = 2,
00078
00082 RGB = 3,
00083
00087 RGB_TRANSPARENCY = 4,
00088
00093 RGBE = 5
00094 };
00095
00096
00100 enum CopyPolicy {
00104 COPY = 0,
00108 NO_COPY = 1,
00113 NO_COPY_AND_DELETE = 2,
00118 NO_COPY_AND_FREE = 3
00119 };
00120
00121
00125 SbRasterImage();
00126
00160 SbRasterImage( const SbVec2i32 &size, Components components,
00161 SoBufferObject* bufferObject );
00162
00166 virtual ~SbRasterImage();
00167
00175 void setSize(const SbVec2s& size);
00176
00182 void setSize_i32(const SbVec2i32& size);
00183
00187 SbVec2s getSize() const;
00188
00192 SbVec2i32 getSize_i32() const;
00193
00198 void setComponents(SbRasterImage::Components comp);
00199
00204 SbRasterImage::Components getComponents() const;
00205
00212 int getComponentsSize() const;
00213
00220 int getComponentsCount() const;
00221
00255 void setBuffer(SoBufferObject* bufferObject);
00256
00275 SoBufferObject* getBufferObject() const;
00276
00281 int getNumMipmaps() {return m_numMipmaps;};
00282
00286 CopyPolicy getCopyPolicy() const;
00287
00296 SbBool removeAlphaChannel();
00297
00298 #if 1 SoDEPRECATED
00303 SbRasterImage( const SbVec2s &size, Components components,
00304 const unsigned char *bytes, CopyPolicy copy=COPY );SoDEPRECATED
00309 SbRasterImage( const SbVec2i32 &size, Components components,
00310 const unsigned char *bytes, CopyPolicy copy=COPY );
00311 SoDEPRECATED
00320 void setBuffer(unsigned char* buffer, CopyPolicy copy = COPY);
00321 SoDEPRECATED
00328 unsigned char* getBuffer() const;
00329
00330 #endif
00332 private:
00333
00334 #if 1 SoDEPRECATED
00339 SbRasterImage( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
00340 const void *bytes, CopyPolicy copy=COPY );
00341
00342 #endif
00347 SbRasterImage( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
00348 SoBufferObject* bufferObject );
00349
00350
00351 void setNumMipmaps(int nmm) {m_numMipmaps = nmm;};
00352
00353 void setDataType(SbDataType::DataType dataType) {m_dataType = dataType;};
00354 SbDataType::DataType getDataType() {return m_dataType;};
00355
00356 void setCompressedInternalFormat(GLenum intFormat) {m_compressedInternalFormat = intFormat;};
00357 GLenum getCompressedInternalFormat() {return m_compressedInternalFormat;};
00358
00359 private:
00360
00364 int getDataTypeSizeInBytes() const;
00365
00366 private:
00367
00368 void commonConstructor( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
00369 SoBufferObject* bufferObject );
00370
00371 SbVec2i32 m_size;
00372 Components m_components;
00377 mutable unsigned char* m_buffer;
00381 SoRef<SoBufferObject> m_bufferObject;
00385 mutable SoRef<SoCpuBufferObject> m_cpuBufferObject;
00386 CopyPolicy m_copy;
00387 int m_numMipmaps;
00388 GLenum m_compressedInternalFormat;
00389
00390 SbDataType::DataType m_dataType;
00391 };
00392
00393 #ifdef _WIN32
00394 #pragma warning(pop)
00395 #endif
00396
00397 inline SbRasterImage::CopyPolicy
00398 SbRasterImage::getCopyPolicy() const
00399 {
00400 return m_copy;
00401 }
00402
00403 #endif
00404
00405
00406