From 0ff68bca2faed84809010322b2ebd824dcfe0c34 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Thu, 24 Oct 2013 23:58:45 -0400 Subject: [PATCH] add setters for boolean uniforms contributed by AmnonOwed, fixes #1991. --- core/src/processing/opengl/PGraphicsOpenGL.java | 17 ++++++++++++++--- core/src/processing/opengl/PShader.java | 13 +++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index e87be1980..7608ca292 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -5230,9 +5230,9 @@ public class PGraphicsOpenGL extends PGraphics { try { if (0 < x || 0 < y || w < width || h < height) { - // The pixels to copy to the texture need to be consecutive, and they - // are not in the pixels array, so putting each row one after another - // in nativePixels. + // The pixels to be copied to the texture need to be consecutive, and + // they are not in the pixels array, so putting each row one after + // another in nativePixels. int offset0 = y * width + x; int offset1 = 0; @@ -5324,6 +5324,17 @@ public class PGraphicsOpenGL extends PGraphics { setgetPixels = true; super.setImpl(sourceImage, sourceX, sourceY, sourceWidth, sourceHeight, targetX, targetY); +// do we need this? +// see https://github.com/processing/processing/issues/2125 +// if (sourceImage.format == RGB) { +// int targetOffset = targetY * width + targetX; +// for (int y = sourceY; y < sourceY + sourceHeight; y++) { +// for (int x = targetOffset; x < targetOffset + sourceWidth; x++) { +// pixels[x] |= 0xff000000; +// } +// targetOffset += width; +// } +// } } diff --git a/core/src/processing/opengl/PShader.java b/core/src/processing/opengl/PShader.java index b0ef40ac2..c7f996ff0 100644 --- a/core/src/processing/opengl/PShader.java +++ b/core/src/processing/opengl/PShader.java @@ -449,17 +449,20 @@ public class PShader implements PConstants { public void set(String name, boolean x, boolean y) { - setUniformImpl(name, UniformValue.INT2, new int[] { (x)?1:0, (y)?1:0 }); + setUniformImpl(name, UniformValue.INT2, + new int[] { (x)?1:0, (y)?1:0 }); } public void set(String name, boolean x, boolean y, boolean z) { - setUniformImpl(name, UniformValue.INT3, new int[] { (x)?1:0, (y)?1:0, (z)?1:0 }); + setUniformImpl(name, UniformValue.INT3, + new int[] { (x)?1:0, (y)?1:0, (z)?1:0 }); } public void set(String name, boolean x, boolean y, boolean z, boolean w) { - setUniformImpl(name, UniformValue.INT4, new int[] { (x)?1:0, (y)?1:0, (z)?1:0, (w)?1:0 }); + setUniformImpl(name, UniformValue.INT4, + new int[] { (x)?1:0, (y)?1:0, (z)?1:0, (w)?1:0 }); } @@ -467,6 +470,7 @@ public class PShader implements PConstants { set(name, vec, 1); } + /** * @param ncoords number of coordinates per element, max 4 */ @@ -510,6 +514,7 @@ public class PShader implements PConstants { } } + public void set(String name, boolean[] vec) { set(name, vec, 1); } @@ -517,7 +522,7 @@ public class PShader implements PConstants { public void set(String name, boolean[] boolvec, int ncoords) { int[] vec = new int[boolvec.length]; - for (int i=0; i