Class InstancedRenderSystem

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, IObserver, IRenderSystem
Direct Known Subclasses:
ParticleSetInstancedRenderer, StarSetInstancedRenderer, VariableSetInstancedRenderer

public abstract class InstancedRenderSystem extends ImmediateModeRenderSystem implements IObserver
Common code to all render systems that render quads with GPU instancing.
  • Field Details

    • tempInstanceAttribs

      protected float[] tempInstanceAttribs
  • Constructor Details

  • Method Details

    • initVertices

      protected void initVertices()
      Specified by:
      initVertices in class ImmediateModeRenderSystem
    • ensureInstanceAttribsSize

      protected void ensureInstanceAttribsSize(int size)
    • initializeModel

      protected void initializeModel()
    • addAttributesDivisor0

      protected abstract void addAttributesDivisor0(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes)
      Adds the required vertex attributes for this renderer to the given list. These attributes are added only once for all instances (divisor=0)
      Parameters:
      attributes - The list of attributes with divisor=0
    • addAttributesDivisor1

      protected abstract void addAttributesDivisor1(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes)
      Adds the required vertex attributes for this renderer to the given list. These attributes are added for every instance (divisor=1)
      Parameters:
      attributes - The list of attributes with divisor=1
    • buildAttributesDivisor0

      protected com.badlogic.gdx.graphics.VertexAttribute[] buildAttributesDivisor0()
      Builds the vertex attributes with divisor=0 array and returns it
      Returns:
      The vertex attributes array
    • buildAttributesDivisor1

      protected com.badlogic.gdx.graphics.VertexAttribute[] buildAttributesDivisor1()
      Builds the vertex attributes with divisor=1 array and returns it
      Returns:
      The vertex attributes array
    • offsets0

      protected abstract void offsets0(ImmediateModeRenderSystem.MeshData curr)
      Computes the offset for each vertex attribute. The offsets will be used later in the render stage.
      Parameters:
      curr - The current mesh data
    • offsets1

      protected abstract void offsets1(ImmediateModeRenderSystem.MeshData curr)
      Computes the offset for each vertex attribute in the instanced array. The offsets will be used later in the render stage.
      Parameters:
      curr - The current mesh data
    • addMeshData

      protected int addMeshData(int maxVerts0, int maxVerts1)
      Adds a new mesh data to the meshes list and increases the mesh data index
      Parameters:
      maxVerts0 - The max number of vertices the divisor 0 mesh data can hold
      maxVerts1 - The max number of vertices the divisor 1 mesh data can hold
      Returns:
      The index of the new mesh data
    • preRenderObjects

      protected void preRenderObjects(ExtShaderProgram shaderProgram, ICamera camera)
    • renderObject

      protected void renderObject(ExtShaderProgram shaderProgram, IRenderable renderable)
    • postRenderObjects

      protected void postRenderObjects(ExtShaderProgram shaderProgram, ICamera camera)
    • renderStud

      public void renderStud(List<IRenderable> renderables, ICamera camera, double t)
      Specified by:
      renderStud in class AbstractRenderSystem