protected int beginPrimitive(int vertexCount, int elemCount) { int vertIdx = vertices.position() / vertexSize(); int verts = vertIdx + vertexCount, elems = elements.position() + elemCount; int availVerts = vertices.capacity() / vertexSize(), availElems = elements.capacity(); if ((verts > availVerts) || (elems > availElems)) { IndexedTrisShader.this.flush(); if (verts > availVerts) expandVerts(verts); if (elems > availElems) expandElems(elems); return 0; } return vertIdx; }
protected int vertexStride() { return vertexSize() * FLOAT_SIZE_BYTES; }
public ITCore(String vertShader, String fragShader) { super(vertShader, fragShader); // determine our various shader program locations uScreenSize = prog.getUniform2f("u_ScreenSize"); aMatrix = prog.getAttrib("a_Matrix", 4, GL20.GL_FLOAT); aTranslation = prog.getAttrib("a_Translation", 2, GL20.GL_FLOAT); aColor = prog.getAttrib("a_Color", 2, GL20.GL_FLOAT); aPosition = prog.getAttrib("a_Position", 2, GL20.GL_FLOAT); aTexCoord = prog.getAttrib("a_TexCoord", 2, GL20.GL_FLOAT); // create our vertex and index buffers stableAttrs = new float[stableAttrsSize()]; vertices = ctx.createFloatBuffer(START_VERTS*vertexSize()); elements = ctx.createShortBuffer(START_ELEMS); }
private void expandVerts(int vertCount) { int newVerts = vertices.capacity() / vertexSize(); while (newVerts < vertCount) newVerts += EXPAND_VERTS; vertices.expand(newVerts*vertexSize()); }