@Override public void close() { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] {verticesId, elementsId}, 0); gl.checkError("UniformQuadBatch close"); }
@Override public void flush() { super.flush(); if (quadCounter > 0) { bindTexture(); gl.glUniform4fv(uData, quadCounter * vec4sPerQuad(), data, 0); gl.glDrawElements(GL_TRIANGLES, quadCounter * ELEMENTS_PER_QUAD, GL_UNSIGNED_SHORT, 0); gl.checkError("UniformQuadBatch flush"); quadCounter = 0; } }
@Override public void begin(float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); // TODO: apparently we can avoid glUniform calls because they're part of the program state; so // we can cache the last set values for all these glUniform calls and only set them anew if // they differ... gl.glUniform2f(uHScreenSize, fbufWidth / 2f, fbufHeight / 2f); gl.glUniform1f(uFlip, flip ? -1 : 1); gl.glBindBuffer(GL_ARRAY_BUFFER, verticesId); gl.glEnableVertexAttribArray(aVertex); gl.glVertexAttribPointer(aVertex, VERTEX_SIZE, GL_SHORT, false, 0, 0); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementsId); gl.glActiveTexture(GL_TEXTURE0); gl.glUniform1i(uTexture, 0); gl.checkError("UniformQuadBatch begin"); }
@Override public void end() { super.end(); gl.glDisableVertexAttribArray(aVertex); gl.checkError("UniformQuadBatch end"); }