Package playn.core
Class UniformQuadBatch
java.lang.Object
playn.core.GLBatch
playn.core.TexturedBatch
playn.core.QuadBatch
playn.core.UniformQuadBatch
- All Implemented Interfaces:
AutoCloseable,Closeable
A batch which renders quads by stuffing them into a big(ish) GLSL uniform variable. Turns out to
work pretty well for 2D rendering as we rarely render more than a modest number of quads before
flushing the shader and it allows us to avoid sending a lot of duplicated data as is necessary
when rendering quads via a batch of triangles.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe source for the stock quad batch shader program.Nested classes/interfaces inherited from interface react.Closeable
Closeable.Set, Closeable.Util -
Field Summary
Fields inherited from class playn.core.TexturedBatch
gl -
Constructor Summary
ConstructorsConstructorDescriptionUniformQuadBatch(GL20 gl) Creates a uniform quad batch with the default shader programs.UniformQuadBatch(GL20 gl, UniformQuadBatch.Source source) Creates a uniform quad batch with the supplied custom shader program builder. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddQuad(int tint, float m00, float m01, float m10, float m11, float tx, float ty, float x1, float y1, float sx1, float sy1, float x2, float y2, float sx2, float sy2, float x3, float y3, float sx3, float sy3, float x4, float y4, float sx4, float sy4) Adds a transformed axis-aligned quad to this batch.voidbegin(float fbufWidth, float fbufHeight, boolean flip) Must be called before this batch is used to accumulate and send drawing commands.voidclose()Releases any GPU resources retained by this batch.voidend()Must be called when one is done using this batch to accumulate and send drawing commands.voidflush()Sends any accumulated drawing calls to the GPU.static booleanReturns false if the GL context doesn't support sufficient numbers of vertex uniform vectors to allow this shader to run with good performance, true otherwise.toString()Methods inherited from class playn.core.TexturedBatch
setTexture
-
Constructor Details
-
UniformQuadBatch
Creates a uniform quad batch with the default shader programs. -
UniformQuadBatch
Creates a uniform quad batch with the supplied custom shader program builder.
-
-
Method Details
-
isLikelyToPerform
Returns false if the GL context doesn't support sufficient numbers of vertex uniform vectors to allow this shader to run with good performance, true otherwise. -
addQuad
public void addQuad(int tint, float m00, float m01, float m10, float m11, float tx, float ty, float x1, float y1, float sx1, float sy1, float x2, float y2, float sx2, float sy2, float x3, float y3, float sx3, float sy3, float x4, float y4, float sx4, float sy4) Description copied from class:QuadBatchAdds a transformed axis-aligned quad to this batch.m00, m01, m10, m11, tx, tydefine the affine transform applied to the quad.x1, y1, .., x4, y4define the corners of the quad.sx1, sy1, .., sx4, sy4define the texture coordinate of the quad. -
begin
public void begin(float fbufWidth, float fbufHeight, boolean flip) Description copied from class:GLBatchMust be called before this batch is used to accumulate and send drawing commands. -
flush
public void flush()Description copied from class:GLBatchSends any accumulated drawing calls to the GPU. Depending on the nature of the batch, this may be necessary before certain state changes (like switching to a new texture). This should be a NOOP if there's nothing to flush. -
end
public void end()Description copied from class:GLBatchMust be called when one is done using this batch to accumulate and send drawing commands. The default implementation callsGLBatch.flush()and marks this batch as inactive.- Overrides:
endin classTexturedBatch
-
close
public void close()Description copied from class:GLBatchReleases any GPU resources retained by this batch. This should be called when the batch will never again be used. -
toString
-