31 #define GL_BGRA 0x80E1
32 #define GL_UNSIGNED_BYTE_3_3_2 0x8032
33 #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
34 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
35 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
36 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
37 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
38 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
39 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
40 #define GL_UNSIGNED_INT_8_8_8_8 0x8035
41 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
42 #define GL_UNSIGNED_INT_10_10_10_2 0x8036
43 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
46#ifndef GL_COMPRESSED_ALPHA
47 #define GL_COMPRESSED_ALPHA 0x84E9
48 #define GL_COMPRESSED_LUMINANCE 0x84EA
49 #define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
50 #define GL_COMPRESSED_INTENSITY 0x84EC
51 #define GL_COMPRESSED_RGB 0x84ED
52 #define GL_COMPRESSED_RGBA 0x84EE
57#define GL_ABGR_EXT 0x8000
60#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
62 #define GL_GREEN 0x1904
63 #define GL_BLUE 0x1905
64 #define GL_DEPTH_COMPONENT 0x1902
67#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
68 #define GL_STENCIL_INDEX 0x1901
71#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) || defined(OSG_GL3_AVAILABLE)
72 #define GL_ALPHA4 0x803B
73 #define GL_ALPHA8 0x803C
74 #define GL_ALPHA12 0x803D
75 #define GL_ALPHA16 0x803E
76 #define GL_BITMAP 0x1A00
77 #define GL_COLOR_INDEX 0x1900
78 #define GL_INTENSITY12 0x804C
79 #define GL_INTENSITY16 0x804D
80 #define GL_INTENSITY 0x8049
81 #define GL_INTENSITY4 0x804A
82 #define GL_INTENSITY8 0x804B
83 #define GL_LUMINANCE12 0x8041
84 #define GL_LUMINANCE12_ALPHA4 0x8046
85 #define GL_LUMINANCE12_ALPHA12 0x8047
86 #define GL_LUMINANCE16 0x8042
87 #define GL_LUMINANCE16_ALPHA16 0x8048
88 #define GL_LUMINANCE4 0x803F
89 #define GL_LUMINANCE4_ALPHA4 0x8043
90 #define GL_LUMINANCE6_ALPHA2 0x8044
91 #define GL_LUMINANCE8 0x8040
92 #define GL_LUMINANCE8_ALPHA8 0x8045
93 #define GL_RGBA8 0x8058
94 #define GL_RGBA16 0x805B
95 #define GL_PACK_ROW_LENGTH 0x0D02
98#ifndef GL_PACK_SKIP_IMAGES
99 #define GL_PACK_SKIP_IMAGES 0x806B
100 #define GL_PACK_IMAGE_HEIGHT 0x806C
101 #define GL_UNPACK_SKIP_IMAGES 0x806D
102 #define GL_UNPACK_IMAGE_HEIGHT 0x806E
105#ifndef GL_OES_compressed_ETC1_RGB8_texture
106 #define GL_ETC1_RGB8_OES 0x8D64
109#ifndef GL_ARB_ES3_compatibility
110 #define GL_COMPRESSED_RGB8_ETC2 0x9274
111 #define GL_COMPRESSED_SRGB8_ETC2 0x9275
112 #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
113 #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
114 #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
115 #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
116 #define GL_COMPRESSED_R11_EAC 0x9270
117 #define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
118 #define GL_COMPRESSED_RG11_EAC 0x9272
119 #define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
122#ifndef GL_KHR_texture_compression_astc_hdr
123#define GL_KHR_texture_compression_astc_hdr 1
124#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
125#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
126#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
127#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
128#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
129#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
130#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
131#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
132#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
133#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
134#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
135#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
136#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
137#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
138#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
139#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
140#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
141#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
142#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
143#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
144#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
145#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
146#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
147#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
148#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
149#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
150#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
151#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
154#ifndef GL_DEPTH_COMPONENT
155#define GL_DEPTH_COMPONENT 0x1902
158#ifndef GL_VERSION_1_4
159#define GL_DEPTH_COMPONENT16 0x81A5
160#define GL_DEPTH_COMPONENT24 0x81A6
161#define GL_DEPTH_COMPONENT32 0x81A7
164#ifndef GL_DEPTH_COMPONENT32F
165#define GL_DEPTH_COMPONENT32F 0x8CAC
168#ifndef GL_DEPTH_COMPONENT32F_NV
169#define GL_DEPTH_COMPONENT32F_NV 0x8DAB
192 virtual const char*
className()
const {
return "Image"; }
198 virtual unsigned int getTotalDataSize()
const {
return getTotalSizeInBytesIncludingMipmaps(); }
204 inline const std::string&
getFileName()
const {
return _fileName; }
230 GLenum pixelFormat,GLenum type,
236 GLint internalTextureformat,
237 GLenum pixelFormat,GLenum type,
240 int packing=1,
int rowLength=0);
246 GLenum pixelFormat, GLenum type,
int packing=1);
252 virtual void readImageFromCurrentTexture(
unsigned int contextID,
bool copyMipMapsIfAvailable, GLenum type = GL_UNSIGNED_BYTE,
unsigned int face = 0);
261 virtual void scaleImage(
int s,
int t,
int r, GLenum newDataType);
291 inline int s()
const {
return _s; }
294 inline int t()
const {
return _t; }
297 inline int r()
const {
return _r; }
311 void setPacking(
unsigned int packing) { _packing = packing; }
324 inline unsigned int getPixelSizeInBits()
const {
return computePixelSizeInBits(_pixelFormat,_dataType); }
327 inline unsigned int getRowSizeInBytes()
const {
return computeRowWidthInBytes(_s,_pixelFormat,_dataType,_packing); }
331 inline unsigned int getRowStepInBytes()
const {
return computeRowWidthInBytes(_rowLength==0?_s:_rowLength,_pixelFormat,_dataType,_packing); }
347 bool valid()
const {
return _s!=0 && _t!=0 && _r!=0 && _data!=0 && _dataType!=0; }
352 inline unsigned char*
data() {
return _data; }
357 inline const unsigned char*
data()
const {
return _data; }
359 inline unsigned char*
data(
unsigned int column,
unsigned int row = 0,
unsigned int image = 0)
361 if (!_data)
return NULL;
362 return _data+(column*getPixelSizeInBits())/8+row*getRowStepInBytes()+image*getImageSizeInBytes();
365 inline const unsigned char*
data(
unsigned int column,
unsigned int row = 0,
unsigned int image = 0)
const
367 if (!_data)
return NULL;
368 return _data+(column*getPixelSizeInBits())/8+row*getRowStepInBytes()+image*getImageSizeInBytes();
386 bool valid()
const {
return _currentPtr!=0; }
389 const unsigned char*
data()
const {
return _currentPtr; }
392 unsigned int size()
const {
return _currentSize; }
453 static unsigned int computeImageSizeInBytes(
int width,
int height,
int depth, GLenum pixelFormat, GLenum type,
int packing = 1,
int slice_packing = 1,
int image_packing = 1);
461 inline bool isMipmap()
const {
return !_mipmapData.empty();};
465 return static_cast<unsigned int>(_mipmapData.size())+1;
477 else if (mipmapLevel < getNumMipmapLevels())
478 return _mipmapData[mipmapLevel-1];
484 return _data+getMipmapOffset(mipmapLevel);
489 return _data+getMipmapOffset(mipmapLevel);
553 for(DimensionsChangedCallbackVector::iterator i = _dimensionsChangedCallbacks.begin(); i != _dimensionsChangedCallbacks.end(); ++i)
555 (*i)->operator()(
this);
Definition BufferObject:495
const unsigned char * data() const
Definition Image:389
int _rowNum
Definition Image:400
int _imageNum
Definition Image:401
unsigned int _currentSize
Definition Image:404
DataIterator(const Image *image)
const osg::Image * _image
Definition Image:399
~DataIterator()
Definition Image:380
bool valid() const
Definition Image:386
DataIterator(const DataIterator &ri)
const unsigned char * _currentPtr
Definition Image:403
unsigned int size() const
Definition Image:392
unsigned int _mipmapNum
Definition Image:402
DimensionsChangedCallback()
Definition Image:536
virtual void operator()(osg::Image *image)=0
void setPixelBufferObject(PixelBufferObject *buffer)
Definition Image:499
bool valid() const
Definition Image:347
virtual const char * libraryName() const
Definition Image:191
virtual bool sendKeyEvent(int, bool)
Definition Image:529
virtual bool isSameKindAs(const Object *obj) const
Definition Image:190
virtual void readPixels(int x, int y, int width, int height, GLenum pixelFormat, GLenum type, int packing=1)
unsigned int getRowSizeInBytes() const
Definition Image:327
void setRowLength(int length)
virtual Object * clone(const CopyOp ©op) const
Definition Image:189
PixelBufferObject * getPixelBufferObject()
Definition Image:502
unsigned int getNumMipmapLevels() const
Definition Image:463
virtual void update(NodeVisitor *)
Definition Image:511
MipmapDataType _mipmapData
Definition Image:579
static bool isPackedType(GLenum type)
Origin
Definition Image:274
@ BOTTOM_LEFT
Definition Image:275
Vec4 getColor(unsigned int s, unsigned t=0, unsigned r=0) const
void removeDimensionsChangedCallback(DimensionsChangedCallback *cb)
int s() const
Definition Image:291
void setInternalTextureFormat(GLint internalFormat)
Vec4 getColor(const Vec2 &texcoord) const
Definition Image:411
void setMipmapLevels(const MipmapDataType &mipmapDataVector)
Definition Image:469
void setPacking(unsigned int packing)
Definition Image:311
const PixelBufferObject * getPixelBufferObject() const
Definition Image:505
int _r
Definition Image:564
unsigned int getImageStepInBytes() const
Definition Image:338
int t() const
Definition Image:294
WriteHint
Definition Image:206
@ NO_PREFERENCE
Definition Image:207
@ STORE_INLINE
Definition Image:208
unsigned char * data(unsigned int column, unsigned int row=0, unsigned int image=0)
Definition Image:359
virtual unsigned int getTotalDataSize() const
Definition Image:198
virtual bool sendFocusHint(bool)
Definition Image:523
void setDataType(GLenum dataType)
unsigned int getMipmapOffset(unsigned int mipmapLevel) const
Definition Image:473
AllocationMode getAllocationMode() const
Definition Image:225
void handleDimensionsChangedCallbacks()
Definition Image:551
virtual void readImageFromCurrentTexture(unsigned int contextID, bool copyMipMapsIfAvailable, GLenum type=GL_UNSIGNED_BYTE, unsigned int face=0)
static unsigned int computeImageSizeInBytes(int width, int height, int depth, GLenum pixelFormat, GLenum type, int packing=1, int slice_packing=1, int image_packing=1)
virtual void scaleImage(int s, int t, int r, GLenum newDataType)
virtual Object * cloneType() const
Definition Image:188
GLenum getDataType() const
Definition Image:309
int _rowLength
Definition Image:565
static GLenum computeFormatDataType(GLenum pixelFormat)
void setOrigin(Origin origin)
Definition Image:284
unsigned int getPacking() const
Definition Image:312
AllocationMode
Definition Image:215
@ NO_DELETE
Definition Image:216
@ USE_NEW_DELETE
Definition Image:217
static int computeNumberOfMipmapLevels(int s, int t=1, int r=1)
void ensureValidSizeForTexturing(GLint maxTextureSize)
unsigned int _packing
Definition Image:569
Origin getOrigin() const
Definition Image:287
virtual void copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image *source)
float getPixelAspectRatio() const
Definition Image:321
Image(const Image &image, const CopyOp ©op=CopyOp::SHALLOW_COPY)
void setData(unsigned char *data, AllocationMode allocationMode)
unsigned char * getMipmapData(unsigned int mipmapLevel)
Definition Image:482
static GLenum computePixelFormat(GLenum pixelFormat)
void setColor(const osg::Vec4 &color, unsigned int s, unsigned int t=0, unsigned int r=0)
unsigned int getTotalSizeInBytesIncludingMipmaps() const
static unsigned int computeNumComponents(GLenum pixelFormat)
unsigned int getTotalSizeInBytes() const
Definition Image:341
DimensionsChangedCallbackVector _dimensionsChangedCallbacks
Definition Image:581
virtual const GLvoid * getDataPointer() const
Definition Image:197
unsigned char * _data
Definition Image:573
bool isCompressed() const
virtual const osg::Image * asImage() const
Definition Image:195
static unsigned int computeBlockSize(GLenum pixelFormat, GLenum packing)
void setPixelAspectRatio(float pixelAspectRatio)
Definition Image:318
unsigned int getRowStepInBytes() const
Definition Image:331
virtual bool isImageTranslucent() const
Origin _origin
Definition Image:562
float _pixelAspectRatio
Definition Image:570
static unsigned int computePixelSizeInBits(GLenum pixelFormat, GLenum type)
WriteHint getWriteHint() const
Definition Image:213
const unsigned char * getMipmapData(unsigned int mipmapLevel) const
Definition Image:487
virtual bool sendPointerEvent(int, int, int)
Definition Image:526
void setColor(const osg::Vec4 &color, const osg::Vec2 &texcoord)
Definition Image:420
void setColor(const osg::Vec4 &color, const osg::Vec3 &texcoord)
virtual osg::Image * asImage()
Definition Image:194
const std::string & getFileName() const
Definition Image:204
void setPixelFormat(GLenum pixelFormat)
const MipmapDataType & getMipmapLevels() const
Definition Image:471
virtual void setFrameLastRendered(const osg::FrameStamp *)
Definition Image:532
virtual const char * className() const
Definition Image:192
bool supportsTextureSubloading() const
virtual void setImage(int s, int t, int r, GLint internalTextureformat, GLenum pixelFormat, GLenum type, unsigned char *data, AllocationMode mode, int packing=1, int rowLength=0)
const unsigned char * data(unsigned int column, unsigned int row=0, unsigned int image=0) const
Definition Image:365
std::string _fileName
Definition Image:559
virtual int compare(const Image &rhs) const
void setAllocationMode(AllocationMode mode)
Definition Image:222
unsigned int getImageSizeInBytes() const
Definition Image:334
static unsigned int computeRowWidthInBytes(int width, GLenum pixelFormat, GLenum type, int packing)
void setWriteHint(WriteHint writeHint)
Definition Image:212
GLint getInternalTextureFormat() const
Definition Image:303
static int computeNearestPowerOfTwo(int s, float bias=0.5f)
int r() const
Definition Image:297
void setFileName(const std::string &fileName)
std::vector< unsigned int > MipmapDataType
Definition Image:459
GLenum _dataType
Definition Image:568
unsigned char * data()
Definition Image:352
void scaleImage(int s, int t, int r)
Definition Image:258
GLint _internalTextureFormat
Definition Image:566
bool isMipmap() const
Definition Image:461
virtual bool requiresUpdateCall() const
Definition Image:508
int getRowLength() const
Definition Image:300
static int roudUpToMultiple(int s, int pack)
void addDimensionsChangedCallback(DimensionsChangedCallback *cb)
GLenum _pixelFormat
Definition Image:567
void swap(osg::Image &rhs)
GLenum getPixelFormat() const
Definition Image:306
static osg::Vec3i computeBlockFootprint(GLenum pixelFormat)
virtual void allocateImage(int s, int t, int r, GLenum pixelFormat, GLenum type, int packing=1)
const unsigned char * data() const
Definition Image:357
std::vector< osg::ref_ptr< DimensionsChangedCallback > > DimensionsChangedCallbackVector
Definition Image:540
Vec4 getColor(const Vec3 &texcoord) const
WriteHint _writeHint
Definition Image:560
AllocationMode _allocationMode
Definition Image:572
bool isDataContiguous() const
Definition Image:372
unsigned int getPixelSizeInBits() const
Definition Image:324
Definition NodeVisitor:82
Definition BufferObject:668
Definition StateAttribute:77
value_type & x()
Definition Vec2f:67
value_type & y()
Definition Vec2f:68
T * get() const
Definition ref_ptr:117
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
OSG_EXPORT Geode * createGeodeForImage(Image *image)
#define NULL
Definition osg/Export:55
#define OSG_EXPORT
Definition osg/Export:39