Class SoGpuBufferObject
java.lang.Object
com.openinventor.inventor.Inventor
com.openinventor.inventor.devices.SoBufferObject
com.openinventor.inventor.devices.SoGpuBufferObject
- All Implemented Interfaces:
SafeDisposable
GPU buffer object class.
This class provides management functions for GPU 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.
See SoBufferObject for general information about buffer objects.
NOTES:
- Creating a GPU buffer requires a current GPU context (like OpenGL).
- Modifying the properties of an GPU buffer require a current GPU context.
This includes mapping and unmapping the buffer (map()/unmap()), allocating memory (setSize()) and copying data into the buffer (e.g.memcpy()). - The same instance of
SoGpuBufferObjectcan not be used inside two GPU contexts that are not shared. For example, if an instance ofSoBufferedShapecontains SoGpuBufferObjects in its fields, this instance can be used in multiple viewers only if their contexts are shared.
See SoBufferObject for general information about buffer objects.
See SoBufferedShape for an example of storing vertices in a GPU buffer.
Load data into a buffer object.
Create a GPU buffer object and load data from an array in memory:
float[] vertices = { 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 }; // Create a GPU buffer and allocate memory // Ensure that a context is created and bound before this step ! // Make sure the window containing the RenderArea is already exposed SoGpuBufferObject gpuBuffer = new SoGpuBufferObject( SoGpuBufferObject.BufferAccessFrequencies.STATIC, SoGpuBufferObject.BufferAccessNatures.SHARED ); gpuBuffer.setSize( vertices.length * Float.SIZE/8 ); // Set the buffer size (allocate memory) // Copy data into the buffer object FloatBuffer vertData = gpuBuffer.map( SoBufferObject.AccessModes.SET ).asFloatBuffer(); vertData.put(vertices); gpuBuffer.unmap();
Access data stored in a GPU buffer object.
FloatBuffer data = gpuBuffer.map( SoBufferObject.AccessModes.READ_ONLY ).asFloatBuffer(); float value = data.get(0); value = data.get(1); . . . gpuBuffer.unmap();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAvailable values for hints on how frequently the application will be changing the buffer's data.static enumAvailable values for hints on the nature of the application's access to the buffer.Nested classes/interfaces inherited from class com.openinventor.inventor.devices.SoBufferObject
SoBufferObject.AccessModesNested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand -
Field Summary
Fields inherited from class com.openinventor.inventor.devices.SoBufferObject
SO_BUFFER_SIZE_ALLFields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle -
Constructor Summary
ConstructorsConstructorDescriptionCalls SoGpuBufferObject(SoGpuBufferObject.BufferAccessFrequencies.valueOf( SoGpuBufferObject.BufferAccessFrequencies.STATIC.getValue() ), SoGpuBufferObject.BufferAccessNatures.valueOf( SoGpuBufferObject.BufferAccessNatures.SHARED.getValue() )).SoGpuBufferObject(SoGpuBufferObject.BufferAccessFrequencies accessFrequency) Calls SoGpuBufferObject(accessFrequency, SoGpuBufferObject.BufferAccessNatures.valueOf( SoGpuBufferObject.BufferAccessNatures.SHARED.getValue() )).SoGpuBufferObject(SoGpuBufferObject.BufferAccessFrequencies accessFrequency, SoGpuBufferObject.BufferAccessNatures accessNature) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current buffer access frequency hint for this buffer object.Returns the current buffer access nature hint for this buffer object.Methods inherited from class com.openinventor.inventor.devices.SoBufferObject
clearInstance, createInstance, dispose, getContext, getMappedBufferObject, getMappedBufferObjectAccessMode, getMappedBufferObjectPosition, getMappedBufferObjectSize, getSize, isDisposable, lockBuffer, map, map, map, map, map, map, memcpy, memcpy, memcpy, memcpy, setSize, unlockBuffer, unmap, unmapMethods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
Constructor Details
-
SoGpuBufferObject
Calls SoGpuBufferObject(accessFrequency, SoGpuBufferObject.BufferAccessNatures.valueOf( SoGpuBufferObject.BufferAccessNatures.SHARED.getValue() )). -
SoGpuBufferObject
public SoGpuBufferObject()Calls SoGpuBufferObject(SoGpuBufferObject.BufferAccessFrequencies.valueOf( SoGpuBufferObject.BufferAccessFrequencies.STATIC.getValue() ), SoGpuBufferObject.BufferAccessNatures.valueOf( SoGpuBufferObject.BufferAccessNatures.SHARED.getValue() )). -
SoGpuBufferObject
public SoGpuBufferObject(SoGpuBufferObject.BufferAccessFrequencies accessFrequency, SoGpuBufferObject.BufferAccessNatures accessNature) Constructor.- Parameters:
accessFrequency- The intended access frequency of this buffer.accessNature- The intended access nature of this buffer.
-
-
Method Details
-
getAccessNature
Returns the current buffer access nature hint for this buffer object. -
getAccessFrequency
Returns the current buffer access frequency hint for this buffer object.
-