Package gaiasky.util.gdx.g2d
Interface ExtBatch
-
- All Known Implementing Classes:
ExtSpriteBatch
public interface ExtBatch
-
-
Field Summary
Fields Modifier and Type Field Description static intC1static intC2static intC3static intC4static intU1static intU2static intU3static intU4static intV1static intV2static intV3static intV4static intX1static intX2static intX3static intX4static intY1static intY2static intY3static intY4
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbegin()Sets up the Batch for drawing.voiddisableBlending()Disables blending for drawing sprites.voiddraw(com.badlogic.gdx.graphics.Texture texture, float[] spriteVertices, int offset, int count)Draws a rectangle using the given vertices.voiddraw(com.badlogic.gdx.graphics.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.voiddraw(com.badlogic.gdx.graphics.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.voiddraw(com.badlogic.gdx.graphics.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.voiddraw(com.badlogic.gdx.graphics.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.voiddraw(com.badlogic.gdx.graphics.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.voiddraw(com.badlogic.gdx.graphics.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.voiddraw(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.voiddraw(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.voiddraw(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.voiddraw(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.voiddraw(TextureRegion region, float width, float height, com.badlogic.gdx.math.Affine2 transform)Draws a rectangle transformed by the given matrix.voidenableBlending()Enables blending for drawing sprites.voidend()Finishes off rendering.voidflush()Causes any pending sprites to be rendered, without ending the Batch.intgetBlendDstFunc()intgetBlendDstFuncAlpha()intgetBlendSrcFunc()intgetBlendSrcFuncAlpha()com.badlogic.gdx.graphics.ColorgetColor()floatgetPackedColor()com.badlogic.gdx.math.Matrix4getProjectionMatrix()Returns the current projection matrix.ExtShaderProgramgetShader()com.badlogic.gdx.math.Matrix4getTransformMatrix()Returns the current transform matrix.booleanisBlendingEnabled()booleanisDrawing()voidsetBlendFunction(int srcFunc, int dstFunc)Sets the blending function to be used when rendering sprites.voidsetBlendFunctionSeparate(int srcFuncColor, int dstFuncColor, int srcFuncAlpha, int dstFuncAlpha)Sets separate (color/alpha) blending function to be used when rendering sprites.voidsetColor(float r, float g, float b, float a)voidsetColor(com.badlogic.gdx.graphics.Color tint)Sets the color used to tint images when they are added to the Batch.voidsetPackedColor(float packedColor)Sets the rendering color of this Batch, expanding the alpha from 0-254 to 0-255.voidsetProjectionMatrix(com.badlogic.gdx.math.Matrix4 projection)Sets the projection matrix to be used by this Batch.voidsetShader(ExtShaderProgram shader)Sets the shader to be used in a GLES 2.0 environment.voidsetTransformMatrix(com.badlogic.gdx.math.Matrix4 transform)Sets the transform matrix to be used by this Batch.
-
-
-
Field Detail
-
X1
static final int X1
- See Also:
- Constant Field Values
-
Y1
static final int Y1
- See Also:
- Constant Field Values
-
C1
static final int C1
- See Also:
- Constant Field Values
-
U1
static final int U1
- See Also:
- Constant Field Values
-
V1
static final int V1
- See Also:
- Constant Field Values
-
X2
static final int X2
- See Also:
- Constant Field Values
-
Y2
static final int Y2
- See Also:
- Constant Field Values
-
C2
static final int C2
- See Also:
- Constant Field Values
-
U2
static final int U2
- See Also:
- Constant Field Values
-
V2
static final int V2
- See Also:
- Constant Field Values
-
X3
static final int X3
- See Also:
- Constant Field Values
-
Y3
static final int Y3
- See Also:
- Constant Field Values
-
C3
static final int C3
- See Also:
- Constant Field Values
-
U3
static final int U3
- See Also:
- Constant Field Values
-
V3
static final int V3
- See Also:
- Constant Field Values
-
X4
static final int X4
- See Also:
- Constant Field Values
-
Y4
static final int Y4
- See Also:
- Constant Field Values
-
C4
static final int C4
- See Also:
- Constant Field Values
-
U4
static final int U4
- See Also:
- Constant Field Values
-
V4
static final int V4
- See Also:
- Constant Field Values
-
-
Method Detail
-
begin
void begin()
Sets up the Batch for drawing. This will disable depth buffer writing. It enables blending and texturing. If you have more texture units enabled than the first one you have to disable them before calling this. Uses a screen coordinate system by default where everything is given in pixels. You can specify your own projection and modelview matrices viasetProjectionMatrix(Matrix4)andsetTransformMatrix(Matrix4).
-
end
void end()
Finishes off rendering. Enables depth writes, disables blending and texturing. Must always be called after a call tobegin()
-
setColor
void setColor(com.badlogic.gdx.graphics.Color tint)
Sets the color used to tint images when they are added to the Batch. Default isColor.WHITE.
-
setColor
void setColor(float r, float g, float b, float a)- See Also:
setColor(Color)
-
getColor
com.badlogic.gdx.graphics.Color getColor()
- Returns:
- the rendering color of this Batch. If the returned instance is manipulated,
setColor(Color)must be called afterward.
-
setPackedColor
void setPackedColor(float packedColor)
Sets the rendering color of this Batch, expanding the alpha from 0-254 to 0-255.- See Also:
setColor(Color),Color.toFloatBits()
-
getPackedColor
float getPackedColor()
- Returns:
- the rendering color of this Batch in vertex format (alpha compressed to 0-254)
- See Also:
Color.toFloatBits()
-
draw
void draw(com.badlogic.gdx.graphics.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. The rectangle is offset by originX, originY relative to the origin. Scale specifies the scaling factor by which the rectangle should be scaled around originX, originY. Rotation specifies the angle of counter clockwise rotation of the rectangle around originX, originY. The portion of theTexturegiven 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.- Parameters:
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 vertically
-
draw
void draw(com.badlogic.gdx.graphics.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. The portion of theTexturegiven 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.- Parameters:
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 vertically
-
draw
void draw(com.badlogic.gdx.graphics.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. The portion of theTexturegiven by srcX, srcY and srcWidth, srcHeight are used. These coordinates and sizes are given in texels.- Parameters:
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 texels
-
draw
void draw(com.badlogic.gdx.graphics.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. The portion of theTexturegiven by u, v and u2, v2 are used. These coordinates and sizes are given in texture size percentage. The rectangle will have the given tintColor.- Parameters:
x- the x-coordinate in screen spacey- the y-coordinate in screen spacewidth- the width in pixelsheight- the height in pixels
-
draw
void draw(com.badlogic.gdx.graphics.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.- Parameters:
x- the x-coordinate in screen spacey- the y-coordinate in screen space
-
draw
void draw(com.badlogic.gdx.graphics.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.
-
draw
void draw(com.badlogic.gdx.graphics.Texture texture, float[] spriteVertices, int offset, int count)Draws a rectangle using the given vertices. There must be 4 vertices, each made up of 5 elements in this order: x, y, color, u, v. ThegetColor()from the Batch is not applied.
-
draw
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.
-
draw
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.
-
draw
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. The rectangle is offset by originX, originY relative to the origin. Scale specifies the scaling factor by which the rectangle should be scaled around originX, originY. Rotation specifies the angle of counter clockwise rotation of the rectangle around originX, originY.
-
draw
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. The bottom left corner at x,y and stretching the region to cover the given width and height. The rectangle is offset by originX, originY relative to the origin. Scale specifies the scaling factor by which the rectangle should be scaled around originX, originY. Rotation specifies the angle of counter clockwise rotation of the rectangle around originX, originY.- Parameters:
clockwise- If true, the texture coordinates are rotated 90 degrees clockwise. If false, they are rotated 90 degrees counter clockwise.
-
draw
void draw(TextureRegion region, float width, float height, com.badlogic.gdx.math.Affine2 transform)
Draws a rectangle transformed by the given matrix.
-
flush
void flush()
Causes any pending sprites to be rendered, without ending the Batch.
-
disableBlending
void disableBlending()
-
enableBlending
void enableBlending()
-
setBlendFunction
void setBlendFunction(int srcFunc, int dstFunc)Sets the blending function to be used when rendering sprites.- Parameters:
srcFunc- the source function, e.g. GL20.GL_SRC_ALPHA. If set to -1, Batch won't change the blending function.dstFunc- the destination function, e.g. GL20.GL_ONE_MINUS_SRC_ALPHA
-
setBlendFunctionSeparate
void setBlendFunctionSeparate(int srcFuncColor, int dstFuncColor, int srcFuncAlpha, int dstFuncAlpha)Sets separate (color/alpha) blending function to be used when rendering sprites.- Parameters:
srcFuncColor- the source color function, e.g. GL20.GL_SRC_ALPHA. If set to -1, Batch won't change the blending function.dstFuncColor- the destination color function, e.g. GL20.GL_ONE_MINUS_SRC_ALPHA.srcFuncAlpha- the source alpha function, e.g. GL20.GL_SRC_ALPHA.dstFuncAlpha- the destination alpha function, e.g. GL20.GL_ONE_MINUS_SRC_ALPHA.
-
getBlendSrcFunc
int getBlendSrcFunc()
-
getBlendDstFunc
int getBlendDstFunc()
-
getBlendSrcFuncAlpha
int getBlendSrcFuncAlpha()
-
getBlendDstFuncAlpha
int getBlendDstFuncAlpha()
-
getProjectionMatrix
com.badlogic.gdx.math.Matrix4 getProjectionMatrix()
-
getTransformMatrix
com.badlogic.gdx.math.Matrix4 getTransformMatrix()
-
setProjectionMatrix
void setProjectionMatrix(com.badlogic.gdx.math.Matrix4 projection)
-
setTransformMatrix
void setTransformMatrix(com.badlogic.gdx.math.Matrix4 transform)
Sets the transform matrix to be used by this Batch.
-
setShader
void setShader(ExtShaderProgram shader)
Sets the shader to be used in a GLES 2.0 environment. Vertex position attribute is called "a_position", the texture coordinates attribute is called "a_texCoord0", the color attribute is called "a_color". SeeExtShaderProgram.POSITION_ATTRIBUTE,ExtShaderProgram.COLOR_ATTRIBUTEandExtShaderProgram.TEXCOORD_ATTRIBUTEwhich gets "0" appended to indicate the use of the first texture unit. The combined transform and projection matrx is uploaded via a mat4 uniform called "u_projTrans". The texture sampler is passed via a uniform called "u_texture".Call this method with a null argument to use the default shader.
This method will flush the batch before setting the new shader, you can call it in between
begin()andend().- Parameters:
shader- theExtShaderProgramor null to use the default shader.
-
getShader
ExtShaderProgram getShader()
- Returns:
- the current
ExtShaderProgramset bysetShader(ExtShaderProgram)or the defaultShader
-
isBlendingEnabled
boolean isBlendingEnabled()
- Returns:
- true if blending for sprites is enabled
-
isDrawing
boolean isDrawing()
- Returns:
- true if currently between begin and end.
-
-