Skip to content

Commit 2b0c9a1

Browse files
committed
pixeldensity bug solved by adding new parameter fixed #27
1 parent 499d8ea commit 2b0c9a1

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

src/main/java/ch/bildspur/postfx/PostFXSupervisor.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,39 @@ public int[] getResolution() {
9393
* Start a new multi-pass rendering with the screen framebuffer.
9494
*/
9595
public void render() {
96-
sketch.g.endDraw();
97-
render(sketch.g);
98-
sketch.g.beginDraw();
96+
render(sketch.g, true);
9997
}
10098

10199
/**
102100
* Start a new multi-pass rendering.
103101
*
104102
* @param graphics Texture used as input.
105103
*/
106-
@Override
107104
public void render(PImage graphics) {
105+
render(graphics, false);
106+
}
107+
108+
/**
109+
* Start a new multi-pass rendering.
110+
*
111+
* @param graphics Texture used as input.
112+
* @param toggleDraw Toggles the draw state of the graphics object inside the draw toggle of the pass.
113+
*/
114+
@Override
115+
public void render(PImage graphics, boolean toggleDraw) {
108116
PGraphics pass = getNextPass();
109117
clearPass(pass);
110118

111119
pass.beginDraw();
112-
/*
113-
pass.image(graphics, 0, 0, width, height,
114-
0, (int) (height * -1f), width * graphics.pixelDensity, (int) (0.5f * height * graphics.pixelDensity));
115-
*/
120+
121+
if (toggleDraw)
122+
((PGraphics) graphics).endDraw();
123+
116124
pass.image(graphics, 0, 0, width, height);
125+
126+
if (toggleDraw)
127+
((PGraphics) graphics).beginDraw();
128+
117129
pass.endDraw();
118130

119131
increasePass();

src/main/java/ch/bildspur/postfx/Supervisor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ public interface Supervisor {
2828
/**
2929
* Start a new multi-pass rendering.
3030
*
31-
* @param graphics Texture used as input.
31+
* @param graphics Texture used as input.
32+
* @param toggleDraw Toggles the draw state of the graphics object inside the draw toggle of the pass.
3233
*/
33-
void render(PImage graphics);
34+
void render(PImage graphics, boolean toggleDraw);
3435

3536
/**
3637
* Apply pass to texture.

src/test/java/ch/bildspur/postfx/SimpleSketch.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void main(String... args) {
2727

2828
public void settings() {
2929
size(720, 720, P3D);
30-
pixelDensity(1);
30+
pixelDensity(2);
3131
}
3232

3333
public void setup() {
@@ -75,7 +75,9 @@ void renderExample(PGraphics graphics) {
7575
// clear screen
7676
graphics.background(0);
7777

78-
graphics.fill(255);
78+
79+
graphics.noFill();
80+
graphics.stroke(255);
7981
graphics.ellipse(width / 2, height / 2, width * 0.75f, height * 0.75f);
8082

8183
// render simple cube

0 commit comments

Comments
 (0)