public abstract class ZeroMemoryVertexBufferObject extends java.lang.Object implements IVertexBufferObject
HighPerformanceVertexBufferObject or a LowMemoryVertexBufferObject, the ZeroMemoryVertexBufferObject uses no permanent heap memory,
at the cost of expensive data buffering (up to 5x slower!) whenever the bufferdata needs to be updated and higher GC activity, due to the temporary ByteBuffer allocations.
Usually a ZeroMemoryVertexBufferObject is preferred to a HighPerformanceVertexBufferObject or a LowMemoryVertexBufferObject when the following conditions are met:
HighPerformanceVertexBufferObject/LowMemoryVertexBufferObject or an extreme number of small HighPerformanceVertexBufferObject/LowMemoryVertexBufferObjects, where you can't afford to have any of the bufferdata to be kept in heap memory.ZeroMemoryVertexBufferObject is changed not often, or even better: never.IDisposable.AlreadyDisposedException| Modifier and Type | Field and Description |
|---|---|
protected boolean |
mAutoDispose |
protected int |
mCapacity |
protected boolean |
mDirtyOnHardware |
protected boolean |
mDisposed |
protected int |
mHardwareBufferID |
protected int |
mUsage |
protected VertexBufferObjectAttributes |
mVertexBufferObjectAttributes |
protected VertexBufferObjectManager |
mVertexBufferObjectManager |
HARDWARE_BUFFER_ID_INVALID| Constructor and Description |
|---|
ZeroMemoryVertexBufferObject(VertexBufferObjectManager pVertexBufferObjectManager,
int pCapacity,
DrawType pDrawType,
boolean pAutoDispose,
VertexBufferObjectAttributes pVertexBufferObjectAttributes) |
| Modifier and Type | Method and Description |
|---|---|
protected java.nio.ByteBuffer |
aquireByteBuffer()
When a non
null ByteBuffer is returned by this function, it is guaranteed that releaseByteBuffer(ByteBuffer) is called. |
void |
bind(GLState pGLState) |
void |
bind(GLState pGLState,
ShaderProgram pShaderProgram) |
void |
dispose() |
void |
draw(int pPrimitiveType,
int pCount) |
void |
draw(int pPrimitiveType,
int pOffset,
int pCount) |
protected void |
finalize() |
int |
getByteCapacity() |
int |
getCapacity() |
int |
getGPUMemoryByteSize() |
int |
getHardwareBufferID() |
int |
getHeapMemoryByteSize() |
int |
getNativeHeapMemoryByteSize() |
VertexBufferObjectManager |
getVertexBufferObjectManager() |
boolean |
isAutoDispose() |
boolean |
isDirtyOnHardware() |
boolean |
isDisposed() |
boolean |
isLoadedToHardware() |
protected abstract void |
onPopulateBufferData(java.nio.ByteBuffer byteBuffer) |
protected void |
releaseByteBuffer(java.nio.ByteBuffer byteBuffer) |
void |
setDirtyOnHardware()
Mark this
VertexBufferObject dirty so it gets updated on the hardware. |
void |
setNotLoadedToHardware()
Mark this
VertexBufferObject as not not loaded to hardware. |
void |
unbind(GLState pGLState,
ShaderProgram pShaderProgram) |
void |
unloadFromHardware(GLState pGLState) |
protected final int mCapacity
protected final boolean mAutoDispose
protected final int mUsage
protected int mHardwareBufferID
protected boolean mDirtyOnHardware
protected boolean mDisposed
protected final VertexBufferObjectManager mVertexBufferObjectManager
protected final VertexBufferObjectAttributes mVertexBufferObjectAttributes
public ZeroMemoryVertexBufferObject(VertexBufferObjectManager pVertexBufferObjectManager, int pCapacity, DrawType pDrawType, boolean pAutoDispose, VertexBufferObjectAttributes pVertexBufferObjectAttributes)
public VertexBufferObjectManager getVertexBufferObjectManager()
getVertexBufferObjectManager in interface IVertexBufferObjectpublic boolean isDisposed()
isDisposed in interface IDisposablepublic boolean isAutoDispose()
isAutoDispose in interface IVertexBufferObjectpublic int getHardwareBufferID()
getHardwareBufferID in interface IVertexBufferObjectpublic boolean isLoadedToHardware()
isLoadedToHardware in interface IVertexBufferObjectpublic void setNotLoadedToHardware()
IVertexBufferObjectVertexBufferObject as not not loaded to hardware.
It will reload itself to hardware when it gets used again.setNotLoadedToHardware in interface IVertexBufferObjectpublic boolean isDirtyOnHardware()
isDirtyOnHardware in interface IVertexBufferObjectpublic void setDirtyOnHardware()
IVertexBufferObjectVertexBufferObject dirty so it gets updated on the hardware.setDirtyOnHardware in interface IVertexBufferObjectpublic int getCapacity()
getCapacity in interface IVertexBufferObjectfloats that fit into this IVertexBufferObject.public int getByteCapacity()
getByteCapacity in interface IVertexBufferObjectbytes that fit into this IVertexBufferObject.public int getHeapMemoryByteSize()
getHeapMemoryByteSize in interface IVertexBufferObjectbytes that are allocated on the heap.public int getNativeHeapMemoryByteSize()
getNativeHeapMemoryByteSize in interface IVertexBufferObjectbytes that are allocated on the native heap (through direct ByteBuffers).public int getGPUMemoryByteSize()
getGPUMemoryByteSize in interface IVertexBufferObjectbytes that are allocated on the GPU.protected abstract void onPopulateBufferData(java.nio.ByteBuffer byteBuffer)
public void bind(GLState pGLState)
bind in interface IVertexBufferObjectpublic void bind(GLState pGLState, ShaderProgram pShaderProgram)
bind in interface IVertexBufferObjectpublic void unbind(GLState pGLState, ShaderProgram pShaderProgram)
unbind in interface IVertexBufferObjectpublic void unloadFromHardware(GLState pGLState)
unloadFromHardware in interface IVertexBufferObjectpublic void draw(int pPrimitiveType,
int pCount)
draw in interface IVertexBufferObjectpublic void draw(int pPrimitiveType,
int pOffset,
int pCount)
draw in interface IVertexBufferObjectpublic void dispose()
dispose in interface IDisposableprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwableprotected java.nio.ByteBuffer aquireByteBuffer()
null ByteBuffer is returned by this function, it is guaranteed that releaseByteBuffer(ByteBuffer) is called.ByteBuffer to be passed to onPopulateBufferData(ByteBuffer).protected void releaseByteBuffer(java.nio.ByteBuffer byteBuffer)