public class CpuSpriteBatch extends SpriteBatch
SpriteBatch.renderCalls
,
Group.setTransform()
defaultVertexDataType, maxSpritesInBatch, renderCalls, totalRenderCalls
Constructor and Description |
---|
CpuSpriteBatch()
Constructs a CpuSpriteBatch with a size of 1000 and the default shader.
|
CpuSpriteBatch(int size)
Constructs a CpuSpriteBatch with the default shader.
|
CpuSpriteBatch(int size,
ShaderProgram defaultShader)
Constructs a CpuSpriteBatch with a custom shader.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Texture texture,
float[] spriteVertices,
int offset,
int count)
Draws a rectangle using the given vertices.
|
void |
draw(Texture texture,
float x,
float y)
Draws a rectangle with the bottom left corner at x,y having the width and height of the texture.
|
void |
draw(Texture texture,
float x,
float y,
float width,
float height)
Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
|
void |
draw(Texture texture,
float x,
float y,
float width,
float height,
float u,
float v,
float u2,
float v2)
Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
|
void |
draw(Texture texture,
float x,
float y,
float originX,
float originY,
float width,
float height,
float scaleX,
float scaleY,
float rotation,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
boolean flipX,
boolean flipY)
Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
|
void |
draw(Texture texture,
float x,
float y,
float width,
float height,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
boolean flipX,
boolean flipY)
Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
|
void |
draw(Texture texture,
float x,
float y,
int srcX,
int srcY,
int srcWidth,
int srcHeight)
Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
|
void |
draw(TextureRegion region,
float x,
float y)
Draws a rectangle with the bottom left corner at x,y having the width and height of the region.
|
void |
draw(TextureRegion region,
float width,
float height,
Affine2 transform)
Draws a rectangle transformed by the given matrix.
|
void |
draw(TextureRegion region,
float x,
float y,
float width,
float height)
Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
|
void |
draw(TextureRegion region,
float x,
float y,
float originX,
float originY,
float width,
float height,
float scaleX,
float scaleY,
float rotation)
Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
|
void |
draw(TextureRegion region,
float x,
float y,
float originX,
float originY,
float width,
float height,
float scaleX,
float scaleY,
float rotation,
boolean clockwise)
Draws a rectangle with the texture coordinates rotated 90 degrees.
|
void |
flushAndSyncTransformMatrix()
Flushes the batch and realigns the real matrix on the GPU.
|
Matrix4 |
getTransformMatrix()
Returns the current transform matrix.
|
void |
setTransformMatrix(Affine2 transform)
Sets the transform matrix to be used by this Batch.
|
void |
setTransformMatrix(Matrix4 transform)
Sets the transform matrix to be used by this Batch.
|
begin, createDefaultShader, disableBlending, dispose, enableBlending, end, flush, getBlendDstFunc, getBlendDstFuncAlpha, getBlendSrcFunc, getBlendSrcFuncAlpha, getColor, getPackedColor, getProjectionMatrix, getShader, isBlendingEnabled, isDrawing, setBlendFunction, setBlendFunctionSeparate, setColor, setColor, setColor, setProjectionMatrix, setShader
public CpuSpriteBatch()
SpriteBatch.SpriteBatch()
public CpuSpriteBatch(int size)
SpriteBatch.SpriteBatch(int)
public CpuSpriteBatch(int size, ShaderProgram defaultShader)
public void flushAndSyncTransformMatrix()
Flushes the batch and realigns the real matrix on the GPU. Subsequent draws won't need adjustment and will be slightly
faster as long as the transform matrix is not changed
.
Note: The real transform matrix must be invertible. If a singular matrix is detected, GdxRuntimeException will be thrown.
SpriteBatch.flush()
public Matrix4 getTransformMatrix()
Batch
Batch.begin()
/Batch.end()
results in undefined behaviour.getTransformMatrix
in interface Batch
getTransformMatrix
in class SpriteBatch
public void setTransformMatrix(Matrix4 transform)
SpriteBatch.begin()
/SpriteBatch.end()
block,
the current batch is not flushed to the GPU. Instead, for every subsequent draw() the vertices will be transformed
on the CPU to match the original batch matrix. This adjustment must be performed until the matrices are realigned by
restoring the original matrix, or by calling flushAndSyncTransformMatrix()
.setTransformMatrix
in interface Batch
setTransformMatrix
in class SpriteBatch
public void setTransformMatrix(Affine2 transform)
SpriteBatch.begin()
/SpriteBatch.end()
block,
the current batch is not flushed to the GPU. Instead, for every subsequent draw() the vertices will be transformed
on the CPU to match the original batch matrix. This adjustment must be performed until the matrices are realigned by
restoring the original matrix, or by calling flushAndSyncTransformMatrix()
or SpriteBatch.end()
.public void draw(Texture texture, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
Batch
Texture
given by srcX, srcY and srcWidth, srcHeight is used. These coordinates and sizes are given in
texels. FlipX and flipY specify whether the texture portion should be flipped horizontally or vertically.draw
in interface Batch
draw
in class SpriteBatch
x
- the x-coordinate in screen spacey
- the y-coordinate in screen spaceoriginX
- the x-coordinate of the scaling and rotation origin relative to the screen space coordinatesoriginY
- the y-coordinate of the scaling and rotation origin relative to the screen space coordinateswidth
- the width in pixelsheight
- the height in pixelsscaleX
- the scale of the rectangle around originX/originY in xscaleY
- the scale of the rectangle around originX/originY in yrotation
- the angle of counter clockwise rotation of the rectangle around originX/originYsrcX
- the x-coordinate in texel spacesrcY
- the y-coordinate in texel spacesrcWidth
- the source with in texelssrcHeight
- the source height in texelsflipX
- whether to flip the sprite horizontallyflipY
- whether to flip the sprite verticallypublic void draw(Texture texture, float x, float y, float width, float height, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
Batch
Texture
given by srcX, srcY and srcWidth, srcHeight is used. These coordinates and sizes are given in texels. FlipX
and flipY specify whether the texture portion should be flipped horizontally or vertically.draw
in interface Batch
draw
in class SpriteBatch
x
- the x-coordinate in screen spacey
- the y-coordinate in screen spacewidth
- the width in pixelsheight
- the height in pixelssrcX
- the x-coordinate in texel spacesrcY
- the y-coordinate in texel spacesrcWidth
- the source with in texelssrcHeight
- the source height in texelsflipX
- whether to flip the sprite horizontallyflipY
- whether to flip the sprite verticallypublic void draw(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight)
Batch
Texture
given by srcX, srcY and srcWidth, srcHeight are used. These coordinates and sizes are given in texels.draw
in interface Batch
draw
in class SpriteBatch
x
- the x-coordinate in screen spacey
- the y-coordinate in screen spacesrcX
- the x-coordinate in texel spacesrcY
- the y-coordinate in texel spacesrcWidth
- the source with in texelssrcHeight
- the source height in texelspublic void draw(Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2)
Batch
Texture
given by u, v and u2, v2 are used. These coordinates and sizes are given in texture size percentage. The
rectangle will have the given tint Color
.draw
in interface Batch
draw
in class SpriteBatch
x
- the x-coordinate in screen spacey
- the y-coordinate in screen spacewidth
- the width in pixelsheight
- the height in pixelspublic void draw(Texture texture, float x, float y)
Batch
draw
in interface Batch
draw
in class SpriteBatch
x
- the x-coordinate in screen spacey
- the y-coordinate in screen spacepublic void draw(Texture texture, float x, float y, float width, float height)
Batch
draw
in interface Batch
draw
in class SpriteBatch
public void draw(TextureRegion region, float x, float y)
Batch
draw
in interface Batch
draw
in class SpriteBatch
public void draw(TextureRegion region, float x, float y, float width, float height)
Batch
draw
in interface Batch
draw
in class SpriteBatch
public void draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)
Batch
draw
in interface Batch
draw
in class SpriteBatch
public void draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, boolean clockwise)
Batch
draw
in interface Batch
draw
in class SpriteBatch
clockwise
- If true, the texture coordinates are rotated 90 degrees clockwise. If false, they are rotated 90 degrees
counter clockwise.public void draw(Texture texture, float[] spriteVertices, int offset, int count)
Batch
Batch.getColor()
from the Batch is not applied.draw
in interface Batch
draw
in class SpriteBatch
public void draw(TextureRegion region, float width, float height, Affine2 transform)
Batch
draw
in interface Batch
draw
in class SpriteBatch
Copyright © 2017. All rights reserved.