Skip to content

Commit

Permalink
added java doc to release
Browse files Browse the repository at this point in the history
started adding java doc to classes
  • Loading branch information
cansik committed Apr 4, 2017
1 parent 6680114 commit 23e01b7
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 19 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ configurations {
jar.archiveName = 'PostFX.jar'
}


javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Expand Down
82 changes: 67 additions & 15 deletions src/main/java/ch/bildspur/postfx/PostFXSupervisor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -74,13 +98,21 @@ public void render(PGraphics graphics) {
increasePass();
}

/**
* Apply pass to texture.
*
* @param pass Pass to apply.
*/
@Override
public void pass(Pass pass) {
pass.prepare(this);
pass.apply(this);
increasePass();
}

/**
* Compose and finalize rendering onto sketch texture.
*/
public void compose() {
//todo: not working at the moment

Expand All @@ -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);
Expand All @@ -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
Expand Down
45 changes: 43 additions & 2 deletions src/main/java/ch/bildspur/postfx/Supervisor.java
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 23e01b7

Please sign in to comment.