Package gaiasky.util.gdx
Class IntModelBatch
java.lang.Object
gaiasky.util.gdx.IntModelBatch
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Batches
IntRenderable
instances, fetches IntShader
s 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 IntRenderable
s at once a IntRenderableProvider
can be used, e.g. a IntModelInstance
.-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.badlogic.gdx.graphics.Camera
protected com.badlogic.gdx.graphics.g3d.utils.RenderContext
theRenderContext
protected com.badlogic.gdx.utils.Array<IntRenderable>
list of Renderables to be rendered in the current batchprotected IntModelBatch.RenderablePool
protected IntShaderProvider
theIntShaderProvider
, providesIntShader
instances for IntRenderablesprotected IntRenderableSorter
-
Constructor Summary
ConstructorDescriptionConstruct a ModelBatch with the default implementationIntModelBatch(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.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.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.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.IntModelBatch(IntShaderProvider shaderProvider, IntRenderableSorter sorter)
Construct a ModelBatchIntModelBatch(String vertexShader, String fragmentShader)
Construct a ModelBatch with the default implementation and the specified ubershader. -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin(com.badlogic.gdx.graphics.Camera cam)
Start rendering one or moreIntRenderable
s.void
dispose()
void
end()
End rendering one or moreIntRenderable
s.void
flush()
Flushes the batch, causing allIntRenderable
s in the batch to be rendered.com.badlogic.gdx.graphics.Camera
Provides access to the current camera in betweenbegin(Camera)
andend()
.com.badlogic.gdx.graphics.g3d.utils.RenderContext
boolean
Checks whether theRenderContext
returned bygetRenderContext()
is owned and managed by this ModelBatch.void
render(IntRenderable renderable)
Add a singleIntRenderable
to the batch.void
render(IntRenderableProvider renderableProvider)
CallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.void
render(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment)
CallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.void
render(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)
CallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.void
render(IntRenderableProvider renderableProvider, IntShader shader)
CallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.<T extends IntRenderableProvider>
voidCallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.<T extends IntRenderableProvider>
voidCallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.<T extends IntRenderableProvider>
voidrender(Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)
CallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.<T extends IntRenderableProvider>
voidCallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered.void
setCamera(com.badlogic.gdx.graphics.Camera cam)
Change the camera in betweenbegin(Camera)
andend()
.
-
Field Details
-
camera
protected com.badlogic.gdx.graphics.Camera camera -
renderablesPool
-
renderables
list of Renderables to be rendered in the current batch -
context
protected final com.badlogic.gdx.graphics.g3d.utils.RenderContext contexttheRenderContext
-
shaderProvider
theIntShaderProvider
, providesIntShader
instances for IntRenderables -
sorter
-
-
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
- TheRenderContext
to use.shaderProvider
- TheIntShaderProvider
to use, will be disposed when this ModelBatch is disposed.sorter
- TheRenderableSorter
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
- TheRenderContext
to use.shaderProvider
- TheIntShaderProvider
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
- TheRenderContext
to use.sorter
- TheIntRenderableSorter
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
- TheRenderContext
to use.
-
IntModelBatch
Construct a ModelBatch- Parameters:
shaderProvider
- TheIntShaderProvider
to use, will be disposed when this ModelBatch is disposed.sorter
- TheIntRenderableSorter
to use.
-
IntModelBatch
Construct a ModelBatch with the default implementation and the specified ubershader. SeeDefaultIntShader
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 moreIntRenderable
s. Use one of the render() methods to provide the renderables. Must be followed by a call toend()
. The OpenGL context must not be altered betweenbegin(Camera)
andend()
.- Parameters:
cam
- TheCamera
to be used when rendering and sorting.
-
setCamera
public void setCamera(com.badlogic.gdx.graphics.Camera cam)Change the camera in betweenbegin(Camera)
andend()
. This causes the batch to be flushed. Can only be called after the call tobegin(Camera)
and before the call toend()
.- Parameters:
cam
- The new camera to use.
-
getCamera
public com.badlogic.gdx.graphics.Camera getCamera()Provides access to the current camera in betweenbegin(Camera)
andend()
. Do not change the camera's values. UsesetCamera(Camera)
, if you need to change the camera.- Returns:
- The current camera being used or null if called outside
begin(Camera)
andend()
.
-
ownsRenderContext
public boolean ownsRenderContext()Checks whether theRenderContext
returned bygetRenderContext()
is owned and managed by this ModelBatch. When the RenderContext isn't owned by the ModelBatch, you are responsible for calling theRenderContext.begin()
andRenderContext.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
- Returns:
- the
IntShaderProvider
used by this ModelBatch.
-
getRenderableSorter
- Returns:
- the
IntRenderableSorter
used by this ModelBatch.
-
flush
public void flush()Flushes the batch, causing allIntRenderable
s in the batch to be rendered. Can only be called after the call tobegin(Camera)
and before the call toend()
. -
end
public void end()End rendering one or moreIntRenderable
s. Must be called after a call tobegin(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
Add a singleIntRenderable
to the batch. TheIntShaderProvider
will be used to fetch a suitableIntShader
. Can only be called after a call tobegin(Camera)
and before a call toend()
.- Parameters:
renderable
- TheIntRenderable
to be added.
-
render
CallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered. Can only be called after a call tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProvider
- the renderable provider
-
render
CallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered. Can only be called after a call tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProviders
- one or more renderable providers
-
render
public void render(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment)CallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
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 tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProvider
- the renderable providerenvironment
- theEnvironment
to use for the renderables
-
render
public <T extends IntRenderableProvider> void render(Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment)CallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
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 tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProviders
- one or more renderable providersenvironment
- theEnvironment
to use for the renderables
-
render
CallsRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered. Any shaders set on the returned renderables will be replaced with the givenIntShader
. Can only be called after a call tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProvider
- the renderable providershader
- the shader to use for the renderables
-
render
public <T extends IntRenderableProvider> void render(Iterable<T> renderableProviders, IntShader shader)CallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
instances to the current batch to be rendered. Any shaders set on the returned renderables will be replaced with the givenIntShader
. Can only be called after a call tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProviders
- one or more renderable providersshader
- the shader to use for the renderables
-
render
public void render(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)CallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
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 givenIntShader
. Can only be called after a call tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProvider
- the renderable providerenvironment
- theEnvironment
to use for the renderablesshader
- 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)CallsIntRenderableProvider.getRenderables(Array, Pool)
and adds all returnedIntRenderable
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 givenIntShader
. Can only be called after a call tobegin(Camera)
and before a call toend()
.- Parameters:
renderableProviders
- one or more renderable providersenvironment
- theEnvironment
to use for the renderablesshader
- the shader to use for the renderables
-
dispose
public void dispose()- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-