Skip to content

Commit

Permalink
pixeldensity bug solved by adding new parameter fixed #27
Browse files Browse the repository at this point in the history
  • Loading branch information
cansik committed Feb 6, 2019
1 parent 499d8ea commit 2b0c9a1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
28 changes: 20 additions & 8 deletions src/main/java/ch/bildspur/postfx/PostFXSupervisor.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,39 @@ public int[] getResolution() {
* Start a new multi-pass rendering with the screen framebuffer.
*/
public void render() {
sketch.g.endDraw();
render(sketch.g);
sketch.g.beginDraw();
render(sketch.g, true);
}

/**
* Start a new multi-pass rendering.
*
* @param graphics Texture used as input.
*/
@Override
public void render(PImage graphics) {
render(graphics, false);
}

/**
* Start a new multi-pass rendering.
*
* @param graphics Texture used as input.
* @param toggleDraw Toggles the draw state of the graphics object inside the draw toggle of the pass.
*/
@Override
public void render(PImage graphics, boolean toggleDraw) {
PGraphics pass = getNextPass();
clearPass(pass);

pass.beginDraw();
/*
pass.image(graphics, 0, 0, width, height,
0, (int) (height * -1f), width * graphics.pixelDensity, (int) (0.5f * height * graphics.pixelDensity));
*/

if (toggleDraw)
((PGraphics) graphics).endDraw();

pass.image(graphics, 0, 0, width, height);

if (toggleDraw)
((PGraphics) graphics).beginDraw();

pass.endDraw();

increasePass();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ch/bildspur/postfx/Supervisor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ public interface Supervisor {
/**
* Start a new multi-pass rendering.
*
* @param graphics Texture used as input.
* @param graphics Texture used as input.
* @param toggleDraw Toggles the draw state of the graphics object inside the draw toggle of the pass.
*/
void render(PImage graphics);
void render(PImage graphics, boolean toggleDraw);

/**
* Apply pass to texture.
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/ch/bildspur/postfx/SimpleSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void main(String... args) {

public void settings() {
size(720, 720, P3D);
pixelDensity(1);
pixelDensity(2);
}

public void setup() {
Expand Down Expand Up @@ -75,7 +75,9 @@ void renderExample(PGraphics graphics) {
// clear screen
graphics.background(0);

graphics.fill(255);

graphics.noFill();
graphics.stroke(255);
graphics.ellipse(width / 2, height / 2, width * 0.75f, height * 0.75f);

// render simple cube
Expand Down

0 comments on commit 2b0c9a1

Please sign in to comment.