Class SpriteBatchWithZAxis

  • All Implemented Interfaces:
    com.badlogic.gdx.graphics.g2d.Batch, com.badlogic.gdx.utils.Disposable


    public class SpriteBatchWithZAxis
    extends java.lang.Object
    implements com.badlogic.gdx.graphics.g2d.Batch
    Draws batched quads using indices.
    See Also:
    Batch
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int C1  
      static int C2  
      static int C3  
      static int C4  
      int maxSpritesInBatch
      The maximum number of sprites rendered in one batch so far
      int renderCalls
      Number of render calls since the last begin().
      int totalRenderCalls
      Number of rendering calls, ever.
      static int U1  
      static int U2  
      static int U3  
      static int U4  
      static int V1  
      static int V2  
      static int V3  
      static int V4  
      static int X1  
      static int X2  
      static int X3  
      static int X4  
      static int Y1  
      static int Y2  
      static int Y3  
      static int Y4  
      static int Z1  
      static int Z2  
      static int Z3  
      static int Z4  
    • Constructor Summary

      Constructors 
      Constructor Description
      SpriteBatchWithZAxis​()
      Constructs a new SpriteBatch with a size of 1000, one buffer, and the default shader.
      SpriteBatchWithZAxis​(int size)
      Constructs a SpriteBatch with one buffer and the default shader.
      SpriteBatchWithZAxis​(int size, com.badlogic.gdx.graphics.glutils.ShaderProgram defaultShader)
      Constructs a new SpriteBatch.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void begin​()  
      static com.badlogic.gdx.graphics.glutils.ShaderProgram createDefaultShader​()
      Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified.
      void disableBlending​()  
      void dispose​()  
      void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y)  
      void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float width, float height)  
      void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)  
      void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, boolean clockwise)  
      void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region, float width, float height, com.badlogic.gdx.math.Affine2 transform)  
      void draw​(com.badlogic.gdx.graphics.Texture texture, float[] spriteVertices, int offset, int count)  
      void draw​(com.badlogic.gdx.graphics.Texture texture, float x, float y)  
      void draw​(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height)  
      void draw​(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2)  
      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)  
      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)  
      void draw​(com.badlogic.gdx.graphics.Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight)  
      void enableBlending​()  
      void end​()  
      void flush​()  
      int getBlendDstFunc​()  
      int getBlendSrcFunc​()  
      com.badlogic.gdx.graphics.Color getColor​()  
      int getIdx​()  
      float getPackedColor​()  
      com.badlogic.gdx.math.Matrix4 getProjectionMatrix​()  
      int getRenderedSprites​()
      continually increasing
      com.badlogic.gdx.graphics.glutils.ShaderProgram getShader​()  
      com.badlogic.gdx.math.Matrix4 getTransformMatrix​()  
      boolean isBlendingEnabled​()  
      boolean isDrawing​()  
      void setBlendFunction​(int srcFunc, int dstFunc)  
      void setColor​(float color)  
      void setColor​(float r, float g, float b, float a)  
      void setColor​(com.badlogic.gdx.graphics.Color tint)  
      void setIdx​(int idx)
      set this field to render same things twice
      void setProjectionMatrix​(com.badlogic.gdx.math.Matrix4 projection)  
      void setShader​(com.badlogic.gdx.graphics.glutils.ShaderProgram shader)  
      void setTransformMatrix​(com.badlogic.gdx.math.Matrix4 transform)  
      protected void switchTexture​(com.badlogic.gdx.graphics.Texture texture)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SpriteBatchWithZAxis

        public SpriteBatchWithZAxis​()
        Constructs a new SpriteBatch with a size of 1000, one buffer, and the default shader.
        See Also:
        SpriteBatch#SpriteBatch(int, ShaderProgram)
      • SpriteBatchWithZAxis

        public SpriteBatchWithZAxis​(int size)
        Constructs a SpriteBatch with one buffer and the default shader.
        Parameters:
        size -
        See Also:
        SpriteBatch#SpriteBatch(int, ShaderProgram)
      • SpriteBatchWithZAxis

        public SpriteBatchWithZAxis​(int size,
                                    com.badlogic.gdx.graphics.glutils.ShaderProgram defaultShader)
        Constructs a new SpriteBatch. Sets the projection matrix to an orthographic projection with y-axis point upwards, x-axis point to the right and the origin being in the bottom left corner of the screen. The projection will be pixel perfect with respect to the current screen resolution.

        The defaultShader specifies the shader to use. Note that the names for uniforms for this default shader are different than the ones expect for shaders set with setShader(ShaderProgram). See createDefaultShader().

        Parameters:
        size - The max number of sprites in a single batch. Max of 8191.
        defaultShader - The default shader to use. This is not owned by the SpriteBatch and must be disposed separately.
    • Method Detail

      • createDefaultShader

        public static com.badlogic.gdx.graphics.glutils.ShaderProgram createDefaultShader​()
        Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified.
        Returns:
      • begin

        public void begin​()
        Specified by:
        begin in interface com.badlogic.gdx.graphics.g2d.Batch
      • end

        public void end​()
        Specified by:
        end in interface com.badlogic.gdx.graphics.g2d.Batch
      • setColor

        public void setColor​(com.badlogic.gdx.graphics.Color tint)
        Specified by:
        setColor in interface com.badlogic.gdx.graphics.g2d.Batch
      • setColor

        public void setColor​(float r,
                             float g,
                             float b,
                             float a)
        Specified by:
        setColor in interface com.badlogic.gdx.graphics.g2d.Batch
      • setColor

        public void setColor​(float color)
        Specified by:
        setColor in interface com.badlogic.gdx.graphics.g2d.Batch
      • getColor

        public com.badlogic.gdx.graphics.Color getColor​()
        Specified by:
        getColor in interface com.badlogic.gdx.graphics.g2d.Batch
      • getPackedColor

        public float getPackedColor​()
        Specified by:
        getPackedColor in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public 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)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public 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)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.Texture texture,
                         float x,
                         float y,
                         int srcX,
                         int srcY,
                         int srcWidth,
                         int srcHeight)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.Texture texture,
                         float x,
                         float y,
                         float width,
                         float height,
                         float u,
                         float v,
                         float u2,
                         float v2)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.Texture texture,
                         float x,
                         float y)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.Texture texture,
                         float x,
                         float y,
                         float width,
                         float height)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.Texture texture,
                         float[] spriteVertices,
                         int offset,
                         int count)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region,
                         float x,
                         float y)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region,
                         float x,
                         float y,
                         float width,
                         float height)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region,
                         float x,
                         float y,
                         float originX,
                         float originY,
                         float width,
                         float height,
                         float scaleX,
                         float scaleY,
                         float rotation)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region,
                         float x,
                         float y,
                         float originX,
                         float originY,
                         float width,
                         float height,
                         float scaleX,
                         float scaleY,
                         float rotation,
                         boolean clockwise)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • draw

        public void draw​(com.badlogic.gdx.graphics.g2d.TextureRegion region,
                         float width,
                         float height,
                         com.badlogic.gdx.math.Affine2 transform)
        Specified by:
        draw in interface com.badlogic.gdx.graphics.g2d.Batch
      • flush

        public void flush​()
        Specified by:
        flush in interface com.badlogic.gdx.graphics.g2d.Batch
      • setIdx

        public void setIdx​(int idx)
        set this field to render same things twice
        Parameters:
        idx - float position in vertices array
      • getIdx

        public int getIdx​()
        Returns:
        float position in vertices array
      • disableBlending

        public void disableBlending​()
        Specified by:
        disableBlending in interface com.badlogic.gdx.graphics.g2d.Batch
      • enableBlending

        public void enableBlending​()
        Specified by:
        enableBlending in interface com.badlogic.gdx.graphics.g2d.Batch
      • setBlendFunction

        public void setBlendFunction​(int srcFunc,
                                     int dstFunc)
        Specified by:
        setBlendFunction in interface com.badlogic.gdx.graphics.g2d.Batch
      • getBlendSrcFunc

        public int getBlendSrcFunc​()
        Specified by:
        getBlendSrcFunc in interface com.badlogic.gdx.graphics.g2d.Batch
      • getBlendDstFunc

        public int getBlendDstFunc​()
        Specified by:
        getBlendDstFunc in interface com.badlogic.gdx.graphics.g2d.Batch
      • dispose

        public void dispose​()
        Specified by:
        dispose in interface com.badlogic.gdx.utils.Disposable
      • getProjectionMatrix

        public com.badlogic.gdx.math.Matrix4 getProjectionMatrix​()
        Specified by:
        getProjectionMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      • getTransformMatrix

        public com.badlogic.gdx.math.Matrix4 getTransformMatrix​()
        Specified by:
        getTransformMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      • setProjectionMatrix

        public void setProjectionMatrix​(com.badlogic.gdx.math.Matrix4 projection)
        Specified by:
        setProjectionMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      • setTransformMatrix

        public void setTransformMatrix​(com.badlogic.gdx.math.Matrix4 transform)
        Specified by:
        setTransformMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      • switchTexture

        protected void switchTexture​(com.badlogic.gdx.graphics.Texture texture)
      • setShader

        public void setShader​(com.badlogic.gdx.graphics.glutils.ShaderProgram shader)
        Specified by:
        setShader in interface com.badlogic.gdx.graphics.g2d.Batch
      • getShader

        public com.badlogic.gdx.graphics.glutils.ShaderProgram getShader​()
        Specified by:
        getShader in interface com.badlogic.gdx.graphics.g2d.Batch
      • isBlendingEnabled

        public boolean isBlendingEnabled​()
        Specified by:
        isBlendingEnabled in interface com.badlogic.gdx.graphics.g2d.Batch
      • isDrawing

        public boolean isDrawing​()
        Specified by:
        isDrawing in interface com.badlogic.gdx.graphics.g2d.Batch
      • getRenderedSprites

        public int getRenderedSprites​()
        continually increasing
        Returns:
        the amount of sprites rendered so far