00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined SOGLBUFFEROBJECT_H
00024 #define SOGLBUFFEROBJECT_H
00025
00026 #include <Inventor/devices/SoBufferObject.h>
00027 #include <Inventor/sys/SoGLType.h>
00028
00029 class SoGLBufferObjectImpl;
00030
00222 class SoGLBufferObject : public SoBufferObject
00223 {
00224 SO_TYPED_CLASS_HEADER();
00225
00226 friend class SoCpuBufferObject;
00227
00228
00229
00230 public:
00231
00235 enum BufferObjectTarget
00236 {
00241 PIXEL_PACK_BUFFER,
00242
00247 PIXEL_UNPACK_BUFFER,
00248
00253 ARRAY_BUFFER,
00254
00259 ELEMENT_ARRAY_BUFFER,
00260
00265 SHADER_STORAGE_BUFFER
00266 };
00267
00277 enum Usage
00278 {
00284 STREAM_DRAW,
00285
00291 STREAM_READ,
00292
00298 STREAM_COPY,
00299
00305 STATIC_DRAW,
00306
00312 STATIC_READ,
00313
00319 STATIC_COPY,
00320
00326 DYNAMIC_DRAW,
00327
00333 DYNAMIC_READ,
00334
00340 DYNAMIC_COPY
00341 };
00342
00348 SoGLBufferObject( Usage usage );
00349
00355 static bool isAvailable();
00356
00365 void setTarget( BufferObjectTarget target );
00366
00372 BufferObjectTarget getTarget() const;
00373
00385 virtual bool setSize( size_t size );
00386
00397 virtual void map( SoBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00398
00405 virtual void map( SoGLBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00406
00413 virtual void map( SoCpuBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00414
00418 virtual void unmap( SoBufferObject* bufferObject );
00419
00424 virtual void unmap( SoCpuBufferObject* bufferObject );
00425
00430 virtual void unmap( SoGLBufferObject* bufferObject );
00431
00446 void memcpy( SoBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00447
00460 void memcpy( SoGLBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00461
00474 void memcpy( SoCpuBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00475
00513 virtual void memset( void* value, size_t valueSize = 1, size_t offset = 0, size_t count = SO_BUFFER_SIZE_ALL );
00514
00524 void bind();
00525
00535 void unbind();
00536
00551 void* map( AccessMode accessMode );
00552
00566 void* map( AccessMode accessMode, size_t offset, size_t count );
00567
00571 void unmap();
00572
00583 bool isValid();
00584
00588 GLuint getId() const;
00589
00595 virtual SoBufferObject* createInstance() const;
00596
00604 virtual void clearInstance();
00605
00606
00607
00608 private:
00609
00610 void copyToCpuBuffer( SoCpuBufferObject* targetBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00611
00612
00613
00614 private:
00618 virtual ~SoGLBufferObject();
00619
00621 SoGLBufferObject();
00622
00624 GLenum getOpenGLTarget() const;
00625
00627 void setOpenGLUsage(const Usage usage);
00628
00630 GLenum getOpenGLUsage() const;
00631
00632 bool checkContext();
00633
00635 static unsigned int getOpenGLAccessMode( AccessMode accessMode );
00636
00637 private:
00638
00639 SoGLBufferObjectImpl* m_impl;
00640 };
00641
00642
00643
00644 #endif // SOGLBUFFEROBJECT_H
00645
00646