public abstract class VertexBufferObject extends java.lang.Object implements IVertexBufferObject
VertexBufferObject and ZeroMemoryVertexBufferObject (due to significant code duplication).
For naming, maybe be inspired by the java ByteBuffer naming (i.e. HeapBackedFloatArrayVertexBufferObject, StreamBufferVertexBufferObject, SharedBufferStreamVertexBufferObject).
(c) 2010 Nicolas Gramlich
(c) 2011 Zynga Inc.IDisposable.AlreadyDisposedException| Modifier and Type | Field and Description |
|---|---|
protected boolean |
mAutoDispose |
protected java.nio.ByteBuffer |
mByteBuffer |
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 |
|---|
VertexBufferObject(VertexBufferObjectManager pVertexBufferObjectManager,
int pCapacity,
DrawType pDrawType,
boolean pAutoDispose,
VertexBufferObjectAttributes pVertexBufferObjectAttributes) |
| Modifier and Type | Method and Description |
|---|---|
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() |
VertexBufferObjectManager |
getVertexBufferObjectManager() |
boolean |
isAutoDispose() |
boolean |
isDirtyOnHardware() |
boolean |
isDisposed() |
boolean |
isLoadedToHardware() |
protected abstract void |
onBufferData() |
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) |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHeapMemoryByteSize, getNativeHeapMemoryByteSizeprotected final int mCapacity
protected final boolean mAutoDispose
protected final int mUsage
protected final java.nio.ByteBuffer mByteBuffer
protected int mHardwareBufferID
protected boolean mDirtyOnHardware
protected boolean mDisposed
protected final VertexBufferObjectManager mVertexBufferObjectManager
protected final VertexBufferObjectAttributes mVertexBufferObjectAttributes
public VertexBufferObject(VertexBufferObjectManager pVertexBufferObjectManager, int pCapacity, DrawType pDrawType, boolean pAutoDispose, VertexBufferObjectAttributes pVertexBufferObjectAttributes)
pVertexBufferObjectManager - (Optional, if you manage reloading on your own.)pCapacity - pDrawType - pAutoDispose - when passing true this VertexBufferObject loads itself to the active VertexBufferObjectManager. WARNING: When passing false one needs to take care of that by oneself!pVertexBufferObjectAttributes - to be automatically enabled on the ShaderProgram used in VertexBufferObject#bind(ShaderProgram).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 getGPUMemoryByteSize()
getGPUMemoryByteSize in interface IVertexBufferObjectbytes that are allocated on the GPU.protected abstract void onBufferData()
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.Throwable