openscenegraph
Image
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_IMAGE
15#define OSG_IMAGE 1
16
17#include <osg/BufferObject>
18#include <osg/Vec2>
19#include <osg/Vec3>
20#include <osg/Vec3i>
21#include <osg/Vec4>
22#include <osg/FrameStamp>
23#include <osg/StateAttribute>
24
25#include <string>
26#include <vector>
27
28#ifndef GL_VERSION_1_2
29 // 1.2 definitions...
30 #define GL_BGR 0x80E0
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
44#endif
45
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
53#endif
54
55
56#ifndef GL_ABGR_EXT
57#define GL_ABGR_EXT 0x8000
58#endif
59
60#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
61 #define GL_RED 0x1903
62 #define GL_GREEN 0x1904
63 #define GL_BLUE 0x1905
64 #define GL_DEPTH_COMPONENT 0x1902
65#endif
66
67#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
68 #define GL_STENCIL_INDEX 0x1901
69#endif
70
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
96#endif
97
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
103#endif
104
105#ifndef GL_OES_compressed_ETC1_RGB8_texture
106 #define GL_ETC1_RGB8_OES 0x8D64
107#endif
108
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
120#endif
121
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
152#endif /* GL_KHR_texture_compression_astc_hdr */
153
154#ifndef GL_DEPTH_COMPONENT
155#define GL_DEPTH_COMPONENT 0x1902
156#endif
157
158#ifndef GL_VERSION_1_4
159#define GL_DEPTH_COMPONENT16 0x81A5
160#define GL_DEPTH_COMPONENT24 0x81A6
161#define GL_DEPTH_COMPONENT32 0x81A7
162#endif
163
164#ifndef GL_DEPTH_COMPONENT32F
165#define GL_DEPTH_COMPONENT32F 0x8CAC
166#endif
167
168#ifndef GL_DEPTH_COMPONENT32F_NV
169#define GL_DEPTH_COMPONENT32F_NV 0x8DAB
170#endif
171
172namespace osg {
173
174// forward declare
175class NodeVisitor;
176
179{
180
181 public :
182
184
186 Image(const Image& image,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
187
188 virtual Object* cloneType() const { return new Image(); }
189 virtual Object* clone(const CopyOp& copyop) const { return new Image(*this,copyop); }
190 virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Image*>(obj)!=0; }
191 virtual const char* libraryName() const { return "osg"; }
192 virtual const char* className() const { return "Image"; }
193
194 virtual osg::Image* asImage() { return this; }
195 virtual const osg::Image* asImage() const { return this; }
196
197 virtual const GLvoid* getDataPointer() const { return data(); }
198 virtual unsigned int getTotalDataSize() const { return getTotalSizeInBytesIncludingMipmaps(); }
199
201 virtual int compare(const Image& rhs) const;
202
203 void setFileName(const std::string& fileName);
204 inline const std::string& getFileName() const { return _fileName; }
205
209 EXTERNAL_FILE
210 };
211
212 void setWriteHint(WriteHint writeHint) { _writeHint = writeHint; }
213 WriteHint getWriteHint() const { return _writeHint; }
214
218 USE_MALLOC_FREE
219 };
220
222 void setAllocationMode(AllocationMode mode) { _allocationMode = mode; }
223
225 AllocationMode getAllocationMode() const { return _allocationMode; }
226
227
229 virtual void allocateImage(int s,int t,int r,
230 GLenum pixelFormat,GLenum type,
231 int packing=1);
232
233
235 virtual void setImage(int s,int t,int r,
236 GLint internalTextureformat,
237 GLenum pixelFormat,GLenum type,
238 unsigned char* data,
239 AllocationMode mode,
240 int packing=1, int rowLength=0);
241
245 virtual void readPixels(int x,int y,int width,int height,
246 GLenum pixelFormat, GLenum type, int packing=1);
247
248
252 virtual void readImageFromCurrentTexture(unsigned int contextID, bool copyMipMapsIfAvailable, GLenum type = GL_UNSIGNED_BYTE, unsigned int face = 0);
253
255 void swap(osg::Image& rhs);
256
258 void scaleImage(int s,int t,int r) { scaleImage(s,t,r, getDataType()); }
259
261 virtual void scaleImage(int s,int t,int r, GLenum newDataType);
262
270 virtual void copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image* source);
271
272
274 {
276 TOP_LEFT
277 };
278
284 void setOrigin(Origin origin) { _origin = origin; }
285
287 Origin getOrigin() const { return _origin; }
288
289
291 inline int s() const { return _s; }
292
294 inline int t() const { return _t; }
295
297 inline int r() const { return _r; }
298
299 void setRowLength(int length);
300 inline int getRowLength() const { return _rowLength; }
301
302 void setInternalTextureFormat(GLint internalFormat);
303 inline GLint getInternalTextureFormat() const { return _internalTextureFormat; }
304
305 void setPixelFormat(GLenum pixelFormat);
306 inline GLenum getPixelFormat() const { return _pixelFormat; }
307
308 void setDataType(GLenum dataType);
309 inline GLenum getDataType() const { return _dataType; }
310
311 void setPacking(unsigned int packing) { _packing = packing; }
312 inline unsigned int getPacking() const { return _packing; }
313
315 bool isCompressed() const;
316
318 inline void setPixelAspectRatio(float pixelAspectRatio) { _pixelAspectRatio = pixelAspectRatio; }
319
321 inline float getPixelAspectRatio() const { return _pixelAspectRatio; }
322
324 inline unsigned int getPixelSizeInBits() const { return computePixelSizeInBits(_pixelFormat,_dataType); }
325
327 inline unsigned int getRowSizeInBytes() const { return computeRowWidthInBytes(_s,_pixelFormat,_dataType,_packing); }
328
331 inline unsigned int getRowStepInBytes() const { return computeRowWidthInBytes(_rowLength==0?_s:_rowLength,_pixelFormat,_dataType,_packing); }
332
334 inline unsigned int getImageSizeInBytes() const { return getRowSizeInBytes()*_t; }
335
338 inline unsigned int getImageStepInBytes() const { return getRowStepInBytes()*_t; }
339
341 inline unsigned int getTotalSizeInBytes() const { return getImageSizeInBytes()*_r; }
342
345
347 bool valid() const { return _s!=0 && _t!=0 && _r!=0 && _data!=0 && _dataType!=0; }
348
352 inline unsigned char* data() { return _data; }
353
357 inline const unsigned char* data() const { return _data; }
358
359 inline unsigned char* data(unsigned int column, unsigned int row = 0, unsigned int image = 0)
360 {
361 if (!_data) return NULL;
362 return _data+(column*getPixelSizeInBits())/8+row*getRowStepInBytes()+image*getImageSizeInBytes();
363 }
364
365 inline const unsigned char* data(unsigned int column, unsigned int row = 0, unsigned int image = 0) const
366 {
367 if (!_data) return NULL;
368 return _data+(column*getPixelSizeInBits())/8+row*getRowStepInBytes()+image*getImageSizeInBytes();
369 }
370
372 bool isDataContiguous() const { return _rowLength==0 || _rowLength==_s; }
373
376 {
377 public:
378 DataIterator(const Image* image);
381
383 void operator ++ ();
384
386 bool valid() const { return _currentPtr!=0; }
387
389 const unsigned char* data() const { return _currentPtr; }
390
392 unsigned int size() const { return _currentSize; }
393
394 protected:
395
396
397 void assign();
398
402 unsigned int _mipmapNum;
403 const unsigned char* _currentPtr;
404 unsigned int _currentSize;
405 };
406
408 Vec4 getColor(unsigned int s,unsigned t=0,unsigned r=0) const;
409
411 Vec4 getColor(const Vec2& texcoord) const { return getColor(Vec3(texcoord.x(),texcoord.y(),0.0f)); }
412
414 Vec4 getColor(const Vec3& texcoord) const;
415
417 void setColor(const osg::Vec4& color, unsigned int s, unsigned int t=0, unsigned int r=0);
418
420 void setColor(const osg::Vec4& color, const osg::Vec2& texcoord ) { setColor(color, osg::Vec3(texcoord, 0.0f)); }
421
423 void setColor(const osg::Vec4& color, const osg::Vec3& texcoord );
424
427
430
432 void flipDepth();
433
439 void ensureValidSizeForTexturing(GLint maxTextureSize);
440
441 static bool isPackedType(GLenum type);
442 static GLenum computePixelFormat(GLenum pixelFormat);
443 static GLenum computeFormatDataType(GLenum pixelFormat);
444
446 static osg::Vec3i computeBlockFootprint(GLenum pixelFormat);
447
449 static unsigned int computeBlockSize(GLenum pixelFormat, GLenum packing);
450 static unsigned int computeNumComponents(GLenum pixelFormat);
451 static unsigned int computePixelSizeInBits(GLenum pixelFormat,GLenum type);
452 static unsigned int computeRowWidthInBytes(int width,GLenum pixelFormat,GLenum type,int packing);
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);
454 static int roudUpToMultiple(int s, int pack);
455 static int computeNearestPowerOfTwo(int s,float bias=0.5f);
456 static int computeNumberOfMipmapLevels(int s,int t = 1, int r = 1);
457
459 typedef std::vector< unsigned int > MipmapDataType;
460
461 inline bool isMipmap() const {return !_mipmapData.empty();};
462
463 unsigned int getNumMipmapLevels() const
464 {
465 return static_cast<unsigned int>(_mipmapData.size())+1;
466 };
467
469 inline void setMipmapLevels(const MipmapDataType& mipmapDataVector) { _mipmapData = mipmapDataVector; }
470
471 inline const MipmapDataType& getMipmapLevels() const { return _mipmapData; }
472
473 inline unsigned int getMipmapOffset(unsigned int mipmapLevel) const
474 {
475 if(mipmapLevel == 0)
476 return 0;
477 else if (mipmapLevel < getNumMipmapLevels())
478 return _mipmapData[mipmapLevel-1];
479 return 0;
480 };
481
482 inline unsigned char* getMipmapData(unsigned int mipmapLevel)
483 {
484 return _data+getMipmapOffset(mipmapLevel);
485 }
486
487 inline const unsigned char* getMipmapData(unsigned int mipmapLevel) const
488 {
489 return _data+getMipmapOffset(mipmapLevel);
490 }
491
494
496 virtual bool isImageTranslucent() const;
497
499 void setPixelBufferObject(PixelBufferObject* buffer) { setBufferObject(buffer); }
500
502 PixelBufferObject* getPixelBufferObject() { return dynamic_cast<PixelBufferObject*>(getBufferObject()); }
503
505 const PixelBufferObject* getPixelBufferObject() const { return dynamic_cast<const PixelBufferObject*>(getBufferObject()); }
506
508 virtual bool requiresUpdateCall() const { return false; }
509
511 virtual void update(NodeVisitor* /*nv*/) {}
512
518 {
519 virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
520 };
521
523 virtual bool sendFocusHint(bool /*focus*/) { return false; }
524
526 virtual bool sendPointerEvent(int /*x*/, int /*y*/, int /*buttonMask*/) { return false; }
527
529 virtual bool sendKeyEvent(int /*key*/, bool /*keyDown*/) { return false; }
530
532 virtual void setFrameLastRendered(const osg::FrameStamp* /*frameStamp*/) {}
533
535 public:
537 virtual void operator()(osg::Image* image) = 0;
538 };
539
540 typedef std::vector< osg::ref_ptr<DimensionsChangedCallback> > DimensionsChangedCallbackVector;
541
544
545 protected :
546
547 virtual ~Image();
548
549 Image& operator = (const Image&) { return *this; }
550
552 {
553 for(DimensionsChangedCallbackVector::iterator i = _dimensionsChangedCallbacks.begin(); i != _dimensionsChangedCallbacks.end(); ++i)
554 {
555 (*i)->operator()(this);
556 }
557 }
558
559 std::string _fileName;
561
563
564 int _s, _t, _r;
568 GLenum _dataType;
569 unsigned int _packing;
571
573 unsigned char* _data;
574
576
577 void setData(unsigned char* data,AllocationMode allocationMode);
578
580
582};
583
584class Geode;
585
591
592template<class T> Geode* createGeodeForImage(const ref_ptr<T>& image) { return createGeodeForImage(image.get()); }
593
594
599extern OSG_EXPORT Geode* createGeodeForImage(Image* image, float s, float t);
600
601template<class T> Geode* createGeodeForImage(const ref_ptr<T>& image, float s, float t) { return createGeodeForImage(image.get(), s, t); }
602
603}
604
605#endif // __SG_IMAGE_H
Definition BufferObject:495
Definition CopyOp:41
Definition FrameStamp:35
Definition Geode:29
Definition Image:376
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
Definition Image:179
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
void deallocateData()
void flipHorizontal()
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 &copyop) 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 &copyop=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)
virtual ~Image()
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)
void flipDepth()
void flipVertical()
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 Object:61
Definition BufferObject:668
Definition Referenced:44
Definition Callback:246
Definition StateAttribute:77
Definition Vec2f:29
value_type & x()
Definition Vec2f:67
value_type & y()
Definition Vec2f:68
Definition Vec3f:29
Definition Vec3i:22
Definition Vec4f:28
Definition ref_ptr:32
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
Definition Image:518