fixed a bug where the effects woudlnt re-apply if a new image was loaded
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
//globals
|
||||
uptime = 116747025
|
||||
uptime = 116755249
|
||||
|
||||
@@ -82,7 +82,7 @@ void draw() {
|
||||
|
||||
background(color(0));
|
||||
viewport = renderer.get();
|
||||
|
||||
|
||||
int imgw, imgh;
|
||||
if (renderer.width < renderer.height) {
|
||||
imgh = (int)height;
|
||||
@@ -107,6 +107,7 @@ void draw() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void snapshot() {
|
||||
frameName = str(uptime);
|
||||
renderer.save(dataPath("")+"/snapshots/" + frameName + ".png");
|
||||
|
||||
25
shader.pde
25
shader.pde
@@ -41,12 +41,12 @@ class Shader {
|
||||
println(e);
|
||||
}
|
||||
|
||||
//this is only for checking if a param has changed. paramValues could also be used for a save/load function
|
||||
if (paramValues.size() != params.size()) {
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
paramValues.add(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
paramChanged = false;
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
if (paramValues.get(i) != params.get(i).value) {
|
||||
@@ -54,18 +54,19 @@ class Shader {
|
||||
paramChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(pos != previousPos){
|
||||
|
||||
if (pos != previousPos) {
|
||||
paramChanged = true;
|
||||
}
|
||||
previousPos = pos;
|
||||
|
||||
if(previousActive != gui.bricks.get(pos).active){
|
||||
|
||||
if (previousActive != gui.bricks.get(pos).active) {
|
||||
paramChanged = true;
|
||||
}
|
||||
previousActive = gui.bricks.get(pos).active;
|
||||
|
||||
|
||||
if (!paramChanged) {
|
||||
if (imageChanged) paramChanged = true;
|
||||
for (int i = this.pos; i >= 0; i--) {
|
||||
if (gui.shaderList.get(i).paramChanged) paramChanged = true;
|
||||
}
|
||||
@@ -79,6 +80,7 @@ class Shader {
|
||||
gui.bricks.get(pos).params.remove(paramNo);
|
||||
gui.bricks.get(pos).params.add(paramNo, newParam);
|
||||
gui.bricks.get(pos).exchangeSlider(paramNo, newParam);
|
||||
paramChanged = true;
|
||||
}
|
||||
|
||||
void shade() {
|
||||
@@ -131,5 +133,16 @@ class Shader {
|
||||
result.beginDraw();
|
||||
result.image(renderer, 0, 0);
|
||||
result.endDraw();
|
||||
if (pos == gui.bricks.size()-1) {
|
||||
//println("Finished rendering");
|
||||
if (imageChanged) { //kind of hacky but it does synchronize the threads.
|
||||
stepOne++;
|
||||
if (stepOne == 2) {
|
||||
stepOne = 0;
|
||||
imageChanged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int stepOne = 0;
|
||||
|
||||
17
source.pde
17
source.pde
@@ -1,6 +1,6 @@
|
||||
Capture cam;
|
||||
Movie movie;
|
||||
boolean moviePlaying;
|
||||
boolean moviePlaying, imageChanged;
|
||||
PImage fallbackImage;
|
||||
|
||||
void movieEvent(Movie m) {
|
||||
@@ -29,13 +29,14 @@ boolean isImage(String path) {
|
||||
class SourceManager { //no constructor
|
||||
|
||||
|
||||
void setSource() { //set source to renderer
|
||||
renderer.beginDraw();
|
||||
void setSource() { //set source to renderer
|
||||
renderer.beginDraw();
|
||||
renderer.image(source, 0, 0, renderer.width, renderer.height);
|
||||
renderer.endDraw();
|
||||
}
|
||||
|
||||
|
||||
void setImage(PImage img) { //set image to source
|
||||
imageChanged = true;
|
||||
source = img.get();
|
||||
fallbackImage = source;
|
||||
nativeResoX = source.width;
|
||||
@@ -54,10 +55,10 @@ class SourceManager { //no constructor
|
||||
}
|
||||
|
||||
int toW, toH;
|
||||
if (source.width > source.height) {
|
||||
if (source.width > source.height) {
|
||||
toW = renderSize;
|
||||
toH = int(map(source.height, 0, source.width, 0, renderSize));
|
||||
} else {
|
||||
} else {
|
||||
toW = int(map(source.width, 0, source.height, 0, renderSize));
|
||||
toH = renderSize;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ class SourceManager { //no constructor
|
||||
}
|
||||
|
||||
|
||||
// This function returns all the files in a directory as an array of Strings
|
||||
// This function returns all the files in a directory as an array of Strings
|
||||
String[] listFileNames(String dir) {
|
||||
File file = new File(dir);
|
||||
if (file.isDirectory()) {
|
||||
@@ -98,7 +99,7 @@ class SourceManager { //no constructor
|
||||
for (int i = 0; i < usableFiles.size(); i++) selection[i] = usableFiles.get(i);
|
||||
println("Got new selection from folder. " + selection.length + " usable files.");
|
||||
path = dir + "/" + selection[(int)random(selection.length)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isImage(path) || isVideo(path)) {
|
||||
|
||||
Reference in New Issue
Block a user