Class IntModelBatch

java.lang.Object
gaiasky.util.gdx.IntModelBatch
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class IntModelBatch extends Object implements com.badlogic.gdx.utils.Disposable
Batches IntRenderable instances, fetches IntShaders for them, sorts them and then renders them. Fetching the shaders is done using a IntShaderProvider, which defaults to DefaultShaderProvider. Sorting the renderables is done using a RenderableSorter, which default to DefaultRenderableSorter. The OpenGL context between the begin(Camera) and end() call is maintained by the RenderContext. To provide multiple IntRenderables at once a IntRenderableProvider can be used, e.g. a IntModelInstance.
  • Field Details

  • Constructor Details

    • IntModelBatch

      public IntModelBatch(com.badlogic.gdx.graphics.g3d.utils.RenderContext context, IntShaderProvider shaderProvider, IntRenderableSorter sorter)
      Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself.
      Parameters:
      context - The RenderContext to use.
      shaderProvider - The IntShaderProvider to use, will be disposed when this ModelBatch is disposed.
      sorter - The RenderableSorter to use.
    • IntModelBatch

      public IntModelBatch(com.badlogic.gdx.graphics.g3d.utils.RenderContext context, IntShaderProvider shaderProvider)
      Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself.
      Parameters:
      context - The RenderContext to use.
      shaderProvider - The IntShaderProvider to use, will be disposed when this ModelBatch is disposed.
    • IntModelBatch

      public IntModelBatch(com.badlogic.gdx.graphics.g3d.utils.RenderContext context, IntRenderableSorter sorter)
      Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself.
      Parameters:
      context - The RenderContext to use.
      sorter - The IntRenderableSorter to use.
    • IntModelBatch

      public IntModelBatch(com.badlogic.gdx.graphics.g3d.utils.RenderContext context)
      Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself.
      Parameters:
      context - The RenderContext to use.
    • IntModelBatch

      public IntModelBatch(IntShaderProvider shaderProvider, IntRenderableSorter sorter)
      Construct a ModelBatch
      Parameters:
      shaderProvider - The IntShaderProvider to use, will be disposed when this ModelBatch is disposed.
      sorter - The IntRenderableSorter to use.
    • IntModelBatch

      public IntModelBatch(String vertexShader, String fragmentShader)
      Construct a ModelBatch with the default implementation and the specified ubershader. See DefaultIntShader for more information about using a custom ubershader. Requires OpenGL ES 2.0.
      Parameters:
      vertexShader - The vertex shader to use.
      fragmentShader - The fragment shader to use.
    • IntModelBatch

      public IntModelBatch()
      Construct a ModelBatch with the default implementation
  • Method Details

    • begin

      public void begin(com.badlogic.gdx.graphics.Camera cam)
      Start rendering one or more IntRenderables. Use one of the render() methods to provide the renderables. Must be followed by a call to end(). The OpenGL context must not be altered between begin(Camera) and end().
      Parameters:
      cam - The Camera to be used when rendering and sorting.
    • setCamera

      public void setCamera(com.badlogic.gdx.graphics.Camera cam)
      Change the camera in between begin(Camera) and end(). This causes the batch to be flushed. Can only be called after the call to begin(Camera) and before the call to end().
      Parameters:
      cam - The new camera to use.
    • getCamera

      public com.badlogic.gdx.graphics.Camera getCamera()
      Provides access to the current camera in between begin(Camera) and end(). Do not change the camera's values. Use setCamera(Camera), if you need to change the camera.
      Returns:
      The current camera being used or null if called outside begin(Camera) and end().
    • ownsRenderContext

      public boolean ownsRenderContext()
      Checks whether the RenderContext returned by getRenderContext() is owned and managed by this ModelBatch. When the RenderContext isn't owned by the ModelBatch, you are responsible for calling the RenderContext.begin() and RenderContext.end() methods yourself, as well as disposing the RenderContext.
      Returns:
      True if this ModelBatch owns the RenderContext, false otherwise.
    • getRenderContext

      public com.badlogic.gdx.graphics.g3d.utils.RenderContext getRenderContext()
      Returns:
      the RenderContext used by this ModelBatch.
    • getShaderProvider

      public IntShaderProvider getShaderProvider()
      Returns:
      the IntShaderProvider used by this ModelBatch.
    • getRenderableSorter

      public IntRenderableSorter getRenderableSorter()
      Returns:
      the IntRenderableSorter used by this ModelBatch.
    • flush

      public void flush()
      Flushes the batch, causing all IntRenderables in the batch to be rendered. Can only be called after the call to begin(Camera) and before the call to end().
    • end

      public void end()
      End rendering one or more IntRenderables. Must be called after a call to begin(Camera). This will flush the batch, causing any renderables provided using one of the render() methods to be rendered. After a call to this method the OpenGL context can be altered again.
    • render

      public void render(IntRenderable renderable)
      Add a single IntRenderable to the batch. The IntShaderProvider will be used to fetch a suitable IntShader. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderable - The IntRenderable to be added.
    • render

      public void render(IntRenderableProvider renderableProvider)
      Calls RenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProvider - the renderable provider
    • render

      public <T extends IntRenderableProvider> void render(Iterable<T> renderableProviders)
      Calls RenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProviders - one or more renderable providers
    • render

      public void render(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment)
      Calls RenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Any environment set on the returned renderables will be replaced with the given environment. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProvider - the renderable provider
      environment - the Environment to use for the renderables
    • render

      public <T extends IntRenderableProvider> void render(Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment)
      Calls IntRenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Any environment set on the returned renderables will be replaced with the given environment. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProviders - one or more renderable providers
      environment - the Environment to use for the renderables
    • render

      public void render(IntRenderableProvider renderableProvider, IntShader shader)
      Calls RenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Any shaders set on the returned renderables will be replaced with the given IntShader. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProvider - the renderable provider
      shader - the shader to use for the renderables
    • render

      public <T extends IntRenderableProvider> void render(Iterable<T> renderableProviders, IntShader shader)
      Calls IntRenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Any shaders set on the returned renderables will be replaced with the given IntShader. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProviders - one or more renderable providers
      shader - the shader to use for the renderables
    • render

      public void render(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)
      Calls IntRenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Any environment set on the returned renderables will be replaced with the given environment. Any shaders set on the returned renderables will be replaced with the given IntShader. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProvider - the renderable provider
      environment - the Environment to use for the renderables
      shader - the shader to use for the renderables
    • render

      public <T extends IntRenderableProvider> void render(Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)
      Calls IntRenderableProvider.getRenderables(Array, Pool) and adds all returned IntRenderable instances to the current batch to be rendered. Any environment set on the returned renderables will be replaced with the given environment. Any shaders set on the returned renderables will be replaced with the given IntShader. Can only be called after a call to begin(Camera) and before a call to end().
      Parameters:
      renderableProviders - one or more renderable providers
      environment - the Environment to use for the renderables
      shader - the shader to use for the renderables
    • dispose

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