From 2b0c9a1b37a21fbae933bc9fc4c899d71b0f09ab Mon Sep 17 00:00:00 2001 From: Florian Bruggisser Date: Wed, 6 Feb 2019 20:04:15 +0100 Subject: [PATCH] pixeldensity bug solved by adding new parameter fixed #27 --- .../ch/bildspur/postfx/PostFXSupervisor.java | 28 +++++++++++++------ .../java/ch/bildspur/postfx/Supervisor.java | 5 ++-- .../java/ch/bildspur/postfx/SimpleSketch.java | 6 ++-- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java b/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java index 99142e9..1c1b2e2 100644 --- a/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java +++ b/src/main/java/ch/bildspur/postfx/PostFXSupervisor.java @@ -93,9 +93,7 @@ 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); } /** @@ -103,17 +101,31 @@ public void render() { * * @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(); diff --git a/src/main/java/ch/bildspur/postfx/Supervisor.java b/src/main/java/ch/bildspur/postfx/Supervisor.java index 55a081c..077704a 100644 --- a/src/main/java/ch/bildspur/postfx/Supervisor.java +++ b/src/main/java/ch/bildspur/postfx/Supervisor.java @@ -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. diff --git a/src/test/java/ch/bildspur/postfx/SimpleSketch.java b/src/test/java/ch/bildspur/postfx/SimpleSketch.java index 7b1cd0a..492a597 100644 --- a/src/test/java/ch/bildspur/postfx/SimpleSketch.java +++ b/src/test/java/ch/bildspur/postfx/SimpleSketch.java @@ -27,7 +27,7 @@ public static void main(String... args) { public void settings() { size(720, 720, P3D); - pixelDensity(1); + pixelDensity(2); } public void setup() { @@ -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