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/SoInteropBufferObject.h>
00027 #include <Inventor/sys/SoGLType.h>
00028
00029 SO_PIMPL_PUBLIC_DECLARATION(SoGLBufferObject)
00030 class SbVec2i32;
00031
00227 class SoGLBufferObject : public SoInteropBufferObject
00228 {
00229 SO_TYPED_CLASS_HEADER();
00230 SO_PIMPL_PUBLIC_HEADER(SoGLBufferObject)
00231
00232 public:
00233
00237 enum BufferObjectTarget
00238 {
00243 PIXEL_PACK_BUFFER,
00244
00249 PIXEL_UNPACK_BUFFER,
00250
00255 ARRAY_BUFFER,
00256
00261 ELEMENT_ARRAY_BUFFER,
00262
00267 SHADER_STORAGE_BUFFER
00268 };
00269
00279 enum Usage
00280 {
00286 STREAM_DRAW,
00287
00293 STREAM_READ,
00294
00300 STREAM_COPY,
00301
00307 STATIC_DRAW,
00308
00314 STATIC_READ,
00315
00321 STATIC_COPY,
00322
00328 DYNAMIC_DRAW,
00329
00335 DYNAMIC_READ,
00336
00342 DYNAMIC_COPY
00343 };
00344
00350 SoGLBufferObject( Usage usage );
00351
00357 static bool isAvailable();
00358
00367 void setTarget( BufferObjectTarget target );
00368
00374 BufferObjectTarget getTarget() const;
00375
00387 virtual bool setSize( size_t size );
00388
00399 virtual void map( SoBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00400
00404 virtual void unmap( SoBufferObject* bufferObject );
00405
00415 void bind();
00416
00426 void unbind();
00427
00441 virtual void* map( AccessMode accessMode, size_t offset = 0, size_t count = SO_BUFFER_SIZE_ALL );
00442
00446 virtual void unmap();
00447
00458 bool isValid();
00459
00463 GLuint getId() const;
00464
00470 virtual SoBufferObject* createInstance() const;
00471
00479 virtual void clearInstance();
00480
00498 void memcpy(SoBufferObject* source, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL);
00499
00500 private:
00501
00502 void copyToCpuBuffer( SoCpuBufferObject* targetBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00503
00505 bool isBindable();
00506
00508 void copyFromGLTexture(GLuint tex, const SbVec2i32& size, bool alpha);
00509
00510 struct Configuration
00511 {
00512 size_t size;
00513 BufferObjectTarget target;
00514 Usage usage;
00515 };
00516
00517 private:
00521 virtual ~SoGLBufferObject();
00522
00524 SoGLBufferObject();
00525
00526 bool checkContext();
00527
00528 };
00529
00530 #endif // SOGLBUFFEROBJECT_H
00531