com.badlogic.gdx.graphics.g3d.shaders
Class BaseShader

java.lang.Object
  extended by com.badlogic.gdx.graphics.g3d.shaders.BaseShader
All Implemented Interfaces:
Shader, Disposable
Direct Known Subclasses:
DefaultShader

public abstract class BaseShader
extends Object
implements Shader

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 Class Summary
static interface BaseShader.Setter
           
static class BaseShader.Uniform
           
static interface BaseShader.Validator
           
 
Field Summary
 Camera camera
           
 RenderContext context
           
 ShaderProgram program
           
 
Constructor Summary
BaseShader()
           
 
Method Summary
 void begin(Camera camera, RenderContext context)
          Initializes the context for exclusive rendering by this shader
 void dispose()
          Releases all resources of this object.
 void end()
          Cleanup the context so other shaders can render
 String getUniformAlias(int id)
           
 int getUniformID(String alias)
           
 boolean has(int inputID)
          Whether this Shader instance implements the specified uniform, only valid after a call to init().
 void init(ShaderProgram program, Renderable renderable)
          Initialize this shader, causing all registered uniforms/attributes to be fetched.
 int loc(int inputID)
           
 int register(BaseShader.Uniform uniform)
           
 int register(BaseShader.Uniform uniform, BaseShader.Setter setter)
           
 int register(String alias)
           
 int register(String alias, BaseShader.Setter setter)
           
 int register(String alias, BaseShader.Validator validator)
           
 int register(String alias, BaseShader.Validator validator, BaseShader.Setter setter)
          Register an uniform which might be used by this shader.
 void render(Renderable renderable)
          Renders the Renderable must be called between Shader.begin(Camera, RenderContext) and Shader.end()
 void render(Renderable renderable, Attributes combinedAttributes)
           
 boolean set(int uniform, Color value)
           
 boolean set(int uniform, float value)
           
 boolean set(int uniform, float v1, float v2)
           
 boolean set(int uniform, float v1, float v2, float v3)
           
 boolean set(int uniform, float v1, float v2, float v3, float v4)
           
 boolean set(int uniform, GLTexture texture)
           
 boolean set(int uniform, int value)
           
 boolean set(int uniform, int v1, int v2)
           
 boolean set(int uniform, int v1, int v2, int v3)
           
 boolean set(int uniform, int v1, int v2, int v3, int v4)
           
 boolean set(int uniform, Matrix3 value)
           
 boolean set(int uniform, Matrix4 value)
           
 boolean set(int uniform, TextureDescriptor textureDesc)
           
 boolean set(int uniform, Vector2 value)
           
 boolean set(int uniform, Vector3 value)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.badlogic.gdx.graphics.g3d.Shader
canRender, compareTo, init
 

Field Detail

program

public ShaderProgram program

context

public RenderContext context

camera

public Camera camera
Constructor Detail

BaseShader

public BaseShader()
Method Detail

register

public int register(String alias,
                    BaseShader.Validator validator,
                    BaseShader.Setter setter)
Register an uniform which might be used by this shader. Only possible prior to the call to init().

Returns:
The ID of the uniform to use in this shader.

register

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

register

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

register

public int register(String alias)

register

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

register

public int register(BaseShader.Uniform uniform)

getUniformID

public int getUniformID(String alias)
Returns:
the ID of the input or negative if not available.

getUniformAlias

public String getUniformAlias(int id)
Returns:
The input at the specified id.

init

public void init(ShaderProgram program,
                 Renderable renderable)
Initialize this shader, causing all registered uniforms/attributes to be fetched.


begin

public void begin(Camera camera,
                  RenderContext context)
Description copied from interface: Shader
Initializes the context for exclusive rendering by this shader

Specified by:
begin in interface Shader

render

public void render(Renderable renderable)
Description copied from interface: Shader
Renders the Renderable must be called between Shader.begin(Camera, RenderContext) and Shader.end()

Specified by:
render in interface Shader

render

public void render(Renderable renderable,
                   Attributes combinedAttributes)

end

public void end()
Description copied from interface: Shader
Cleanup the context so other shaders can render

Specified by:
end in interface Shader

dispose

public void dispose()
Description copied from interface: Disposable
Releases all resources of this object.

Specified by:
dispose in interface Disposable

has

public final boolean has(int inputID)
Whether this Shader instance implements the specified uniform, only valid after a call to init().


loc

public final int loc(int inputID)

set

public final boolean set(int uniform,
                         Matrix4 value)

set

public final boolean set(int uniform,
                         Matrix3 value)

set

public final boolean set(int uniform,
                         Vector3 value)

set

public final boolean set(int uniform,
                         Vector2 value)

set

public final boolean set(int uniform,
                         Color value)

set

public final boolean set(int uniform,
                         float value)

set

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

set

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

set

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

set

public final boolean set(int uniform,
                         int value)

set

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

set

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

set

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

set

public final boolean set(int uniform,
                         TextureDescriptor textureDesc)

set

public final boolean set(int uniform,
                         GLTexture texture)


Copyright © 2013. All Rights Reserved.