mirror of
https://github.com/processing/processing4.git
synced 2026-02-20 22:05:39 +01:00
working on a fix for issue #1648
This commit is contained in:
@@ -1137,8 +1137,11 @@ public class PGL {
|
||||
}
|
||||
|
||||
|
||||
protected boolean prevCanDraw = false;
|
||||
protected void requestDraw() {
|
||||
if (pg.initialized && pg.parent.canDraw()) {
|
||||
boolean canDraw = pg.parent.canDraw();
|
||||
System.out.println(canDraw + " " + pg.parent.frameCount);
|
||||
if (pg.initialized && (canDraw || prevCanDraw)) {
|
||||
try {
|
||||
drawLatch = new CountDownLatch(1);
|
||||
if (WINDOW_TOOLKIT == AWT) {
|
||||
@@ -1151,6 +1154,9 @@ public class PGL {
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (canDraw) prevCanDraw = true;
|
||||
else prevCanDraw = false;
|
||||
} catch (GLException e) {
|
||||
// Unwrap GLException so that only the causing exception is shown.
|
||||
Throwable tr = e.getCause();
|
||||
@@ -1164,6 +1170,15 @@ public class PGL {
|
||||
}
|
||||
|
||||
|
||||
protected void swapBuffers() {
|
||||
if (WINDOW_TOOLKIT == AWT) {
|
||||
canvasAWT.swapBuffers();
|
||||
} else if (WINDOW_TOOLKIT == NEWT) {
|
||||
window.swapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean threadIsCurrent() {
|
||||
return Thread.currentThread() == glThread;
|
||||
}
|
||||
@@ -2538,6 +2553,7 @@ public class PGL {
|
||||
@Override
|
||||
public void display(GLAutoDrawable glDrawable) {
|
||||
if (drawLatch == null || drawLatch.getCount() == 0) return;
|
||||
System.out.println("display " + pg.parent.frameCount);
|
||||
drawable = glDrawable;
|
||||
context = glDrawable.getContext();
|
||||
|
||||
|
||||
@@ -635,6 +635,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
public void dispose() { // PGraphics
|
||||
super.dispose();
|
||||
|
||||
// Swap buffers the end to make sure that no
|
||||
// garbage is shown on the screen, this particularly
|
||||
// affects non-interactive sketches on windows that
|
||||
// render only 1 frame, so no enough rendering
|
||||
// iterations have been conducted so far to properly
|
||||
// initialize all the buffers.
|
||||
pgl.swapBuffers();
|
||||
|
||||
deletePolyBuffers();
|
||||
deleteLineBuffers();
|
||||
deletePointBuffers();
|
||||
@@ -5149,6 +5157,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
|
||||
protected void restoreSurfaceFromPixels() {
|
||||
System.out.println("restoreSurfaceFromPixels");
|
||||
drawPixels(0, 0, width, height);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user