public void bind() { GL11 gl = (GL11) glGraphics.getGL(); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, vboHandle); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glVertexPointer(3, GL10.GL_FLOAT, vertexSize, 0); if (hasColor) { gl.glEnableClientState(GL10.GL_COLOR_ARRAY); gl.glColorPointer(4, GL10.GL_FLOAT, vertexSize, 3 * 4); } if (hasTexCoords) { gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL10.GL_FLOAT, vertexSize, (hasColor ? 7 : 3) * 4); } if (hasNormals) { gl.glEnableClientState(GL10.GL_NORMAL_ARRAY); int offset = 3; if (hasColor) offset += 4; if (hasTexCoords) offset += 2; gl.glNormalPointer(GL10.GL_FLOAT, vertexSize, offset * 4); } }
public void onDrawFrame(GL10 gl10, boolean fpsTimeElapsed) { GL11 gl = (GL11) gl10; updateWithDelta(1.0f / MAXIMUM_UPDATE_RATE); synchronized (transforms) { if (fpsTimeElapsed) { onTransform(); } } sourcePosition.x = x; sourcePosition.y = y; gl.glMatrixMode(GL11.GL_MODELVIEW); gl.glLoadIdentity(); gl.glEnableClientState(GL11.GL_COLOR_ARRAY); // unbind all buffers gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0); gl.glBindTexture(GL11.GL_TEXTURE_2D, 0); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, verticesID[0]); // Using glBufferSubData means that a copy is done from the quads array to the buffer rather // than recreating the buffer which // would be an allocation and copy. The copy also only takes over the number of live particles. // This provides a nice performance // boost. quadsBuffer.put(quads); quadsBuffer.position(0); gl.glBufferSubData(GL11.GL_ARRAY_BUFFER, 0, 128 * particleIndex, quadsBuffer); // Configure the vertex pointer which will use the currently bound VBO for its data gl.glVertexPointer(2, GL11.GL_FLOAT, 32, 0); gl.glColorPointer(4, GL11.GL_FLOAT, 32, (4 * 4)); gl.glTexCoordPointer(2, GL11.GL_FLOAT, 32, (4 * 2)); if (hasTexture) { gl.glEnable(GL11.GL_TEXTURE_2D); gl.glBindTexture(GL11.GL_TEXTURE_2D, getTexture().getTextureId()); } gl.glBlendFunc(srcBlendFactor, dstBlendFactor); gl.glDrawElements(GL11.GL_TRIANGLES, particleIndex * 6, GL11.GL_UNSIGNED_SHORT, indicesBuffer); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0); gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); gl.glDisableClientState(GL11.GL_COLOR_ARRAY); }
public synchronized void draw(GL11 gl) { super.draw(gl); if (fontIndexCount > 0) { gl.glBindTexture(GL11.GL_TEXTURE_2D, mFont.id); gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, mTextureBuffer); gl.glVertexPointer(3, GL11.GL_FLOAT, 0, mVertexBuffer); gl.glColorPointer(4, GL11.GL_FIXED, 0, mColorBuffer); mIndexBuffer.position(indStart); mColorBuffer.position(colorStart); mVertexBuffer.position(vertStart); mTextureBuffer.position(texStart); gl.glDrawElements(GL11.GL_TRIANGLES, fontIndexCount, GL11.GL_UNSIGNED_SHORT, mIndexBuffer); } }
@Override public void glColorPointer(int size, int type, int stride, int pointer) { gl.glColorPointer(size, type, stride, pointer); }