Class Shaders
java.lang.Object
org.openpatch.scratch.extensions.shader.Shaders
The shaders belonging to one sprite or stage, and which of them is currently
drawn with.
Reached through getShaders(), so that shader handling does not take up
room in the everyday API of a sprite:
this.getShaders().add("blur", "blur.frag", null);
this.getShaders().switchTo("blur");
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a shader.Returns a shader by name.Returns the shader currently drawn with.intReturns the position of the current shader.Returns the name of the current shader.voidnext()Switches to the next shader.voidreset()Stops drawing with a shader.voidswitchTo(double index) Switches to the shader at the given position.voidSwitches to the shader with the given name.
-
Constructor Details
-
Shaders
Creates an empty set of shaders.- Parameters:
owner- what the shaders belong to, used in error messages: "sprite" or "stage"
-
Shaders
Copies a set of shaders.- Parameters:
s- the shaders to copy
-
-
Method Details
-
add
Adds a shader. If a shader with the given name already exists, that one is returned instead.- Parameters:
name- a unique namefragmentShaderPath- the path to the fragment shadervertexShaderPath- the path to the vertex shader, may be null- Returns:
- the shader
-
get
Returns a shader by name.- Parameters:
name- the name of the shader- Returns:
- the shader, or null if there is none with that name
-
switchTo
Switches to the shader with the given name.- Parameters:
name- the name of the shader
-
switchTo
public void switchTo(double index) Switches to the shader at the given position.- Parameters:
index- the position of the shader
-
next
public void next()Switches to the next shader. -
reset
public void reset()Stops drawing with a shader. -
getCurrent
Returns the shader currently drawn with.- Returns:
- the current shader, or null if there is none
-
getCurrentIndex
public int getCurrentIndex()Returns the position of the current shader.- Returns:
- the position, or -1 if no shader is in use
-
getCurrentName
Returns the name of the current shader.- Returns:
- the name, or null if no shader is in use
-