From 6c145683ba12e2e4a3102fd16cd3181b5c83d795 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Fri, 15 May 2015 11:30:27 -0400 Subject: [PATCH] fixes for present mode --- core/src/processing/opengl/PSurfaceJOGL.java | 33 ++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/core/src/processing/opengl/PSurfaceJOGL.java b/core/src/processing/opengl/PSurfaceJOGL.java index 073da73e5..f32678205 100644 --- a/core/src/processing/opengl/PSurfaceJOGL.java +++ b/core/src/processing/opengl/PSurfaceJOGL.java @@ -190,7 +190,10 @@ public class PSurfaceJOGL implements PSurface { fullScreen = true; } -// if (fullScreen || spanDisplays) { + if (fullScreen) { + presentMode = sketchWidth < screenRect.width && sketchHeight < screenRect.height; + } + if (spanDisplays) { sketchWidth = screenRect.width; sketchHeight = screenRect.height; @@ -198,6 +201,10 @@ public class PSurfaceJOGL implements PSurface { // window..setBackground(new Color(backgroundColor, true)); window.setSize(sketchWidth, sketchHeight); + sketch.width = sketch.sketchWidth(); + sketch.height = sketch.sketchHeight(); + graphics.setSize(sketch.width, sketch.height); + System.out.println("deviceIndex: " + deviceIndex); System.out.println(displayDevice); @@ -238,6 +245,8 @@ public class PSurfaceJOGL implements PSurface { DrawListener drawlistener = new DrawListener(); window.addGLEventListener(drawlistener); + + System.err.println("1. create animator"); animator = new FPSAnimator(window, 60); drawException = null; @@ -402,7 +411,7 @@ public class PSurfaceJOGL implements PSurface { float offsetX; float offsetY; public void placePresent(int stopColor) { - if (sketchWidth < screenRect.width || sketchHeight < screenRect.height) { + if (presentMode) { System.err.println("Present mode"); // System.err.println("WILL USE FBO"); presentMode = pgl.presentMode = true; @@ -460,13 +469,18 @@ public class PSurfaceJOGL implements PSurface { } public void setSize(int width, int height) { -// if (frame != null) { - System.err.println("3. set size"); + if (animator.isAnimating()) { + System.err.println("3. set size"); - sketchWidth = sketch.width = width; - sketchHeight = sketch.height = height; - graphics.setSize(width, height); -// } + if (!presentMode) { + sketch.width = width; + sketch.height = height; + graphics.setSize(width, height); + } + + sketchWidth = width; + sketchHeight = height; + } } public Component getComponent() { @@ -683,7 +697,8 @@ public class PSurfaceJOGL implements PSurface { if (presentMode) { - if (20 < nativeEvent.getX() && nativeEvent.getX() < 20 + 100 && + if (peAction == KeyEvent.RELEASE && + 20 < nativeEvent.getX() && nativeEvent.getX() < 20 + 100 && screenRect.height - 70 < nativeEvent.getY() && nativeEvent.getY() < screenRect.height - 20) { System.err.println("clicked on exit button"); // if (externalMessages) {