/** Binds our current texture. Subclasses need to call this in {@link #flush}. */ protected void bindTexture () { gl.glBindTexture(GL20.GL_TEXTURE_2D, curTexId); gl.checkError("QuadBatch glBindTexture"); } }
/** Binds our current texture. Subclasses need to call this in {@link #flush}. */ protected void bindTexture () { gl.glBindTexture(GL20.GL_TEXTURE_2D, curTexId); gl.checkError("QuadBatch glBindTexture"); } }
@Override public void end () { super.end(); gl.glDisableVertexAttribArray(aVertex); gl.checkError("UniformQuadBatch end"); }
@Override protected void upload (Graphics gfx, Texture tex) { gfx.gl.glBindTexture(GL20.GL_TEXTURE_2D, tex.id); GLUtils.texImage2D(GL20.GL_TEXTURE_2D, 0, bitmap, 0); gfx.gl.checkError("updateTexture end"); }
@Override public void end () { super.end(); gl.glDisableVertexAttribArray(aVertex); gl.checkError("UniformQuadBatch end"); }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("TriangleBatch close"); }
@Override public void flush () { super.flush(); if (vertPos > 0) { bindTexture(); if (delayedBinding) { bindAttribsBufs(); // see comments in activate() gl.checkError("TriangleBatch.flush bind"); } gl.bufs.setFloatBuffer(vertices, 0, vertPos); gl.glBufferData(GL_ARRAY_BUFFER, vertPos*4, gl.bufs.floatBuffer, GL_STREAM_DRAW); gl.bufs.setShortBuffer(elements, 0, elemPos); gl.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elemPos*2, gl.bufs.shortBuffer, GL_STREAM_DRAW); gl.checkError("TriangleBatch.flush BufferData"); gl.glDrawElements(GL_TRIANGLES, elemPos, GL_UNSIGNED_SHORT, 0); gl.checkError("TriangleBatch.flush DrawElements"); vertPos = 0; elemPos = 0; } }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("UniformQuadBatch close"); }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("UniformQuadBatch close"); }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("TriangleBatch close"); }
/** Ends a series of drawing commands that were clipped per a call to {@link #startClipped}. */ public void endClipped () { batch.flush(); // flush our clipped calls with SCISSOR_TEST still enabled Rectangle r = popScissorState(); if (r == null) batch.gl.glDisable(GL20.GL_SCISSOR_TEST); else batch.gl.glScissor(r.x, r.y, r.width, r.height); batch.gl.checkError("endClipped"); }
/** Ends a series of drawing commands that were clipped per a call to {@link #startClipped}. */ public void endClipped () { batch.flush(); // flush our clipped calls with SCISSOR_TEST still enabled Rectangle r = popScissorState(); if (r == null) batch.gl.glDisable(GL20.GL_SCISSOR_TEST); else batch.gl.glScissor(r.x, r.y, r.width, r.height); batch.gl.checkError("endClipped"); }
@Override public void begin (float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); gl.glUniform2f(uHScreenSize, fbufWidth/2f, fbufHeight/2f); gl.glUniform1f(uFlip, flip ? -1 : 1); // certain graphics cards (I'm looking at you, Intel) exhibit broken behavior if we bind our // attributes once during activation, so for those cards we bind every time in flush() if (!delayedBinding) bindAttribsBufs(); gl.checkError("TriangleBatch begin"); }
@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 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(); gl.glUniform2f(uHScreenSize, fbufWidth/2f, fbufHeight/2f); gl.glUniform1f(uFlip, flip ? -1 : 1); // certain graphics cards (I'm looking at you, Intel) exhibit broken behavior if we bind our // attributes once during activation, so for those cards we bind every time in flush() if (!delayedBinding) bindAttribsBufs(); gl.checkError("TriangleBatch begin"); }
@Override public void end () { super.end(); gl.glDisableVertexAttribArray(aMatrix); gl.glDisableVertexAttribArray(aTranslation); gl.glDisableVertexAttribArray(aColor); gl.glDisableVertexAttribArray(aPosition); gl.glDisableVertexAttribArray(aTexCoord); gl.checkError("TriangleBatch end"); }
@Override public void end () { super.end(); gl.glDisableVertexAttribArray(aMatrix); gl.glDisableVertexAttribArray(aTranslation); gl.glDisableVertexAttribArray(aColor); gl.glDisableVertexAttribArray(aPosition); gl.glDisableVertexAttribArray(aTexCoord); gl.checkError("TriangleBatch end"); }
/** Starts a series of drawing commands that are clipped to the specified rectangle (in view * coordinates, not OpenGL coordinates). Thus must be followed by a call to {@link #endClipped} * when the clipped drawing commands are done. * * @return whether the resulting clip rectangle is non-empty. <em>Note:</em> the caller may wish * to skip their drawing if this returns false, but they must still call {@link #endClipped}. */ public boolean startClipped (int x, int y, int width, int height) { batch.flush(); // flush any pending unclipped calls Rectangle r = pushScissorState(x, target.flip() ? target.height()-y-height : y, width, height); batch.gl.glScissor(r.x, r.y, r.width, r.height); if (scissorDepth == 1) batch.gl.glEnable(GL20.GL_SCISSOR_TEST); batch.gl.checkError("startClipped"); return !r.isEmpty(); }
/** Starts a series of drawing commands that are clipped to the specified rectangle (in view * coordinates, not OpenGL coordinates). Thus must be followed by a call to {@link #endClipped} * when the clipped drawing commands are done. * * @return whether the resulting clip rectangle is non-empty. <em>Note:</em> the caller may wish * to skip their drawing if this returns false, but they must still call {@link #endClipped}. */ public boolean startClipped (int x, int y, int width, int height) { batch.flush(); // flush any pending unclipped calls Rectangle r = pushScissorState(x, target.flip() ? target.height()-y-height : y, width, height); batch.gl.glScissor(r.x, r.y, r.width, r.height); if (scissorDepth == 1) batch.gl.glEnable(GL20.GL_SCISSOR_TEST); batch.gl.checkError("startClipped"); return !r.isEmpty(); }