public class TriangleBatch extends QuadBatch
QuadBatch
, but can also render
arbitrary triangles via addTris(playn.core.Texture, int, pythagoras.f.AffineTransform, float[], int, int, float, float, int[], int, int, int)
.Modifier and Type | Class and Description |
---|---|
static class |
TriangleBatch.Source
The source for the stock triangle batch shader program.
|
Closeable.Set, Closeable.Util
gl
Constructor and Description |
---|
TriangleBatch(GL20 gl)
Creates a triangle batch with the default shader program.
|
TriangleBatch(GL20 gl,
TriangleBatch.Source source)
Creates a triangle batch with the supplied custom shader program.
|
Modifier and Type | Method and Description |
---|---|
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)
Adds a transformed axis-aligned quad to this batch.
|
void |
addTris(float[] xys,
float[] sxys,
int xysOffset,
int xysLen,
int[] indices,
int indicesOffset,
int indicesLen,
int indexBase)
Adds triangle primitives to a prepared batch.
|
void |
addTris(float[] xys,
int xysOffset,
int xysLen,
float tw,
float th,
int[] indices,
int indicesOffset,
int indicesLen,
int indexBase)
Adds triangle primitives to a prepared batch.
|
void |
addTris(Texture tex,
int tint,
AffineTransform xf,
float[] xys,
float[] sxys,
int xysOffset,
int xysLen,
int[] indices,
int indicesOffset,
int indicesLen,
int indexBase)
Adds a collection of textured triangles to the current render operation.
|
void |
addTris(Texture tex,
int tint,
AffineTransform xf,
float[] xys,
int xysOffset,
int xysLen,
float tw,
float th,
int[] indices,
int indicesOffset,
int indicesLen,
int indexBase)
Adds a collection of textured triangles to the current render operation.
|
void |
begin(float fbufWidth,
float fbufHeight,
boolean flip)
Must be called before this batch is used to accumulate and send drawing commands.
|
void |
close()
Releases any GPU resources retained by this batch.
|
void |
end()
Must be called when one is done using this batch to accumulate and send drawing commands.
|
void |
flush()
Sends any accumulated drawing calls to the GPU.
|
void |
prepare(int tint,
AffineTransform xf)
Prepares to add primitives with the specified tint and transform.
|
void |
prepare(int tint,
float m00,
float m01,
float m10,
float m11,
float tx,
float ty)
|
java.lang.String |
toString() |
setTexture
public TriangleBatch(GL20 gl)
public TriangleBatch(GL20 gl, TriangleBatch.Source source)
public void prepare(int tint, AffineTransform xf)
stableAttrs
with all of the attributes that are the same for every vertex.public void prepare(int tint, float m00, float m01, float m10, float m11, float tx, float ty)
public void addTris(Texture tex, int tint, AffineTransform xf, float[] xys, int xysOffset, int xysLen, float tw, float th, int[] indices, int indicesOffset, int indicesLen, int indexBase)
xys
- a list of x/y coordinates as: [x1, y1, x2, y2, ...]
.xysOffset
- the offset of the coordinates array, must not be negative and no greater than
xys.length
. Note: this is an absolute offset; since xys
contains pairs of
values, this will be some multiple of two.xysLen
- the number of coordinates to read, must be no less than zero and no greater than
xys.length - xysOffset
. Note: this is an absolute length; since xys
contains
pairs of values, this will be some multiple of two.tw
- the width of the texture for which we will auto-generate texture coordinates.th
- the height of the texture for which we will auto-generate texture coordinates.indices
- the index of the triangle vertices in the xys
array. Because this
method renders a slice of xys
, one must also specify indexBase
which tells us
how to interpret indices. The index into xys
will be computed as:
2*(indices[ii] - indexBase)
, so if your indices reference vertices relative to the
whole array you should pass xysOffset/2
for indexBase
, but if your indices
reference vertices relative to the slice then you should pass zero.indicesOffset
- the offset of the indices array, must not be negative and no greater than
indices.length
.indicesLen
- the number of indices to read, must be no less than zero and no greater than
indices.length - indicesOffset
.indexBase
- the basis for interpreting indices
. See the docs for indices
for details.public void addTris(Texture tex, int tint, AffineTransform xf, float[] xys, float[] sxys, int xysOffset, int xysLen, int[] indices, int indicesOffset, int indicesLen, int indexBase)
addTris(Texture,int,AffineTransform,float[],int,int,float,float,int[],int,int,int)
for parameter documentation.sxys
- a list of sx/sy texture coordinates as: [sx1, sy1, sx2, sy2, ...]
. This
must be of the same length as xys
.public void addTris(float[] xys, int xysOffset, int xysLen, float tw, float th, int[] indices, int indicesOffset, int indicesLen, int indexBase)
TexturedBatch.setTexture(playn.core.Texture)
and prepare(int, pythagoras.f.AffineTransform)
to configure the texture and stable attributes.public void addTris(float[] xys, float[] sxys, int xysOffset, int xysLen, int[] indices, int indicesOffset, int indicesLen, int indexBase)
TexturedBatch.setTexture(playn.core.Texture)
and prepare(int, pythagoras.f.AffineTransform)
to configure the texture and stable attributes.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)
QuadBatch
m00, m01, m10, m11, tx, ty
define the affine transform applied to the quad.
x1, y1, .., x4, y4
define the corners of the quad.
sx1, sy1, .., sx4, sy4
define the texture coordinate of the quad.public void begin(float fbufWidth, float fbufHeight, boolean flip)
GLBatch
public void flush()
GLBatch
public void end()
GLBatch
GLBatch.flush()
and marks this batch as inactive.end
in class TexturedBatch
public void close()
GLBatch
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2019. All Rights Reserved.