public void unbind() { GL11 gl = (GL11) glGraphics.getGL(); if (hasTexCoords) gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); if (hasColor) gl.glDisableClientState(GL10.GL_COLOR_ARRAY); if (hasNormals) gl.glDisableClientState(GL10.GL_NORMAL_ARRAY); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0); }
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); }