From b5e72d07828e45218170ce1a7e609dc17eacb8bd Mon Sep 17 00:00:00 2001 From: codeanticode Date: Fri, 16 Dec 2011 06:50:25 +0000 Subject: [PATCH] Reverted changes in hints handling --- core/src/processing/core/PConstants.java | 25 +++++------ core/src/processing/core/PGraphics.java | 2 +- .../processing/opengl/PGraphicsOpenGL.java | 43 ++++++++++--------- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/core/src/processing/core/PConstants.java b/core/src/processing/core/PConstants.java index a793dd1af..84e0532d6 100644 --- a/core/src/processing/core/PConstants.java +++ b/core/src/processing/core/PConstants.java @@ -41,10 +41,10 @@ public interface PConstants { // render & flush modes (in P3D) static public final int IMMEDIATE = 0; - static public final int RETAINED = 1; + static public final int RETAINED = 1; - static public final int FLUSH_AFTER_SHAPE = 0; - static public final int FLUSH_WHEN_FULL = 1; + static public final int FLUSH_CONTINUOUSLY = 0; + static public final int FLUSH_WHEN_FULL = 1; // vertex fields @@ -550,31 +550,26 @@ public interface PConstants { // hints - hint values are positive for the alternate version, // negative of the same value returns to the normal/default state -// static final int DISABLE_OPENGL_2X_SMOOTH = 1; -// static final int ENABLE_OPENGL_2X_SMOOTH = -1; -// static final int ENABLE_OPENGL_4X_SMOOTH = 2; - - static final int ENABLE_NATIVE_FONTS = 1; static final int DISABLE_NATIVE_FONTS = -1; - static final int ENABLE_DEPTH_TEST = 2; - static final int DISABLE_DEPTH_TEST = -2; - + static final int DISABLE_DEPTH_TEST = 2; + static final int ENABLE_DEPTH_TEST = -2; + static final int ENABLE_DEPTH_SORT = 3; static final int DISABLE_DEPTH_SORT = -3; - static final int ENABLE_OPENGL_ERROR_REPORT = 4; - static final int DISABLE_OPENGL_ERROR_REPORT = -4; + static final int DISABLE_OPENGL_ERROR_REPORT = 4; + static final int ENABLE_OPENGL_ERROR_REPORT = -4; static final int ENABLE_ACCURATE_TEXTURES = 5; static final int DISABLE_ACCURATE_TEXTURES = -5; + static final int DISABLE_DEPTH_MASK = 6; static final int ENABLE_DEPTH_MASK = -6; - static final int DISABLE_DEPTH_MASK = 6; static final int ENABLE_ACCURATE_2D = 7; - static final int DISABLE_ACCURATE_2D = -7; + static final int DISABLE_ACCURATE_2D = -7; static final int HINT_COUNT = 8; diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 820e748e9..d4b90d313 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -3504,7 +3504,7 @@ public class PGraphics extends PImage implements PConstants { public void textFont(PFont which) { if (which != null) { textFont = which; - if (hintEnabled(ENABLE_NATIVE_FONTS)) { + if (hints[ENABLE_NATIVE_FONTS]) { //if (which.font == null) { which.findFont(); //} diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 6650e0417..412d26f38 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -1408,21 +1408,26 @@ public class PGraphicsOpenGL extends PGraphics { setDefaultBlend(); // this is necessary for 3D drawing - if (hintEnabled(ENABLE_DEPTH_TEST)) { - gl.glEnable(GL.GL_DEPTH_TEST); + if (hints[DISABLE_DEPTH_TEST]) { + gl.glDisable(GL.GL_DEPTH_TEST); } else { - gl.glDisable(GL.GL_DEPTH_TEST); + gl.glEnable(GL.GL_DEPTH_TEST); } // use <= since that's what processing.core does - //gl.glDepthFunc(GL.GL_LEQUAL); - gl.glDepthFunc(GL.GL_LESS); + gl.glDepthFunc(GL.GL_LEQUAL); - if (hintEnabled(ENABLE_DEPTH_MASK)) { - gl.glDepthMask(true); + if (hints[DISABLE_DEPTH_MASK]) { + gl.glDepthMask(false); } else { - gl.glDepthMask(false); + gl.glDepthMask(true); } + if (hints[ENABLE_ACCURATE_2D]) { + flushMode = FLUSH_CONTINUOUSLY; + } else { + flushMode = FLUSH_WHEN_FULL; + } + // setup opengl viewport. gl.glGetIntegerv(GL.GL_VIEWPORT, savedViewport, 0); gl.glViewport(0, 0, width, height); @@ -1491,7 +1496,7 @@ public class PGraphicsOpenGL extends PGraphics { gl.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); drawing = true; - drawing2D = false; + drawing2D = true; report("bot beginDraw()"); } @@ -1602,18 +1607,18 @@ public class PGraphicsOpenGL extends PGraphics { restoreGLMatrices(); // Restoring hints. - if (hintEnabled(DISABLE_DEPTH_TEST)) { - gl.glEnable(GL.GL_DEPTH_TEST); - } else { + if (hints[DISABLE_DEPTH_TEST]) { gl.glDisable(GL.GL_DEPTH_TEST); gl.glClearColor(0, 0, 0, 0); gl.glClear(GL.GL_DEPTH_BUFFER_BIT); + } else { + gl.glEnable(GL.GL_DEPTH_TEST); } - if (hintEnabled(ENABLE_DEPTH_MASK)) { - gl.glDepthMask(true); + if (hints[DISABLE_DEPTH_MASK]) { + gl.glDepthMask(false); } else { - gl.glDepthMask(false); + gl.glDepthMask(true); } // Restoring blending. @@ -1793,7 +1798,7 @@ public class PGraphicsOpenGL extends PGraphics { } else if (which == ENABLE_ACCURATE_2D) { flush(); - setFlushMode(FLUSH_AFTER_SHAPE); + setFlushMode(FLUSH_CONTINUOUSLY); } @@ -1945,7 +1950,7 @@ public class PGraphicsOpenGL extends PGraphics { tessellate(mode); - if (flushMode == FLUSH_AFTER_SHAPE || + if (flushMode == FLUSH_CONTINUOUSLY || (flushMode == FLUSH_WHEN_FULL && tess.isFull()) || (flushMode == FLUSH_WHEN_FULL && drawing2D && textureImage != null && stroke)) { // Flushing this current shape either because we are in the flush-after-shape, @@ -2210,7 +2215,6 @@ public class PGraphicsOpenGL extends PGraphics { // buffers. renderFill(textureImage); } - PApplet.println("flush fill"); } if (hasPoints) { @@ -2219,7 +2223,6 @@ public class PGraphicsOpenGL extends PGraphics { if (hasLines) { renderLines(); - PApplet.println("flush lines"); } if (flushMode == FLUSH_WHEN_FULL) { @@ -4957,7 +4960,7 @@ public class PGraphicsOpenGL extends PGraphics { * throw an GL_INVALID_OPERATION error. */ public void report(String where) { - if (hintEnabled(ENABLE_OPENGL_ERROR_REPORT)) { + if (!hints[DISABLE_OPENGL_ERROR_REPORT]) { int err = gl.glGetError(); if (err != 0) { String errString = glu.gluErrorString(err);