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"; }
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);
291 inline int s()
const {
return _s; }
294 inline int t()
const {
return _t; }
297 inline int r()
const {
return _r; }
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)
365 inline const unsigned char*
data(
unsigned int column,
unsigned int row = 0,
unsigned int image = 0)
const
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);
465 return static_cast<unsigned int>(
_mipmapData.size())+1;
555 (*i)->operator()(
this);
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Vec2f Vec2
Definition Vec2:21
Vec3f Vec3
Definition Vec3:21
OSG_EXPORT Geode * createGeodeForImage(Image *image)
Convenience function to be used by image loaders to generate a valid geode to return for readNode().
Vec4f Vec4
Definition Vec4:21
BufferObject * getBufferObject()
Definition BufferObject:529
BufferData()
Definition BufferObject:498
void setBufferObject(BufferObject *bufferObject)
Definition BufferObject:668
Deprecated.
Definition Callback:246
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Class which encapsulates the frame number, reference time and calendar time of specific frame,...
Definition FrameStamp:35
A Geode is a "geometry node", that is, a leaf node on the scene graph that can have "renderable thing...
Definition Geode:29
Image class for encapsulating the storage texture image data.
Definition Image:179
void setPixelBufferObject(PixelBufferObject *buffer)
Set the optional PixelBufferObject used to map the image memory efficiently to graphics memory.
Definition Image:499
bool valid() const
Return true if the Image represent a valid and usable imagery.
Definition Image:347
virtual const char * libraryName() const
return the name of the object's library.
Definition Image:191
virtual bool sendKeyEvent(int, bool)
Send key events to images that are acting as front ends to interactive surfaces such as a vnc or brow...
Definition Image:529
virtual bool isSameKindAs(const Object *obj) const
Definition Image:190
void flipHorizontal()
Flip the image horizontally, around s dimension.
virtual void readPixels(int x, int y, int width, int height, GLenum pixelFormat, GLenum type, int packing=1)
Read pixels from current frame buffer at specified position and size, using glReadPixels.
unsigned int getRowSizeInBytes() const
Return the number of bytes each row of pixels occupies once it has been packed.
Definition Image:327
void setRowLength(int length)
virtual Object * clone(const CopyOp ©op) const
Clone an object, with Object* return type.
Definition Image:189
PixelBufferObject * getPixelBufferObject()
Get the PixelBufferObject.
Definition Image:502
unsigned int getNumMipmapLevels() const
Definition Image:463
virtual void update(NodeVisitor *)
update method for osg::Image subclasses that update themselves during the update traversal.
Definition Image:511
MipmapDataType _mipmapData
Definition Image:579
static bool isPackedType(GLenum type)
Origin
Definition Image:274
@ TOP_LEFT
Definition Image:276
@ BOTTOM_LEFT
Definition Image:275
Vec4 getColor(unsigned int s, unsigned t=0, unsigned r=0) const
Get the color value for specified texcoord.
void removeDimensionsChangedCallback(DimensionsChangedCallback *cb)
int s() const
Width of image.
Definition Image:291
void setInternalTextureFormat(GLint internalFormat)
Vec4 getColor(const Vec2 &texcoord) const
Get the color value for specified texcoord.
Definition Image:411
void setMipmapLevels(const MipmapDataType &mipmapDataVector)
Send offsets into data.
Definition Image:469
void setPacking(unsigned int packing)
Definition Image:311
const PixelBufferObject * getPixelBufferObject() const
Get the const PixelBufferObject.
Definition Image:505
int _r
Definition Image:564
unsigned int getImageStepInBytes() const
Return the number of bytes between each successive image.
Definition Image:338
int t() const
Height of image.
Definition Image:294
WriteHint
Definition Image:206
@ NO_PREFERENCE
Definition Image:207
@ STORE_INLINE
Definition Image:208
@ EXTERNAL_FILE
Definition Image:209
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)
Hint whether to enable or disable focus to images acting as front ends to interactive surfaces such a...
Definition Image:523
void setDataType(GLenum dataType)
unsigned int getMipmapOffset(unsigned int mipmapLevel) const
Definition Image:473
AllocationMode getAllocationMode() const
Get the method used for deleting data once it goes out of scope.
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)
Read the contents of the current bound texture, handling compressed pixelFormats if present.
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)
Scale image to specified size and with specified data type.
virtual Object * cloneType() const
Clone the type of an object, with Object* return type.
Definition Image:188
GLenum getDataType() const
Definition Image:309
int _rowLength
Definition Image:565
static GLenum computeFormatDataType(GLenum pixelFormat)
void setOrigin(Origin origin)
Set the origin of the image.
Definition Image:284
unsigned int getPacking() const
Definition Image:312
AllocationMode
Definition Image:215
@ NO_DELETE
Definition Image:216
@ USE_MALLOC_FREE
Definition Image:218
@ USE_NEW_DELETE
Definition Image:217
static int computeNumberOfMipmapLevels(int s, int t=1, int r=1)
void ensureValidSizeForTexturing(GLint maxTextureSize)
Ensure image dimensions are a power of two.
int _t
Definition Image:564
unsigned int _packing
Definition Image:569
Origin getOrigin() const
Get the origin of the image.
Definition Image:287
virtual void copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image *source)
Copy a source Image into a subpart of this Image at specified position.
float getPixelAspectRatio() const
Get the pixel aspect ratio.
Definition Image:321
Image(const Image &image, const CopyOp ©op=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs 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)
Set the color value for specified texcoord.
unsigned int getTotalSizeInBytesIncludingMipmaps() const
Return the number of bytes the whole row/image/volume of pixels occupies, including all mip maps if i...
static unsigned int computeNumComponents(GLenum pixelFormat)
unsigned int getTotalSizeInBytes() const
Return the number of bytes the whole row/image/volume of pixels occupies.
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
Return true of the pixel format is an OpenGL compressed pixel format.
virtual const osg::Image * asImage() const
Convert 'this' into a Image pointer if Object is a Image, otherwise return 0.
Definition Image:195
static unsigned int computeBlockSize(GLenum pixelFormat, GLenum packing)
return the size in bytes of a block of compressed pixels
void setPixelAspectRatio(float pixelAspectRatio)
Set the pixel aspect ratio, defined as the pixel width divided by the pixel height.
Definition Image:318
unsigned int getRowStepInBytes() const
Return the number of bytes between each successive row.
Definition Image:331
virtual bool isImageTranslucent() const
Return true if this image is translucent - i.e.
int _s
Definition Image:564
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)
Send pointer events to images that are acting as front ends to interactive surfaces such as a vnc or ...
Definition Image:526
void setColor(const osg::Vec4 &color, const osg::Vec2 &texcoord)
Set the color value for specified texcoord.
Definition Image:420
void setColor(const osg::Vec4 &color, const osg::Vec3 &texcoord)
Set the color value for specified texcoord.
virtual osg::Image * asImage()
Convert 'this' into a Image pointer if Object is a Image, otherwise return 0.
Definition Image:194
const std::string & getFileName() const
Definition Image:204
void setPixelFormat(GLenum pixelFormat)
void flipDepth()
Flip the image around the r dimension.
void flipVertical()
Flip the image vertically, around t dimension.
const MipmapDataType & getMipmapLevels() const
Definition Image:471
virtual void setFrameLastRendered(const osg::FrameStamp *)
Pass frame information to the custom Image classes, to be called only when objects associated with im...
Definition Image:532
virtual const char * className() const
return the name of the object's class type.
Definition Image:192
bool supportsTextureSubloading() const
returns false for texture formats that do not support texture subloading
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)
Set the image dimensions, format and data.
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
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
void setAllocationMode(AllocationMode mode)
Set the method used for deleting data once it goes out of scope.
Definition Image:222
unsigned int getImageSizeInBytes() const
Return the number of bytes each image (_s*_t) of pixels occupies.
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
Depth of image.
Definition Image:297
void setFileName(const std::string &fileName)
std::vector< unsigned int > MipmapDataType
Precomputed mipmaps stuff.
Definition Image:459
GLenum _dataType
Definition Image:568
unsigned char * data()
Raw image data.
Definition Image:352
void scaleImage(int s, int t, int r)
Scale image to specified size.
Definition Image:258
GLint _internalTextureFormat
Definition Image:566
bool isMipmap() const
Definition Image:461
virtual bool requiresUpdateCall() const
Return whether the update(NodeVisitor* nv) should be required on each frame to enable proper working ...
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)
swap the data and settings between two image objects.
GLenum getPixelFormat() const
Definition Image:306
static osg::Vec3i computeBlockFootprint(GLenum pixelFormat)
return the dimensions of a block of compressed pixels
virtual void allocateImage(int s, int t, int r, GLenum pixelFormat, GLenum type, int packing=1)
Allocate a pixel block of specified size and type.
const unsigned char * data() const
Raw const image data.
Definition Image:357
std::vector< osg::ref_ptr< DimensionsChangedCallback > > DimensionsChangedCallbackVector
Definition Image:540
Vec4 getColor(const Vec3 &texcoord) const
Get the color value for specified texcoord.
WriteHint _writeHint
Definition Image:560
AllocationMode _allocationMode
Definition Image:572
bool isDataContiguous() const
return true if the data stored in the image is a contiguous block of data.
Definition Image:372
unsigned int getPixelSizeInBits() const
Return the number of bits required for each pixel.
Definition Image:324
const unsigned char * data() const
data pointer of current block to copy.
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
is iterator valid.
Definition Image:386
DataIterator(const DataIterator &ri)
const unsigned char * _currentPtr
Definition Image:403
unsigned int size() const
Size of current block to copy.
Definition Image:392
unsigned int _mipmapNum
Definition Image:402
Convenience update callback class that can be attached to a StateAttribute (such as Textures) to ensu...
Definition Image:518
DimensionsChangedCallback()
Definition Image:536
virtual void operator()(osg::Image *image)=0
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Base class for providing reference counted objects.
Definition Referenced:44
Base class for state attributes.
Definition StateAttribute:77
value_type & x()
Definition Vec2f:67
value_type & y()
Definition Vec2f:68
General purpose integer triple.
Definition Vec3i:22
#define NULL
Definition Export:55
#define OSG_EXPORT
Definition Export:39