SoGLBufferObject Class |
OpenGL buffer object class.
Namespace: OIV.Inventor.Devices
The SoGLBufferObject type exposes the following members.
Name | Description | |
---|---|---|
SoGLBufferObject | Constructor. |
Name | Description | |
---|---|---|
Bind | Bind the current buffer to the specified target so it's usable by OpenGL operations. | |
ClearInstance | Free the memory allocated in the buffer object. | |
CreateInstance | Create a new buffer with the same properties as the current one. | |
Dispose |
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.) | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
FillT |
Convenient method to fill an SoBufferObject with
a default value.
(Inherited from SoBufferObject.) | |
GetContext | Returns the device context where this buffer is valid. | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetId | Returns the OpenGL id of the buffer. | |
GetMappedBufferObject | Returns a pointer to the buffer object which is mapped by the actual object. | |
GetMappedBufferObjectAccessMode | Returns the access mode used for the buffer mapping. | |
GetMappedBufferObjectPosition | Returns the position in the source buffer mapped in this buffer. | |
GetMappedBufferObjectSize | Returns the size of the mapped area in bytes. | |
GetSize | Returns the size, in bytes, of the buffer object. | |
GetTarget | Returns the current buffer target. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsAvailable | Query if SoGLBufferObjects are available on this system. | |
IsValid | Query if the buffer is valid in the current context. | |
LockBuffer | Locks the buffer against concurrent calls from different threads. | |
Map(SoBufferObjectAccessModes) | Calls Map(accessMode, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(SoBufferObject, SoBufferObjectAccessModes) | Calls Map(targetBufferObject, accessMode, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(SoBufferObjectAccessModes, UInt64) | Calls Map(accessMode, offset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(SoBufferObject, SoBufferObjectAccessModes, UInt64) | Calls Map(targetBufferObject, accessMode, startPosition, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(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. | |
Map(SoBufferObject, SoBufferObjectAccessModes, UInt64, UInt64) | Map the current buffer object into the specified buffer object. | |
Memcpy(SoBufferObject) | Calls Memcpy(source, System.UInt64(0), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memcpy(SoBufferObject, UInt64) | Calls Memcpy(source, destOffset, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memcpy(SoBufferObject, UInt64, UInt64) | Calls Memcpy(source, destOffset, sourceOffset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memcpy(SoBufferObject, UInt64, UInt64, UInt64) | Copy data from a buffer into this GL buffer. | |
Memset(IntPtr) | Calls Memset(value, System.Convert.ToUInt64(1), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). (Inherited from SoBufferObject.) | |
Memset(IntPtr, UInt64) | Calls Memset(value, valueSize, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). (Inherited from SoBufferObject.) | |
Memset(IntPtr, UInt64, UInt64) | Calls Memset(value, valueSize, offset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). (Inherited from SoBufferObject.) | |
Memset(IntPtr, UInt64, UInt64, UInt64) | This function sets the contents of (or a portion of) this buffer object to the specified value. | |
SetSize | Set the size of the buffer in bytes. | |
SetTarget | Specify the buffer target, which defines possible usage of the buffer. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Unbind | Unbind the buffer. | |
UnlockBuffer | Unlocks the buffer object. | |
Unmap | Unmaps the buffer using the regular unmap function. | |
Unmap(SoBufferObject) | Unmap the specified buffer object. |
Name | Description | |
---|---|---|
IsDisposable | ISafeDisposable interface implementation.
(Inherited from SoDisposable.) |
This class provides management functions for OpenGL memory buffers.
NOTE: Since Open Inventor 10.4, applications should use SoGPUBufferObject, instead of OIV.Inventor.Devices.SoGLBufferObject, in most cases. For example to store vertex data in GPU memory for use with OIV.Inventor.Nodes.SoBufferedShape or OIV.Inventor.Nodes.SoVertexShaderParameterBufferObject.
This class can be used as a wrapper for GL memory buffer management when the application manages OpenGL code directly.
NOTES:
Creating a OpenGL buffer requires a current OpenGL context. For example, by calling the viewer's bindNormalContext() method or by creating an OIV.Inventor.Devices.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. OIV.Inventor.Devices.SoGLBufferObject.SetTarget(OIV.Inventor.Devices.SoGLBufferObject.BufferObjectTargets)), allocating memory (OIV.Inventor.Devices.SoGLBufferObject.SetSize(System.UInt64)) and copying data into the buffer (e.g. OIV.Inventor.Devices.SoGLBufferObject.Memcpy(OIV.Inventor.Devices.SoBufferObject, System.UInt64, System.UInt64, System.UInt64)). Mapping a buffer does not require explicitly binding a context.
The OIV.Inventor.Devices.SoGLBufferObject.SetTarget(OIV.Inventor.Devices.SoGLBufferObject.BufferObjectTargets) 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 OIV.Inventor.Devices.SoBufferObject for general information about buffer objects.
See OIV.Inventor.Nodes.SoBufferedShape for an example of storing vertices in an OpenGL buffer.
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();
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();
cpuBuffer.Map( gpuBuffer, SoBufferObject.AccessModes.READ_ONLY ); cpuBuffer.Unmap();
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();