public abstract class GLInstancedRenderable
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.List<GLInstanceData> |
_drawInstances |
protected int |
_drawVersion |
protected int |
_instanceLimit |
protected LocalCoordinateSystem |
_lcs |
protected java.nio.FloatBuffer |
_mxBuffer |
protected int[] |
_mxBufferID |
protected long |
_mxBufferPtr |
protected int |
_mxBufferSize |
protected java.lang.String |
_name |
protected java.util.List<GLInstanceData> |
_pendingInstances |
protected java.lang.Integer |
_programID |
protected boolean |
_released |
protected int |
_renderPass |
protected int[] |
_vao |
protected static int |
SIZE_BUF |
protected static int |
SIZE_MAT4 |
protected static int |
SIZE_VEC2 |
protected static int |
SIZE_VEC3 |
protected static int |
SIZE_VEC4 |
Constructor and Description |
---|
GLInstancedRenderable(java.lang.String name,
int renderPass) |
Modifier and Type | Method and Description |
---|---|
void |
addInstance(GLInstanceData instance)
Add an instance of this mesh to be drawn
|
protected abstract java.lang.Integer |
compileShader()
Compile the main program shader
|
protected static int |
compileShader(java.lang.String vtxShader,
java.lang.String fragShader)
Compile the main program shader
|
protected static java.nio.FloatBuffer |
createFloatBuffer(int size)
Create a simple float buffer in native memory
|
protected static int[] |
deleteBuffers(java.nio.Buffer buffer,
int[] bufIndex)
Delete a buffer and return null so we can nullify the reference in 1 line
|
protected static int[] |
deleteBuffers(int[] bufIndex) |
void |
draw(GLMapView view,
int renderPass) |
protected abstract void |
drawInstanced(GLMapView view)
Perform instanced draw calls here
At this point the matrices have been set up
|
protected void |
expandInstanceBuffers() |
void |
flagRelease() |
protected int |
getNumInstances()
Get the number of instances to draw
Use this for your glDrawArraysInstanced call
|
protected abstract int |
getPositionPointer()
Get the layout index of the location pointer (the matrix used to position the renderable)
|
int |
getRenderPass() |
void |
release() |
void |
reset()
Reset instance data
|
protected static int[] |
setupInstanceBuffer(java.nio.Buffer buffer,
int size)
Setup an instance buffer
|
protected static void |
setupInstancePointer(int idx,
int size,
int stride,
int offset)
Setup instance pointer
|
protected abstract void |
setupVertexBuffers()
Setup vertex buffers
|
protected void |
updateMatrices(GLMapView view) |
protected static final int SIZE_BUF
protected static final int SIZE_VEC2
protected static final int SIZE_VEC3
protected static final int SIZE_VEC4
protected static final int SIZE_MAT4
protected final java.lang.String _name
protected final int _renderPass
protected java.lang.Integer _programID
protected int _drawVersion
protected final java.util.List<GLInstanceData> _drawInstances
protected final java.util.List<GLInstanceData> _pendingInstances
protected int[] _vao
protected int _instanceLimit
protected LocalCoordinateSystem _lcs
protected boolean _released
protected int[] _mxBufferID
protected int _mxBufferSize
protected long _mxBufferPtr
protected java.nio.FloatBuffer _mxBuffer
public GLInstancedRenderable(java.lang.String name, int renderPass)
public int getRenderPass()
public void reset()
public void addInstance(GLInstanceData instance)
instance
- Instance dataprotected int getNumInstances()
protected abstract java.lang.Integer compileShader()
public void draw(GLMapView view, int renderPass)
protected abstract void setupVertexBuffers()
protected abstract void drawInstanced(GLMapView view)
view
- Map viewprotected abstract int getPositionPointer()
protected void expandInstanceBuffers()
protected void updateMatrices(GLMapView view)
public void release()
public void flagRelease()
protected static int compileShader(java.lang.String vtxShader, java.lang.String fragShader)
protected static int[] deleteBuffers(java.nio.Buffer buffer, int[] bufIndex)
buffer
- Buffer to delete (null to ignore)bufIndex
- Buffer index (null to ignore)protected static int[] deleteBuffers(int[] bufIndex)
protected static java.nio.FloatBuffer createFloatBuffer(int size)
size
- Size of buffer in bytesprotected static int[] setupInstanceBuffer(java.nio.Buffer buffer, int size)
buffer
- Underlying buffer datasize
- Size of bufferprotected static void setupInstancePointer(int idx, int size, int stride, int offset)
idx
- Vertex attribute array index (see vertex shader layout locations)size
- Size of each data point in the bufferstride
- Data stride in bytesoffset
- Offset in bytes