7import java.util.function.Function;
8import java.util.Collections;
24 ArrayList<Uniform>
uniforms =
new ArrayList<Uniform>();
69 Shader(String path,
int w,
int h, ArrayList<Uniform> u) {
84 Function<Float, Float> update_time = t -> (float)millis()/1000.0;
87 update_time.apply(0.0),
92 ArrayList<Float> dimensions =
new ArrayList<Float>();
93 dimensions.add((
float)
w);
94 dimensions.add((
float)
h);
101 ArrayList<Float> mouse_pos =
new ArrayList<Float>();
102 mouse_pos.add((
float)mouseX);
103 mouse_pos.add((
float)(-1*mouseY + height));
104 mouse_pos.add(mousePressed ? 1.0 : -1.0);
105 Function<ArrayList<Float>, ArrayList<Float>> update_mouse = t -> {
106 t.set(0, (
float)mouseX);
107 t.set(1, (
float)(-1*mouseY + height));
108 t.set(2, mousePressed ? 1.0 : -1.0);
111 mouse_pos = update_mouse.apply(mouse_pos);
150 println(
"- program : " +
program);
151 println(
"- type : " +
type);
152 println(
"- uniforms : " +
uniforms);
153 println(
"- dim(w,h) : " +
w +
", " +
h);
154 println(
"----------------");
Shader object organizes a list of uniforms and a compiled PShader.
void print()
print function for debugging.
void update_uniforms()
update uniforms with an update function.
void make_default_uniforms()
this creates three common uniforms as defaults.
Shader(String path, int w, int h)
Shader Constructor without Uniforms.
void set_uniforms()
set uniforms in shader.
Shader(String path, int w, int h, Uniform u)
Shader Constructor with Uniform.
PShader program
OpenGL program binding.
void add_uniforms(ArrayList< Uniform > custom_uniforms)
add a list of custom defined uniforms.
ArrayList< Uniform > uniforms
Uniform data.
shader_type type
Shader type (vertex or fragment)
void add_uniform(Uniform custom_uniform)
add a single uniform.
Shader(String path, int w, int h, ArrayList< Uniform > u)
Shader Constructor with Uniforms.
interface to store lambda expressions.