SoGLBufferObject Class Reference
[GL device]

VSG extension OpenGL buffer object class. More...

#include <Inventor/devices/SoGLBufferObject.h>

Inheritance diagram for SoGLBufferObject:
SoInteropBufferObject SoBufferObject SoRefCounter SoTypedObject

List of all members.

Classes

struct  Configuration

Public Types

enum  BufferObjectTarget {
  PIXEL_PACK_BUFFER,
  PIXEL_UNPACK_BUFFER,
  ARRAY_BUFFER,
  ELEMENT_ARRAY_BUFFER,
  SHADER_STORAGE_BUFFER
}
enum  Usage {
  STREAM_DRAW,
  STREAM_READ,
  STREAM_COPY,
  STATIC_DRAW,
  STATIC_READ,
  STATIC_COPY,
  DYNAMIC_DRAW,
  DYNAMIC_READ,
  DYNAMIC_COPY
}

Public Member Functions

 SoGLBufferObject (Usage usage)
void setTarget (BufferObjectTarget target)
BufferObjectTarget getTarget () const
virtual bool setSize (size_t size)
virtual void map (SoBufferObject *targetBufferObject, AccessMode accessMode, size_t startPosition=0, size_t mappingSize=SO_BUFFER_SIZE_ALL)
virtual void unmap (SoBufferObject *bufferObject)
void bind ()
void unbind ()
virtual void * map (AccessMode accessMode, size_t offset=0, size_t count=SO_BUFFER_SIZE_ALL)
virtual void unmap ()
bool isValid ()
GLuint getId () const
virtual SoBufferObjectcreateInstance () const
virtual void clearInstance ()
void memcpy (SoBufferObject *source, size_t destOffset=0, size_t sourceOffset=0, size_t copySize=SO_BUFFER_SIZE_ALL)

Static Public Member Functions

static bool isAvailable ()

Detailed Description

VSG extension OpenGL buffer object class.

This class provides management functions for OpenGL memory buffers.

NOTE: Since Open Inventor 10.4, applications should use SoGPUBufferObject, instead of SoGLBufferObject, in most cases. For example to store vertex data in GPU memory for use with SoBufferedShape or SoVertexShaderParameterBufferObject.

This class can be used as a wrapper for GL memory buffer management when the application manages OpenGL code directly.

NOTES:

See SoBufferObject for general information about buffer objects.

See SoBufferedShape for an example of storing vertices in an OpenGL buffer.

EXAMPLE

EXAMPLE

SEE ALSO

SoCpuBufferObject

See related examples:

ComputeSlice


Member Enumeration Documentation

This enum declares the possible targets of the buffer.

Enumerator:
PIXEL_PACK_BUFFER 

The buffer is used as a pixel pack buffer, it can be used as texture.

For instance as a Texture Buffer Object (TBO).

PIXEL_UNPACK_BUFFER 

The buffer is used as a pixel unpack buffer, it can be used for readback operation.

For instance as a Pixel Buffer Object (PBO).

ARRAY_BUFFER 

The buffer is used as an array buffer, it can be used for vertices, normals, colors.

For instance as a Vertex Buffer Object (VBO). Tis is the default value.

ELEMENT_ARRAY_BUFFER 

The buffer is used as a pixel pack buffer, it is used to specify the indices for indexed geometries.

For instance a Vertex Buffer Object (VBO).

SHADER_STORAGE_BUFFER 

The buffer is used as a shader storage buffer, it can be used to perform random access reads, writes and atomic memory operations from a shader.

This enum declares the possible usages of the memory allocated for the buffer.

This is a hint to the OpenGL driver implementation as to how a buffer object's data store will be accessed. This enables the OpenGL implementation to make more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. usage can be broken down into two parts: first, the frequency of access (modification and usage - STATIC, STREAM, DYNAMIC), and second, the nature of that access - DRAW, COPY, READ.

Enumerator:
STREAM_DRAW 

The data store contents will be modified once and used at most a few times.

The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.

STREAM_READ 

The data store contents will be modified once and used at most a few times.

The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.

STREAM_COPY 

The data store contents will be modified once and used at most a few times.

The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.

STATIC_DRAW 

The data store contents will be modified once and used many times.

The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.

STATIC_READ 

The data store contents will be modified once and used many times.

The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.

STATIC_COPY 

The data store contents will be modified once and used many times.

The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.

DYNAMIC_DRAW 

The data store contents will be modified repeatedly and used many times.

The data store contents are modified by the application, and used as the source for GL drawing and image specification commands.

DYNAMIC_READ 

The data store contents will be modified repeatedly and used many times.

The data store contents are modified by reading data from the GL, and used to return that data when queried by the application.

DYNAMIC_COPY 

The data store contents will be modified repeatedly and used many times.

The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.


Constructor & Destructor Documentation

SoGLBufferObject::SoGLBufferObject ( Usage  usage  ) 

Constructor.

Parameters:
usage The intended usage of this buffer. Use enum Usage

Member Function Documentation

void SoGLBufferObject::bind (  ) 

Bind the current buffer to the specified target so it's usable by OpenGL operations.

Notes:

  • Most applications will not need to use this method, because the other methods in this class (map, memcpy, etc) bind the buffer to its target automatically. It may be useful when making direct calls to OpenGL. It corresponds to the glBindBuffer() call.
  • A valid OpenGL context (see SoGLContext) must be bound before calling this method.
virtual void SoGLBufferObject::clearInstance (  )  [virtual]

Free the memory allocated in the buffer object.

Notes:

  • It is not necessary to bind an OpenGL context to call this method.
  • After this call the buffer is invalid (until memory is allocated again).

Implements SoInteropBufferObject.

virtual SoBufferObject* SoGLBufferObject::createInstance (  )  const [virtual]

Create a new buffer with the same properties as the current one.

The new instance will have the same context and device properties, but no memory is allocated so the new buffer is initially invalid.

Implements SoInteropBufferObject.

GLuint SoGLBufferObject::getId (  )  const

Returns the OpenGL id of the buffer.

BufferObjectTarget SoGLBufferObject::getTarget (  )  const

Returns the current buffer target.

Returns:
The actual buffer target. Use enum BufferObjectTarget
static bool SoGLBufferObject::isAvailable (  )  [static]

Query if SoGLBufferObjects are available on this system.

Returns:
Returns true if SoGLBufferObjects are available on this system.
bool SoGLBufferObject::isValid (  ) 

Query if the buffer is valid in the current context.

Notes:

  • It is not necessary to bind an OpenGL context to call this method.
  • The buffer object will be invalid until memory is allocated, either explicitly (see setSize()) or implicitly (e.g. mapping from another buffer).
  • The buffer object will be invalid after calling clearInstance().
virtual void* SoGLBufferObject::map ( AccessMode  accessMode,
size_t  offset = 0,
size_t  count = SO_BUFFER_SIZE_ALL 
) [virtual]

This function extends the map(AccessMode) method by allowing the mapping of a sub part of the buffer object into CPU memory.

On some systems this method has better performance.

Notes:

  • It is not necessary to bind an OpenGL context before calling this method.
  • The unmap() method must be called before using the buffer for any OpenGL operation, otherwise the operation will produce an error.
Returns:
Pointer to data in the mapped region of the OpenGL buffer.

Reimplemented from SoBufferObject.

virtual void SoGLBufferObject::map ( SoBufferObject targetBufferObject,
AccessMode  accessMode,
size_t  startPosition = 0,
size_t  mappingSize = SO_BUFFER_SIZE_ALL 
) [virtual]

Map the current buffer object into the specified buffer object.

Parameters:
targetBufferObject The buffer object which will be the mapped version of this buffer.
accessMode The access mode used for the mapping. Use enum AccessMode
startPosition offset in source buffer to map from (default is start of buffer).
mappingSize size from the startPosition, if SO_BUFFER_SIZE_ALL then the whole buffer is mapped.
void SoGLBufferObject::memcpy ( SoBufferObject source,
size_t  destOffset = 0,
size_t  sourceOffset = 0,
size_t  copySize = SO_BUFFER_SIZE_ALL 
)

Copy data from a buffer into this GL buffer.

Notes:

  • It is not necessary to bind an OpenGL context before calling this method.
  • The current buffer object must be large enough to hold the data that will be copied. See setSize() to allocate memory.
  • If the size or the offset are not valid an error is reported (SoDebugError).
  • This buffer is not resized, if it is too small an error is reported.

This function is a specialized function for speed-up.

Parameters:
source The buffer object to be copied.
destOffset The starting offset in the destination buffer object, useful for data subsets.
sourceOffset The starting offset in the source buffer object, useful for data subsets.
copySize The number of bytes to copy from the source buffer object (SO_BUFFER_SIZE_ALL means all).
virtual bool SoGLBufferObject::setSize ( size_t  size  )  [virtual]

Set the size of the buffer in bytes.

Parameters:
size New size in bytes of the buffer.

Notes:

  • Causes memory to be allocated for the buffer.
  • A valid OpenGL context (see SoGLContext) must be bound to perform this operation.
  • If the buffer is already allocated, the memory is freed and re-allocated with the new size.
    Therefore if you increase the size of the buffer, the original data is lost!

Reimplemented from SoBufferObject.

void SoGLBufferObject::setTarget ( BufferObjectTarget  target  ) 

Specify the buffer target, which defines possible usage of the buffer.

WARNING: The function setTarget must be called before any operation for which OpenGL requires the target to be specified.

Parameters:
target The new target of the buffer. Use enum BufferObjectTarget
void SoGLBufferObject::unbind (  ) 

Unbind the buffer.

Notes:

  • A valid OpenGL context (see SoGLContext) must be bound before calling this method.
  • Most applications will not need to use this method, because the other methods in this class (map, memcpy, etc) unbind the buffer automatically. It may be useful when making direct calls to OpenGL. It corresponds to the glBindBuffer() call with an id of 0.
virtual void SoGLBufferObject::unmap (  )  [virtual]

Unmaps the buffer using the regular unmap function.

Reimplemented from SoBufferObject.

virtual void SoGLBufferObject::unmap ( SoBufferObject bufferObject  )  [virtual]

Unmap the specified buffer object.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 4 Sep 2023
Copyright © Thermo Fisher Scientific All rights reserved.
https://www.openinventor.com/