Package gaiasky.util.gdx
Class IntModelBatch
- java.lang.Object
-
- gaiasky.util.gdx.IntModelBatch
-
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
public class IntModelBatch extends java.lang.Object implements com.badlogic.gdx.utils.DisposableBatchesIntRenderableinstances, fetchesIntShaders for them, sorts them and then renders them. Fetching the shaders is done using aIntShaderProvider, which defaults toDefaultShaderProvider. Sorting the renderables is done using aRenderableSorter, which default toDefaultRenderableSorter. The OpenGL context between thebegin(Camera)andend()call is maintained by theRenderContext. To provide multipleIntRenderables at once aIntRenderableProvidercan be used, e.g. aIntModelInstance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classIntModelBatch.RenderablePool
-
Field Summary
Fields Modifier and Type Field Description protected com.badlogic.gdx.graphics.Cameracameraprotected com.badlogic.gdx.graphics.g3d.utils.RenderContextcontexttheRenderContextprotected com.badlogic.gdx.utils.Array<IntRenderable>renderableslist of Renderables to be rendered in the current batchprotected IntModelBatch.RenderablePoolrenderablesPoolprotected IntShaderProvidershaderProvidertheIntShaderProvider, providesIntShaderinstances for IntRenderablesprotected IntRenderableSortersorter
-
Constructor Summary
Constructors Constructor Description IntModelBatch()Construct 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(java.lang.String vertexShader, java.lang.String fragmentShader)Construct a ModelBatch with the default implementation and the specified ubershader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin(com.badlogic.gdx.graphics.Camera cam)Start rendering one or moreIntRenderables.voiddispose()voidend()End rendering one or moreIntRenderables.voidflush()Flushes the batch, causing allIntRenderables in the batch to be rendered.com.badlogic.gdx.graphics.CameragetCamera()Provides access to the current camera in betweenbegin(Camera)andend().IntRenderableSortergetRenderableSorter()com.badlogic.gdx.graphics.g3d.utils.RenderContextgetRenderContext()IntShaderProvidergetShaderProvider()booleanownsRenderContext()Checks whether theRenderContextreturned bygetRenderContext()is owned and managed by this ModelBatch.voidrender(IntRenderable renderable)Add a singleIntRenderableto the batch.voidrender(IntRenderableProvider renderableProvider)CallsRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.voidrender(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment)CallsRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.voidrender(IntRenderableProvider renderableProvider, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)CallsIntRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.voidrender(IntRenderableProvider renderableProvider, IntShader shader)CallsRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.<T extends IntRenderableProvider>
voidrender(java.lang.Iterable<T> renderableProviders)CallsRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.<T extends IntRenderableProvider>
voidrender(java.lang.Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment)CallsIntRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.<T extends IntRenderableProvider>
voidrender(java.lang.Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)CallsIntRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.<T extends IntRenderableProvider>
voidrender(java.lang.Iterable<T> renderableProviders, IntShader shader)CallsIntRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances to the current batch to be rendered.voidsetCamera(com.badlogic.gdx.graphics.Camera cam)Change the camera in betweenbegin(Camera)andend().
-
-
-
Field Detail
-
camera
protected com.badlogic.gdx.graphics.Camera camera
-
renderablesPool
protected final IntModelBatch.RenderablePool renderablesPool
-
renderables
protected final com.badlogic.gdx.utils.Array<IntRenderable> renderables
list of Renderables to be rendered in the current batch
-
context
protected final com.badlogic.gdx.graphics.g3d.utils.RenderContext context
theRenderContext
-
shaderProvider
protected final IntShaderProvider shaderProvider
theIntShaderProvider, providesIntShaderinstances for IntRenderables
-
sorter
protected final IntRenderableSorter sorter
-
-
Constructor Detail
-
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- TheRenderContextto use.shaderProvider- TheIntShaderProviderto use, will be disposed when this ModelBatch is disposed.sorter- TheRenderableSorterto 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- TheRenderContextto use.shaderProvider- TheIntShaderProviderto 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- TheRenderContextto use.sorter- TheIntRenderableSorterto 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- TheRenderContextto use.
-
IntModelBatch
public IntModelBatch(IntShaderProvider shaderProvider, IntRenderableSorter sorter)
Construct a ModelBatch- Parameters:
shaderProvider- TheIntShaderProviderto use, will be disposed when this ModelBatch is disposed.sorter- TheIntRenderableSorterto use.
-
IntModelBatch
public IntModelBatch(java.lang.String vertexShader, java.lang.String fragmentShader)Construct a ModelBatch with the default implementation and the specified ubershader. SeeDefaultIntShaderfor 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 Detail
-
begin
public void begin(com.badlogic.gdx.graphics.Camera cam)
Start rendering one or moreIntRenderables. 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- TheCamerato 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 theRenderContextreturned 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
RenderContextused by this ModelBatch.
-
getShaderProvider
public IntShaderProvider getShaderProvider()
- Returns:
- the
IntShaderProviderused by this ModelBatch.
-
getRenderableSorter
public IntRenderableSorter getRenderableSorter()
- Returns:
- the
IntRenderableSorterused by this ModelBatch.
-
flush
public void flush()
Flushes the batch, causing allIntRenderables 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 moreIntRenderables. 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
public void render(IntRenderable renderable)
Add a singleIntRenderableto the batch. TheIntShaderProviderwill be used to fetch a suitableIntShader. Can only be called after a call tobegin(Camera)and before a call toend().- Parameters:
renderable- TheIntRenderableto be added.
-
render
public void render(IntRenderableProvider renderableProvider)
CallsRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances 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
public <T extends IntRenderableProvider> void render(java.lang.Iterable<T> renderableProviders)
CallsRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances 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 returnedIntRenderableinstances 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- theEnvironmentto use for the renderables
-
render
public <T extends IntRenderableProvider> void render(java.lang.Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment)
CallsIntRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances 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- theEnvironmentto use for the renderables
-
render
public void render(IntRenderableProvider renderableProvider, IntShader shader)
CallsRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances 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(java.lang.Iterable<T> renderableProviders, IntShader shader)
CallsIntRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances 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 returnedIntRenderableinstances 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- theEnvironmentto use for the renderablesshader- the shader to use for the renderables
-
render
public <T extends IntRenderableProvider> void render(java.lang.Iterable<T> renderableProviders, com.badlogic.gdx.graphics.g3d.Environment environment, IntShader shader)
CallsIntRenderableProvider.getRenderables(Array, Pool)and adds all returnedIntRenderableinstances 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- theEnvironmentto use for the renderablesshader- the shader to use for the renderables
-
dispose
public void dispose()
- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable
-
-