Skip to content

Commit 6ebef4a

Browse files
committed
tacking the other direction on offscreen
1 parent ef9bcf5 commit 6ebef4a

4 files changed

Lines changed: 27 additions & 10 deletions

File tree

core/src/processing/core/PApplet.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,9 @@ protected PGraphics makeGraphics(int w, int h,
16791679
pg.setPrimary(primary);
16801680
if (path != null) pg.setPath(path);
16811681
// pg.setQuality(sketchQuality());
1682+
if (!primary) {
1683+
surface.initImage(pg, w, h);
1684+
}
16821685
pg.setSize(w, h);
16831686

16841687
// everything worked, return it

core/src/processing/core/PSurface.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ public Frame initFrame(PApplet sketch, Color backgroundColor,
103103

104104
public void setSize(int width, int height);
105105

106+
// create pixel buffer (pulled out for offscreen graphics)
107+
public void initImage(PGraphics gr, int wide, int high);
108+
106109
public void setSmooth(int level);
107110

108111
public void setFrameRate(float fps);

core/src/processing/core/PSurfaceAWT.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ public void addNotify() {
203203
protected synchronized void render() {
204204
if (!EventQueue.isDispatchThread()) {
205205
//throw new IllegalStateException("render() called outside the EDT");
206-
System.err.println("render() called outside the EDT");
206+
//System.err.println("render() called outside the EDT");
207+
new Exception("render() called outside the EDT").printStackTrace();
207208
}
208209
// if (canvas == null) {
209210
// removeListeners(this);
@@ -739,6 +740,18 @@ public void setSize(int wide, int high) {
739740
// frame.setLocationRelativeTo(null);
740741
// }
741742

743+
initImage(graphics, wide, high);
744+
745+
//throw new RuntimeException("implement me, see readme.md");
746+
sketch.width = wide;
747+
sketch.height = high;
748+
749+
// set PGraphics variables for width/height/pixelWidth/pixelHeight
750+
graphics.setSize(wide, high);
751+
}
752+
753+
754+
public void initImage(PGraphics gr, int wide, int high) {
742755
GraphicsConfiguration gc = canvas.getGraphicsConfiguration();
743756
// If not realized (off-screen, i.e the Color Selector Tool), gc will be null.
744757
if (gc == null) {
@@ -749,15 +762,8 @@ public void setSize(int wide, int high) {
749762

750763
// Formerly this was broken into separate versions based on offscreen or
751764
// not, but we may as well create a compatible image; it won't hurt, right?
752-
int factor = graphics.pixelFactor;
753-
graphics.image = gc.createCompatibleImage(wide * factor, high * factor);
754-
755-
//throw new RuntimeException("implement me, see readme.md");
756-
sketch.width = wide;
757-
sketch.height = high;
758-
759-
// sets internal variables for width/height/pixelWidth/pixelHeight
760-
graphics.setSize(wide, high);
765+
int factor = gr.pixelFactor;
766+
gr.image = gc.createCompatibleImage(wide * factor, high * factor);
761767
}
762768

763769

core/src/processing/opengl/PSurfaceLWJGL.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ public void setSize(int width, int height) {
415415
}
416416

417417

418+
public void initImage(PGraphics gr, int wide, int high) {
419+
// TODO not sure yet how to implement [fry]
420+
}
421+
422+
418423
@Override
419424
public void setSmooth(int level) {
420425
System.err.println("set smooth " + level);

0 commit comments

Comments
 (0)