tacking the other direction on offscreen

This commit is contained in:
Ben Fry
2015-04-19 14:21:15 -04:00
parent e6c68399da
commit 9f1bef58bb
4 changed files with 27 additions and 10 deletions

View File

@@ -1679,6 +1679,9 @@ public class PApplet implements PConstants {
pg.setPrimary(primary);
if (path != null) pg.setPath(path);
// pg.setQuality(sketchQuality());
if (!primary) {
surface.initImage(pg, w, h);
}
pg.setSize(w, h);
// everything worked, return it

View File

@@ -103,6 +103,9 @@ public interface PSurface {
public void setSize(int width, int height);
// create pixel buffer (pulled out for offscreen graphics)
public void initImage(PGraphics gr, int wide, int high);
public void setSmooth(int level);
public void setFrameRate(float fps);

View File

@@ -203,7 +203,8 @@ public class PSurfaceAWT implements PSurface {
protected synchronized void render() {
if (!EventQueue.isDispatchThread()) {
//throw new IllegalStateException("render() called outside the EDT");
System.err.println("render() called outside the EDT");
//System.err.println("render() called outside the EDT");
new Exception("render() called outside the EDT").printStackTrace();
}
// if (canvas == null) {
// removeListeners(this);
@@ -739,6 +740,18 @@ public class PSurfaceAWT implements PSurface {
// frame.setLocationRelativeTo(null);
// }
initImage(graphics, wide, high);
//throw new RuntimeException("implement me, see readme.md");
sketch.width = wide;
sketch.height = high;
// set PGraphics variables for width/height/pixelWidth/pixelHeight
graphics.setSize(wide, high);
}
public void initImage(PGraphics gr, int wide, int high) {
GraphicsConfiguration gc = canvas.getGraphicsConfiguration();
// If not realized (off-screen, i.e the Color Selector Tool), gc will be null.
if (gc == null) {
@@ -749,15 +762,8 @@ public class PSurfaceAWT implements PSurface {
// Formerly this was broken into separate versions based on offscreen or
// not, but we may as well create a compatible image; it won't hurt, right?
int factor = graphics.pixelFactor;
graphics.image = gc.createCompatibleImage(wide * factor, high * factor);
//throw new RuntimeException("implement me, see readme.md");
sketch.width = wide;
sketch.height = high;
// sets internal variables for width/height/pixelWidth/pixelHeight
graphics.setSize(wide, high);
int factor = gr.pixelFactor;
gr.image = gc.createCompatibleImage(wide * factor, high * factor);
}

View File

@@ -415,6 +415,11 @@ public class PSurfaceLWJGL implements PSurface {
}
public void initImage(PGraphics gr, int wide, int high) {
// TODO not sure yet how to implement [fry]
}
@Override
public void setSmooth(int level) {
System.err.println("set smooth " + level);