/** Adds {@code tex} as a transformed axis-aligned quad to this batch. * {@code dx, dy, dw, dh} define the size and position of the quad. * {@code sx, sy, sw, sh} define region of the texture which will be displayed in the quad. */ public void addQuad (Texture tex, int tint, AffineTransform xf, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { setTexture(tex); float texWidth = tex.displayWidth, texHeight = tex.displayHeight; addQuad(tint, xf, dx, dy, dx+dw, dy+dh, sx/texWidth, sy/texHeight, (sx+sw)/texWidth, (sy+sh)/texHeight); }
/** Completes a series of drawing commands to this surface. */ public Surface end () { batch.end(); return this; }
/** Adds a transformed axis-aligned quad to this batch. * {@code left, top, right, bottom} define the bounds of the quad. * {@code sl, st, sr, sb} define the texture coordinates. */ public void addQuad (int tint, AffineTransform xf, float left, float top, float right, float bottom, float sl, float st, float sr, float sb) { addQuad(tint, xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, left, top, right, bottom, sl, st, sr, sb); }
/** 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"); }
private QuadBatch beginBatch (QuadBatch batch) { batch.begin(target.width(), target.height(), target.flip()); return batch; }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("TriangleBatch close"); }
@Override public void addToBatch (QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { batch.addQuad(this, tint, tx, dx, dy, dw, dh, sx, sy, sw, sh); }
/** 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"); }
private QuadBatch beginBatch (QuadBatch batch) { batch.begin(target.width(), target.height(), target.flip()); return batch; }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("UniformQuadBatch close"); }
/** Adds {@code tex} as a transformed axis-aligned quad to this batch. * {@code dx, dy, dw, dh} define the size and position of the quad. * {@code sx, sy, sw, sh} define region of the texture which will be displayed in the quad. */ public void addQuad (Texture tex, int tint, AffineTransform xf, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { setTexture(tex); float texWidth = tex.displayWidth, texHeight = tex.displayHeight; addQuad(tint, xf, dx, dy, dx+dw, dy+dh, sx/texWidth, sy/texHeight, (sx+sw)/texWidth, (sy+sh)/texHeight); }
@Override public void addToBatch (QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { batch.addQuad(this, tint, tx, dx, dy, dw, dh, sx, sy, sw, sh); }
/** Completes a series of drawing commands to this surface. */ public Surface end () { batch.end(); return this; }
@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 close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("UniformQuadBatch close"); }
/** Adds {@code tex} as a transformed axis-aligned quad to this batch. * {@code x, y, w, h} define the size and position of the quad. */ public void addQuad (Texture tex, int tint, AffineTransform xf, float x, float y, float w, float h) { setTexture(tex); float sr = tex.config.repeatX ? w/tex.displayWidth : 1; float sb = tex.config.repeatY ? h/tex.displayHeight : 1; addQuad(tint, xf, x, y, x+w, y+h, 0, 0, sr, sb); }
/** Adds a transformed axis-aligned quad to this batch. * {@code m00, m01, m10, m11, tx, ty} define the affine transform applied to the quad. * {@code left, top, right, bottom} define the bounds of the quad. * {@code sl, st, sr, sb} define the texture coordinates. */ public void addQuad (int tint, float m00, float m01, float m10, float m11, float tx, float ty, float left, float top, float right, float bottom, float sl, float st, float sr, float sb) { addQuad(tint, m00, m01, m10, m11, tx, ty, left, top, sl, st, right, top, sr, st, left, bottom, sl, sb, right, bottom, sr, sb); }
/** Configures this surface to use {@code batch}, if non-null. NOOPs otherwise. * @return a batch which should be passed to {@link #popBatch} when rendering is done with this * batch. */ public QuadBatch pushBatch (QuadBatch newBatch) { if (newBatch == null) return null; QuadBatch oldBatch = batch; batch.end(); batch = beginBatch(newBatch); return oldBatch; }
@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; } }