Click or drag to resize
SoGLBufferObject Class

OpenGL buffer object class.

Inheritance Hierarchy

Namespace: OIV.Inventor.Devices
Assembly: OIV.Inventor.Base (in OIV.Inventor.Base.dll) Version: 9.9.13.0 (9.9.13.0)
Syntax
public class SoGLBufferObject : SoBufferObject

The SoGLBufferObject type exposes the following members.

Constructors
  NameDescription
Public methodSoGLBufferObject

Constructor.

Top
Methods
  NameDescription
Public methodBind

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

Public methodClearInstance

Free the memory allocated in the buffer object.

(Overrides SoBufferObjectClearInstance.)
Public methodCreateInstance

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

(Overrides SoBufferObjectCreateInstance.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFillT
Convenient method to fill an SoBufferObject with a default value.
(Inherited from SoBufferObject.)
Public methodGetContext

Returns the device context where this buffer is valid.

(Inherited from SoBufferObject.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetId

Returns the OpenGL id of the buffer.

Public methodGetLongMappingSize Obsolete.

Returns the size of the mapped area in bytes.

(Inherited from SoBufferObject.)
Public methodGetLongMappingStartPosition Obsolete.

Returns the position in the source buffer mapped in this buffer.

(Inherited from SoBufferObject.)
Public methodGetLongSize Obsolete.

Returns the size, in bytes, of the buffer object.

(Inherited from SoBufferObject.)
Public methodGetMappedBufferObject

Returns a pointer to the buffer object which is mapped by the actual object.

(Inherited from SoBufferObject.)
Public methodGetMappingAccessMode

Returns the access mode used for the buffer mapping.

(Inherited from SoBufferObject.)
Public methodGetMappingSize

Returns the size of the mapped area in bytes.

(Inherited from SoBufferObject.)
Public methodGetMappingStartPosition

Returns the position in the source buffer mapped in this buffer.

(Inherited from SoBufferObject.)
Public methodGetSize

Returns the size, in bytes, of the buffer object.

(Inherited from SoBufferObject.)
Public methodGetTarget

Returns the current buffer target.

Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberIsAvailable

Query if SoGLBufferObjects are available on this system.

Public methodIsValid

Query if the buffer is valid in the current context.

Public methodLockBuffer

Locks the buffer against concurrent calls from different threads.

(Inherited from SoBufferObject.)
Public methodMap(SoBufferObjectAccessModes)

This function maps the OpenGL buffer memory into CPU memory.

Public methodMap(SoBufferObject, SoBufferObjectAccessModes)
Calls Map(targetBufferObject, accessMode, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMap(SoCpuBufferObject, SoBufferObjectAccessModes)
Calls Map(targetBufferObject, accessMode, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMap(SoGLBufferObject, SoBufferObjectAccessModes)
Calls Map(targetBufferObject, accessMode, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMap(SoBufferObject, SoBufferObjectAccessModes, UInt64)
Calls Map(targetBufferObject, accessMode, startPosition, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMap(SoBufferObjectAccessModes, UInt64, UInt64)

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

Public methodMap(SoCpuBufferObject, SoBufferObjectAccessModes, UInt64)
Calls Map(targetBufferObject, accessMode, startPosition, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMap(SoGLBufferObject, SoBufferObjectAccessModes, UInt64)
Calls Map(targetBufferObject, accessMode, startPosition, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMap(SoBufferObject, SoBufferObjectAccessModes, UInt64, UInt64)

Map the current buffer object into the specified buffer object.

(Overrides SoBufferObjectMap(SoBufferObject, SoBufferObjectAccessModes, UInt64, UInt64).)
Public methodMap(SoCpuBufferObject, SoBufferObjectAccessModes, UInt64, UInt64)

Map the current buffer object into the specified CPU buffer object.

(Overrides SoBufferObjectMap(SoCpuBufferObject, SoBufferObjectAccessModes, UInt64, UInt64).)
Public methodMap(SoGLBufferObject, SoBufferObjectAccessModes, UInt64, UInt64)

Map the current buffer object into the specified GL buffer object.

Public methodMemcpy(SoBufferObject)
Calls Memcpy(sourceBufferObject, System.UInt64(0), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoCpuBufferObject)
Calls Memcpy(sourceBufferObject, System.UInt64(0), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoGLBufferObject)
Calls Memcpy(sourceBufferObject, System.UInt64(0), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoBufferObject, UInt64)
Calls Memcpy(sourceBufferObject, destOffset, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoCpuBufferObject, UInt64)
Calls Memcpy(sourceBufferObject, destOffset, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoGLBufferObject, UInt64)
Calls Memcpy(sourceBufferObject, destOffset, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoBufferObject, UInt64, UInt64)
Calls Memcpy(sourceBufferObject, destOffset, sourceOffset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoCpuBufferObject, UInt64, UInt64)
Calls Memcpy(sourceBufferObject, destOffset, sourceOffset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoGLBufferObject, UInt64, UInt64)
Calls Memcpy(sourceBufferObject, destOffset, sourceOffset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemcpy(SoBufferObject, UInt64, UInt64, UInt64)

Copy data from any SoBufferObject into this buffer.

(Overrides SoBufferObjectMemcpy(SoBufferObject, UInt64, UInt64, UInt64).)
Public methodMemcpy(SoCpuBufferObject, UInt64, UInt64, UInt64)

Copy data from a CPU buffer into this buffer.

(Overrides SoBufferObjectMemcpy(SoCpuBufferObject, UInt64, UInt64, UInt64).)
Public methodMemcpy(SoGLBufferObject, UInt64, UInt64, UInt64)

Copy data from a GL buffer into this buffer.

Public methodMemset(IntPtr)
Calls Memset(value, System.Convert.ToUInt64(1), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemset(IntPtr, UInt64)
Calls Memset(value, valueSize, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemset(IntPtr, UInt64, UInt64)
Calls Memset(value, valueSize, offset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)).
Public methodMemset(IntPtr, UInt64, UInt64, UInt64)

Set the contents of (or a portion of) this buffer object to the specified value.

(Overrides SoBufferObjectMemset(IntPtr, UInt64, UInt64, UInt64).)
Public methodSetMappedBufferObject

This function is used when the instance of buffer object is used to map a buffer.

(Inherited from SoBufferObject.)
Public methodSetMappingAccessMode

Sets the mapping mode used for the mapping of a buffer object.

(Inherited from SoBufferObject.)
Public methodSetMappingZoneInformation

Stores information about the mapping in order to know the subset of the data mapped in the buffer.

(Inherited from SoBufferObject.)
Public methodSetSize

Set the size of the buffer in bytes.

(Overrides SoBufferObjectSetSize(UInt64).)
Public methodSetTarget

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

Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUnbind

Unbind the buffer.

Public methodUnlockBuffer

Unlocks the buffer object.

(Inherited from SoBufferObject.)
Public methodUnmap

Unmaps the buffer using the regular unmap function.

Public methodUnmap(SoBufferObject)

Unmap the specified buffer object.

(Overrides SoBufferObjectUnmap(SoBufferObject).)
Public methodUnmap(SoCpuBufferObject)

Unmap the specified CPU buffer object.

(Overrides SoBufferObjectUnmap(SoCpuBufferObject).)
Public methodUnmap(SoGLBufferObject)

Unmap the specified GL buffer object.

Top
Properties
  NameDescription
Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Top
Remarks

This class provides management functions for OpenGL memory buffers.

NOTES:

  • Creating a OpenGL buffer requires a current OpenGL context. For example, by calling the viewer's bindNormalContext() method or by creating an SoGLContext object and binding (then unbinding) it.

  • Modifying the properties of an OpenGL buffer require a current OpenGL context. This includes changing properties (e.g. setTarget()), allocating memory (setSize()) and copying data into the buffer (e.g. memcpy()). Mapping a buffer does not require explicitly binding a context.

  • The setTarget() method must be called before any operation, as long as OpenGL requires the target for that operation.

  • For detailed use of this class it may be helpful to review and understand the use of OpenGL Buffer Objects, particularly Vertex Buffer Objects (VBO).

See SoBufferObject for general information about buffer objects.

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

EXAMPLE

Load data into a buffer object.

Create a GPU buffer object and load data from an array in memory:

float[] vertices = new float[9 * 3] {
    1.0f, 0.5f,0.0f, 0.0f, 1.0f,0.0f, -1.0f,0.5f,0.0f,
   -1.0f,-1.0f,0.0f, 1.0f,-1.0f,0.0f,  1.0f,0.0f,0.0f, -1.0f,0.0f,0.0f,
   -1.0f,-1.5f,0.0f, 1.0f,-1.5f,0.0f
};

SbNativeArray<float> vertArray = new SbNativeArray<float>(vertices);
SoCpuBufferObject vertBuf = new SoCpuBufferObject( (SbNativeArray<byte>)vertArray );

SoGLContext glContext = new SoGLContext(true);
glContext.Bind();
   SoGLBufferObject gpuBuffer = new SoGLBufferObject(SoGLBufferObject.Usages.STATIC_DRAW);
   gpuBuffer.SetTarget( SoGLBufferObject.BufferObjectTargets.ARRAY_BUFFER );
   gpuBuffer.SetSize( cpuBuffer.GetSize() );  // Set the buffer size (allocate memory)
   gpuBuffer.Memcpy ( cpuBuffer );            // Copy data into the buffer
glContext.Unbind();
Load data into an existing GPU buffer from a CPU buffer:
SoGLContext ctx = (SoGLContext)gpuBuffer.GetContext();
ctx.Bind();
   gpuBuffer.SetSize( cpuBuffer.GetSize() ); // Set the buffer size (allocate memory)
   gpuBuffer.Memcpy ( cpuBuffer );           // Copy data into the buffer
ctx.Unbind();
Or
cpuBuffer.Map( gpuBuffer, SoBufferObject.AccessModes.READ_ONLY );
cpuBuffer.Unmap();

EXAMPLE

Access data stored in a GPU buffer object.

SbNativeArray<float> data = (SbNativeArray<float>)gpuBuffer.Map( SoBufferObject.AccessModes.READ_ONLY );
float value = data[0];
value = data[1];
   . . .
gpuBuffer.Unmap();

See Also