From 09de1306e5b98a9bae9365688b73a6270238805d Mon Sep 17 00:00:00 2001 From: codeanticode Date: Wed, 6 Nov 2013 09:00:20 -0500 Subject: [PATCH] filter shaders don't need to use the texture uniform, fixes #2204 --- core/src/processing/opengl/PGraphics2D.java | 6 ------ core/src/processing/opengl/PGraphicsOpenGL.java | 4 ++-- core/src/processing/opengl/PShader.java | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/src/processing/opengl/PGraphics2D.java b/core/src/processing/opengl/PGraphics2D.java index 9c1761cba..2d05921a1 100644 --- a/core/src/processing/opengl/PGraphics2D.java +++ b/core/src/processing/opengl/PGraphics2D.java @@ -180,12 +180,6 @@ public class PGraphics2D extends PGraphicsOpenGL { popProjection(); } -// @Override -// public void resetMatrix() { -// super.resetMatrix(); -// defaultCamera(); -// } - ////////////////////////////////////////////////////////////// diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index f613fc583..d0bdf524e 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -79,7 +79,7 @@ public class PGraphicsOpenGL extends PGraphics { static final String MISSING_UV_TEXCOORDS_ERROR = "No uv texture coordinates supplied with vertex() call"; static final String INVALID_FILTER_SHADER_ERROR = - "Your shader needs to be of TEXTURE type to be used as a filter"; + "Your shader cannot be used as a filter because is of type POINT or LINES"; static final String INCONSISTENT_SHADER_TYPES = "The vertex and fragment shaders have different types"; static final String WRONG_SHADER_TYPE_ERROR = @@ -5546,7 +5546,7 @@ public class PGraphicsOpenGL extends PGraphics { @Override public void filter(PShader shader) { - if (!shader.isPolyShader() || !shader.supportsTexturing()) { + if (!shader.isPolyShader()) { PGraphics.showWarning(INVALID_FILTER_SHADER_ERROR); return; } diff --git a/core/src/processing/opengl/PShader.java b/core/src/processing/opengl/PShader.java index 87c8e311b..c1030b219 100644 --- a/core/src/processing/opengl/PShader.java +++ b/core/src/processing/opengl/PShader.java @@ -108,6 +108,9 @@ public class PShader implements PConstants { protected IntBuffer intBuffer; protected FloatBuffer floatBuffer; + protected boolean loadedAttributes = false; + protected boolean loadedUniforms = false; + // Uniforms common to all shader types protected int transformMatLoc; protected int modelviewMatLoc; @@ -1048,30 +1051,37 @@ public class PShader implements PConstants { // // Processing specific + protected int getType() { return type; } + protected void setType(int type) { this.type = type; } + protected boolean hasType() { return POINT <= type && type <= TEXLIGHT; } + protected boolean isPointShader() { return type == POINT; } + protected boolean isLineShader() { return type == LINE; } + protected boolean isPolyShader() { return POLY <= type && type <= TEXLIGHT; } + protected boolean checkPolyType(int type) { if (getType() == PShader.POLY) return true; @@ -1091,15 +1101,17 @@ public class PShader implements PConstants { return true; } + protected int getLastTexUnit() { return texUnits == null ? -1 : texUnits.size() - 1; } + protected void setRenderer(PGraphicsOpenGL pg) { this.pg = pg; } - boolean loadedAttributes = false; + protected void loadAttributes() { if (loadedAttributes) return; @@ -1126,7 +1138,6 @@ public class PShader implements PConstants { } - boolean loadedUniforms = false; protected void loadUniforms() { if (loadedUniforms) return; transformMatLoc = getUniformLoc("transform");