diff --git a/build.gradle b/build.gradle index 537f395..03a2a01 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,6 @@ configurations { jar.archiveName = 'PostFX.jar' } - javadoc { source = sourceSets.main.allJava classpath = configurations.compile diff --git a/release.sh b/release.sh index 699e34e..32b40e6 100755 --- a/release.sh +++ b/release.sh @@ -41,7 +41,7 @@ cp -r "src" "$OUTPUT/" # create release files cd "release/" rm -f "PostFX.zip" -zip -r "PostFX.zip" "PostFX" +zip -r "PostFX.zip" "PostFX" -x "*.DS_Store" # store it with version number cd .. diff --git a/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java b/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java index 76d4e67..793560a 100644 --- a/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java +++ b/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java @@ -7,7 +7,7 @@ import java.nio.file.Path; /** - * Created by cansik on 26.03.17. + * Handles ping-pong pass buffer. */ public class PostFXSupervisor implements Supervisor { private PApplet sketch; @@ -25,43 +25,67 @@ public class PostFXSupervisor implements Supervisor { // frameBuffer private PGraphics[] passBuffers; - public PostFXSupervisor(PApplet sketch) - { + /** + * Create a new ping-pong pass buffer. + * + * @param sketch Processing context. Sketch size will be used. + */ + public PostFXSupervisor(PApplet sketch) { this(sketch, sketch.width, sketch.height); } - public PostFXSupervisor(PApplet sketch, int width, int height) - { + /** + * Create a new ping-pong pass buffer. + * + * @param sketch Processing context. + * @param width Width of the pass buffer. + * @param height Height of the pass buffer. + */ + public PostFXSupervisor(PApplet sketch, int width, int height) { this.sketch = sketch; setResolution(width, height); - - // init temp pass buffer - passBuffers = new PGraphics[PASS_NUMBER]; - for (int i = 0; i < passBuffers.length; i++) - { - passBuffers[i] = sketch.createGraphics(width, height, PApplet.P2D); - passBuffers[i].noSmooth(); - } } - private void increasePass() - { + private void increasePass() { passIndex = (passIndex + 1) % passBuffers.length; } + /** + * Set new resolution and re-init buffer. + * + * @param width New width of the pass buffer. + * @param height New height of the pass buffer. + */ @Override public void setResolution(int width, int height) { this.width = width; this.height = height; + // init temp pass buffer + passBuffers = new PGraphics[PASS_NUMBER]; + for (int i = 0; i < passBuffers.length; i++) { + passBuffers[i] = sketch.createGraphics(width, height, PApplet.P2D); + passBuffers[i].noSmooth(); + } + resolution = new int[]{width, height}; } + /** + * Returns pass buffer resolution. + * + * @return Int array as shader uniform. + */ @Override public int[] getResolution() { return resolution; } + /** + * Start a new multi-pass rendering. + * + * @param graphics Texture used as input. + */ @Override public void render(PGraphics graphics) { PGraphics pass = getNextPass(); @@ -74,6 +98,11 @@ public void render(PGraphics graphics) { increasePass(); } + /** + * Apply pass to texture. + * + * @param pass Pass to apply. + */ @Override public void pass(Pass pass) { pass.prepare(this); @@ -81,6 +110,9 @@ public void pass(Pass pass) { increasePass(); } + /** + * Compose and finalize rendering onto sketch texture. + */ public void compose() { //todo: not working at the moment @@ -90,6 +122,11 @@ public void compose() { sketch.g.endDraw(); } + /** + * Compose and finalize rendering. + * + * @param graphics Texture to render onto. + */ @Override public void compose(PGraphics graphics) { clearPass(graphics); @@ -99,17 +136,32 @@ public void compose(PGraphics graphics) { graphics.endDraw(); } + /** + * Get next pass of the pass buffer. + * + * @return Next pass of the pass buffer. + */ @Override public PGraphics getNextPass() { int nextIndex = (passIndex + 1) % passBuffers.length; return passBuffers[nextIndex]; } + /** + * Get current pass of the pass buffer. + * + * @return Current pass of the pass buffer. + */ @Override public PGraphics getCurrentPass() { return passBuffers[passIndex]; } + /** + * Clear a pass (black with alpha). + * + * @param pass Pass to clear. + */ @Override public void clearPass(PGraphics pass) { // clear pass buffer diff --git a/src/main/java/ch/bildspur/postfx/Supervisor.java b/src/main/java/ch/bildspur/postfx/Supervisor.java index 60f4c94..0b4f5c4 100644 --- a/src/main/java/ch/bildspur/postfx/Supervisor.java +++ b/src/main/java/ch/bildspur/postfx/Supervisor.java @@ -1,26 +1,67 @@ package ch.bildspur.postfx; import ch.bildspur.postfx.pass.Pass; -import processing.core.PApplet; import processing.core.PGraphics; /** - * Created by cansik on 26.03.17. + * Handles the pass buffer and render technique. */ public interface Supervisor { + + /** + * Reset the resolution of the pass buffer. + * + * @param width New width of the pass buffer. + * @param height New height of the pass buffer. + */ void setResolution(int width, int height); + /** + * Returns pass buffer resolution. + * + * @return Int array as shader uniform. + */ int[] getResolution(); + /** + * Start a new multi-pass rendering. + * + * @param graphics Texture used as input. + */ void render(PGraphics graphics); + /** + * Apply pass to texture. + * + * @param pass Pass to apply. + */ void pass(Pass pass); + /** + * Compose and finalize rendering. + * + * @param graphics Texture to render onto. + */ void compose(PGraphics graphics); + /** + * Get next pass of the pass buffer. + * + * @return Next pass of the pass buffer. + */ PGraphics getNextPass(); + /** + * Get current pass of the pass buffer. + * + * @return Current pass of the pass buffer. + */ PGraphics getCurrentPass(); + /** + * Clear a pass (black with alpha). + * + * @param pass Pass to clear. + */ void clearPass(PGraphics pass); }