thebookofshaders/04/processing/processing.pde

30 lines
638 B
Plaintext
Raw Normal View History

2015-03-15 15:21:47 +00:00
// Copyright 2015 Patricio Gonzalez Vivo (http://patriciogonzalezvivo.com)
PShader shader;
void setup() {
size(640, 360, P2D);
noStroke();
2017-08-19 10:11:58 +00:00
2015-03-15 15:21:47 +00:00
// Load and compile shader
shader = loadShader("shader.frag");
}
void draw() {
// Set uniforms
shader.set("u_resolution", float(width), float(height));
shader.set("u_mouse", float(mouseX), float(mouseY));
shader.set("u_time", millis() / 1000.0);
2017-08-19 10:11:58 +00:00
2015-03-15 15:21:47 +00:00
// Replace the default pipeline programs with our shader
shader(shader);
2017-08-19 10:11:58 +00:00
2015-03-15 15:21:47 +00:00
// Draw a billboard
rect(0,0,width,height);
}
void keyPressed(){
// Reload shader everytime a key is press
shader = loadShader("shader.frag");
}