public abstract class BaseShader extends Object implements Shader
Modifier and Type | Class and Description |
---|---|
static class |
BaseShader.GlobalSetter |
static class |
BaseShader.LocalSetter |
static interface |
BaseShader.Setter |
static class |
BaseShader.Uniform |
static interface |
BaseShader.Validator |
Modifier and Type | Field and Description |
---|---|
Camera |
camera |
RenderContext |
context |
ShaderProgram |
program |
Constructor and Description |
---|
BaseShader() |
Modifier and Type | Method and Description |
---|---|
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) |
public ShaderProgram program
public RenderContext context
public Camera camera
public int register(String alias, BaseShader.Validator validator, BaseShader.Setter setter)
public int register(String alias, BaseShader.Validator validator)
public int register(String alias, BaseShader.Setter setter)
public int register(String alias)
public int register(BaseShader.Uniform uniform, BaseShader.Setter setter)
public int register(BaseShader.Uniform uniform)
public int getUniformID(String alias)
public String getUniformAlias(int id)
public void init(ShaderProgram program, Renderable renderable)
public void begin(Camera camera, RenderContext context)
Shader
Shader.render(Renderable)
method to render a
Renderable
. When done rendering the Shader.end()
method must be called.begin
in interface Shader
camera
- The camera to use when renderingcontext
- The context to be used, which must be exclusive available for the shader until the call to the Shader.end()
method.public void render(Renderable renderable)
Shader
Renderable
, must be called between Shader.begin(Camera, RenderContext)
and Shader.end()
. The Shader
instance might not be able to render every type of Renderable
s. Use the Shader.canRender(Renderable)
method to
check if the Shader is capable of rendering a specific Renderable
.render
in interface Shader
renderable
- The renderable to render, all required fields (e.g. Renderable.mesh
, Renderable.material
and others) must be set. The Renderable.shader
field will be ignored.public void render(Renderable renderable, Attributes combinedAttributes)
public void end()
Shader
Shader.render(Renderable)
method, which must be preceded by a call to Shader.begin(Camera, RenderContext)
. After a call to this method an call to
the Shader.render(Renderable)
method will fail until the Shader.begin(Camera, RenderContext)
is called.public void dispose()
Disposable
dispose
in interface Disposable
public final boolean has(int inputID)
public final int loc(int inputID)
public final boolean set(int uniform, Matrix4 value)
public final boolean set(int uniform, Matrix3 value)
public final boolean set(int uniform, Vector3 value)
public final boolean set(int uniform, Vector2 value)
public final boolean set(int uniform, Color value)
public final boolean set(int uniform, float value)
public final boolean set(int uniform, float v1, float v2)
public final boolean set(int uniform, float v1, float v2, float v3)
public final boolean set(int uniform, float v1, float v2, float v3, float v4)
public final boolean set(int uniform, int value)
public final boolean set(int uniform, int v1, int v2)
public final boolean set(int uniform, int v1, int v2, int v3)
public final boolean set(int uniform, int v1, int v2, int v3, int v4)
public final boolean set(int uniform, TextureDescriptor textureDesc)
public final boolean set(int uniform, GLTexture texture)
Copyright © 2015. All rights reserved.