APIdia Launch Partner
Top Inners Fields Constructors Methods
com.badlogic.gdx.graphics.g3d.shaders

public abstract Class BaseShader

extends Object
implements Shader
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.graphics.g3d.Shader, com.badlogic.gdx.utils.Disposable
Known Direct Subclasses
com.badlogic.gdx.graphics.g3d.shaders.DefaultShader, com.badlogic.gdx.graphics.g3d.particles.ParticleShader
Imports
com.badlogic.gdx.graphics.Camera, .Color, .GLTexture, .Mesh, .VertexAttribute, .VertexAttributes, com.badlogic.gdx.graphics.g3d.Attributes, .Renderable, .Shader, com.badlogic.gdx.graphics.g3d.utils.RenderContext, .TextureDescriptor, com.badlogic.gdx.graphics.glutils.ShaderProgram, com.badlogic.gdx.math.Matrix3, .Matrix4, .Vector2, .Vector3, com.badlogic.gdx.utils.Array, .GdxRuntimeException, .IntArray, .IntIntMap

Author
Xoppa A BaseShader is a wrapper around a ShaderProgram that keeps track of the uniform and attribute locations. It does not manage the ShaderPogram, you are still responsible for disposing the ShaderProgram.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
public abstract static class
public static interface
public static class
public static interface

Field Summary

Modifier and TypeField and Description
private final IntIntMap
public Camera
private Attributes
public RenderContext
private Mesh
private final IntArray
private final IntIntMap
private final IntArray
private int[]
public ShaderProgram
private final Array<BaseShader.Setter>
private final IntArray
private final IntArray
private final Array<String>
private final Array<BaseShader.Validator>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
begin(Camera camera, RenderContext context)

Implements com.badlogic.gdx.graphics.g3d.Shader.begin.

Initializes the context for exclusive rendering by this shader.

public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Releases all resources of this object.

public void
end()

Implements com.badlogic.gdx.graphics.g3d.Shader.end.

Cleanup the context so other shaders can render.

private final int[]
private final int[]
public String
getUniformAlias(final int id)

Returns: The input at the specified id.

public int
getUniformID(final String alias)

Returns: the ID of the input or negative if not available.

public final boolean
has(final int inputID)

Whether this Shader instance implements the specified uniform, only valid after a call to init().

public void
init(final ShaderProgram program, final Renderable renderable)

Initialize this shader, causing all registered uniforms/attributes to be fetched.

public final int
loc(final int inputID)

public int

Returns:

The ID of the uniform to use in this shader.
register
(final String alias, final BaseShader.Validator validator, final BaseShader.Setter setter)

Register an uniform which might be used by this shader.

public int
register(final String alias, final BaseShader.Validator validator)

public int
register(final String alias, final BaseShader.Setter setter)

public int
register(final String alias)

public int
register(final BaseShader.Uniform uniform, final BaseShader.Setter setter)

public int
register(final BaseShader.Uniform uniform)

public void
render(Renderable renderable)

Implements com.badlogic.gdx.graphics.g3d.Shader.render.

Renders the Renderable, must be called between begin(Camera, RenderContext) and end().

public void
render(Renderable renderable, final Attributes combinedAttributes)

public final boolean
set(final int uniform, final Matrix4 value)

public final boolean
set(final int uniform, final Matrix3 value)

public final boolean
set(final int uniform, final Vector3 value)

public final boolean
set(final int uniform, final Vector2 value)

public final boolean
set(final int uniform, final Color value)

public final boolean
set(final int uniform, final float value)

public final boolean
set(final int uniform, final float v1, final float v2)

public final boolean
set(final int uniform, final float v1, final float v2, final float v3)

public final boolean
set(final int uniform, final float v1, final float v2, final float v3, final float v4)

public final boolean
set(final int uniform, final int value)

public final boolean
set(final int uniform, final int v1, final int v2)

public final boolean
set(final int uniform, final int v1, final int v2, final int v3)

public final boolean
set(final int uniform, final int v1, final int v2, final int v3, final int v4)

public final boolean
set(final int uniform, final TextureDescriptor<T extends GLTexture> textureDesc)

public final boolean
set(final int uniform, final GLTexture texture)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final IntIntMap attributes
cameraback to summary
public Camera camera
combinedAttributesback to summary
private Attributes combinedAttributes
contextback to summary
public RenderContext context
currentMeshback to summary
private Mesh currentMesh
globalUniformsback to summary
private final IntArray globalUniforms
instancedAttributesback to summary
private final IntIntMap instancedAttributes
localUniformsback to summary
private final IntArray localUniforms
locationsback to summary
private int[] locations
programback to summary
public ShaderProgram program
settersback to summary
private final Array<BaseShader.Setter> setters
tempArrayback to summary
private final IntArray tempArray
tempArray2back to summary
private final IntArray tempArray2
uniformsback to summary
private final Array<String> uniforms
validatorsback to summary
private final Array<BaseShader.Validator> validators

Constructor Detail

BaseShaderback to summary
public BaseShader()

Method Detail

beginback to summary
public void begin(Camera camera, RenderContext context)

Implements com.badlogic.gdx.graphics.g3d.Shader.begin.

Doc from com.badlogic.gdx.graphics.g3d.Shader.begin.

Initializes the context for exclusive rendering by this shader. Use the render(Renderable) method to render a Renderable. When done rendering the end() method must be called.

Annotations
@Override
disposeback to summary
public void dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Doc from com.badlogic.gdx.utils.Disposable.dispose.

Releases all resources of this object.

Annotations
@Override
endback to summary
public void end()

Implements com.badlogic.gdx.graphics.g3d.Shader.end.

Doc from com.badlogic.gdx.graphics.g3d.Shader.end.

Cleanup the context so other shaders can render. Must be called when done rendering using the render(Renderable) method, which must be preceded by a call to begin(Camera, RenderContext). After a call to this method an call to the render(Renderable) method will fail until the begin(Camera, RenderContext) is called.

Annotations
@Override
getAttributeLocationsback to summary
private final int[] getAttributeLocations(final VertexAttributes attrs)
getInstancedAttributeLocationsback to summary
private final int[] getInstancedAttributeLocations(final VertexAttributes attrs)
getUniformAliasback to summary
public String getUniformAlias(final int id)
Returns:String

The input at the specified id.

getUniformIDback to summary
public int getUniformID(final String alias)
Returns:int

the ID of the input or negative if not available.

hasback to summary
public final boolean has(final int inputID)

Whether this Shader instance implements the specified uniform, only valid after a call to init().

initback to summary
public void init(final ShaderProgram program, final Renderable renderable)

Initialize this shader, causing all registered uniforms/attributes to be fetched.

locback to summary
public final int loc(final int inputID)
registerback to summary
public int register(final String alias, final BaseShader.Validator validator, final BaseShader.Setter setter)

Register an uniform which might be used by this shader. Only possible prior to the call to init().

Returns:int

The ID of the uniform to use in this shader.

registerback to summary
public int register(final String alias, final BaseShader.Validator validator)
registerback to summary
public int register(final String alias, final BaseShader.Setter setter)
registerback to summary
public int register(final String alias)
registerback to summary
public int register(final BaseShader.Uniform uniform, final BaseShader.Setter setter)
registerback to summary
public int register(final BaseShader.Uniform uniform)
renderback to summary
public void render(Renderable renderable)

Implements com.badlogic.gdx.graphics.g3d.Shader.render.

Doc from com.badlogic.gdx.graphics.g3d.Shader.render.

Renders the Renderable, must be called between begin(Camera, RenderContext) and end(). The Shader instance might not be able to render every type of Renderables. Use the canRender(Renderable) method to check if the Shader is capable of rendering a specific Renderable.

Annotations
@Override
renderback to summary
public void render(Renderable renderable, final Attributes combinedAttributes)
setback to summary
public final boolean set(final int uniform, final Matrix4 value)
setback to summary
public final boolean set(final int uniform, final Matrix3 value)
setback to summary
public final boolean set(final int uniform, final Vector3 value)
setback to summary
public final boolean set(final int uniform, final Vector2 value)
setback to summary
public final boolean set(final int uniform, final Color value)
setback to summary
public final boolean set(final int uniform, final float value)
setback to summary
public final boolean set(final int uniform, final float v1, final float v2)
setback to summary
public final boolean set(final int uniform, final float v1, final float v2, final float v3)
setback to summary
public final boolean set(final int uniform, final float v1, final float v2, final float v3, final float v4)
setback to summary
public final boolean set(final int uniform, final int value)
setback to summary
public final boolean set(final int uniform, final int v1, final int v2)
setback to summary
public final boolean set(final int uniform, final int v1, final int v2, final int v3)
setback to summary
public final boolean set(final int uniform, final int v1, final int v2, final int v3, final int v4)
setback to summary
public final boolean set(final int uniform, final TextureDescriptor<T extends GLTexture> textureDesc)
setback to summary
public final boolean set(final int uniform, final GLTexture texture)
com.badlogic.gdx.graphics.g3d.shaders back to summary

public abstract Class BaseShader.GlobalSetter

extends Object
implements Setter
Class Inheritance
  • java.lang.Object
  • com.badlogic.gdx.graphics.g3d.shaders.BaseShader.GlobalSetter
All Implemented Interfaces
com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Setter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

GlobalSetterback to summary
public GlobalSetter()

Method Detail

isGlobalback to summary
public boolean isGlobal(final BaseShader shader, final int inputID)

Implements com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Setter.isGlobal.

Annotations
@Override
com.badlogic.gdx.graphics.g3d.shaders back to summary

public abstract Class BaseShader.LocalSetter

extends Object
implements Setter
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Setter
Known Direct Subclasses
com.badlogic.gdx.graphics.g3d.shaders.DefaultShader.Setters.Bones, com.badlogic.gdx.graphics.g3d.shaders.DefaultShader.Setters.ACubemap

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LocalSetterback to summary
public LocalSetter()

Method Detail

isGlobalback to summary
public boolean isGlobal(final BaseShader shader, final int inputID)

Implements com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Setter.isGlobal.

Annotations
@Override
com.badlogic.gdx.graphics.g3d.shaders back to summary

public Interface BaseShader.Setter

Known Direct Implementers
com.badlogic.gdx.graphics.g3d.shaders.BaseShader.GlobalSetter, com.badlogic.gdx.graphics.g3d.shaders.BaseShader.LocalSetter

Method Summary

Modifier and TypeMethod and Description
public boolean
isGlobal(final BaseShader shader, final int inputID)

Returns: True if the uniform only has to be set once per render call, false if the uniform must be set for each renderable.

public void
set(final BaseShader shader, final int inputID, final Renderable renderable, final Attributes combinedAttributes)

Method Detail

isGlobalback to summary
public boolean isGlobal(final BaseShader shader, final int inputID)
Returns:boolean

True if the uniform only has to be set once per render call, false if the uniform must be set for each renderable.

setback to summary
public void set(final BaseShader shader, final int inputID, final Renderable renderable, final Attributes combinedAttributes)
com.badlogic.gdx.graphics.g3d.shaders back to summary

public Class BaseShader.Uniform

extends Object
implements Validator
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Validator

Field Summary

Modifier and TypeField and Description
public final String
public final long
public final long
public final long

Constructor Summary

AccessConstructor and Description
public
Uniform(final String alias, final long materialMask, final long environmentMask, final long overallMask)

public
Uniform(final String alias, final long materialMask, final long environmentMask)

public
Uniform(final String alias, final long overallMask)

public
Uniform(final String alias)

Method Summary

Modifier and TypeMethod and Description
public boolean
validate(final BaseShader shader, final int inputID, final Renderable renderable)

Implements com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Validator.validate.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aliasback to summary
public final String alias
environmentMaskback to summary
public final long environmentMask
materialMaskback to summary
public final long materialMask
overallMaskback to summary
public final long overallMask

Constructor Detail

Uniformback to summary
public Uniform(final String alias, final long materialMask, final long environmentMask, final long overallMask)
Uniformback to summary
public Uniform(final String alias, final long materialMask, final long environmentMask)
Uniformback to summary
public Uniform(final String alias, final long overallMask)
Uniformback to summary
public Uniform(final String alias)

Method Detail

validateback to summary
public boolean validate(final BaseShader shader, final int inputID, final Renderable renderable)

Implements com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Validator.validate.

com.badlogic.gdx.graphics.g3d.shaders back to summary

public Interface BaseShader.Validator

Known Direct Implementers
com.badlogic.gdx.graphics.g3d.shaders.BaseShader.Uniform

Method Summary

Modifier and TypeMethod and Description
public boolean
validate(final BaseShader shader, final int inputID, final Renderable renderable)

Returns: True if the input is valid for the renderable, false otherwise.

Method Detail

validateback to summary
public boolean validate(final BaseShader shader, final int inputID, final Renderable renderable)
Returns:boolean

True if the input is valid for the renderable, false otherwise.