Skip to content

Commit bfba153

Browse files
committed
add setters for boolean uniforms contributed by AmnonOwed, fixes processing#1991.
1 parent ced5262 commit bfba153

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,9 +5230,9 @@ protected void drawPixels(int x, int y, int w, int h) {
52305230

52315231
try {
52325232
if (0 < x || 0 < y || w < width || h < height) {
5233-
// The pixels to copy to the texture need to be consecutive, and they
5234-
// are not in the pixels array, so putting each row one after another
5235-
// in nativePixels.
5233+
// The pixels to be copied to the texture need to be consecutive, and
5234+
// they are not in the pixels array, so putting each row one after
5235+
// another in nativePixels.
52365236
int offset0 = y * width + x;
52375237
int offset1 = 0;
52385238

@@ -5324,6 +5324,17 @@ protected void setImpl(PImage sourceImage,
53245324
setgetPixels = true;
53255325
super.setImpl(sourceImage, sourceX, sourceY, sourceWidth, sourceHeight,
53265326
targetX, targetY);
5327+
// do we need this?
5328+
// see https://github.com/processing/processing/issues/2125
5329+
// if (sourceImage.format == RGB) {
5330+
// int targetOffset = targetY * width + targetX;
5331+
// for (int y = sourceY; y < sourceY + sourceHeight; y++) {
5332+
// for (int x = targetOffset; x < targetOffset + sourceWidth; x++) {
5333+
// pixels[x] |= 0xff000000;
5334+
// }
5335+
// targetOffset += width;
5336+
// }
5337+
// }
53275338
}
53285339

53295340

core/src/processing/opengl/PShader.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,24 +449,28 @@ public void set(String name, boolean x) {
449449

450450

451451
public void set(String name, boolean x, boolean y) {
452-
setUniformImpl(name, UniformValue.INT2, new int[] { (x)?1:0, (y)?1:0 });
452+
setUniformImpl(name, UniformValue.INT2,
453+
new int[] { (x)?1:0, (y)?1:0 });
453454
}
454455

455456

456457
public void set(String name, boolean x, boolean y, boolean z) {
457-
setUniformImpl(name, UniformValue.INT3, new int[] { (x)?1:0, (y)?1:0, (z)?1:0 });
458+
setUniformImpl(name, UniformValue.INT3,
459+
new int[] { (x)?1:0, (y)?1:0, (z)?1:0 });
458460
}
459461

460462

461463
public void set(String name, boolean x, boolean y, boolean z, boolean w) {
462-
setUniformImpl(name, UniformValue.INT4, new int[] { (x)?1:0, (y)?1:0, (z)?1:0, (w)?1:0 });
464+
setUniformImpl(name, UniformValue.INT4,
465+
new int[] { (x)?1:0, (y)?1:0, (z)?1:0, (w)?1:0 });
463466
}
464467

465468

466469
public void set(String name, int[] vec) {
467470
set(name, vec, 1);
468471
}
469472

473+
470474
/**
471475
* @param ncoords number of coordinates per element, max 4
472476
*/
@@ -510,14 +514,15 @@ public void set(String name, float[] vec, int ncoords) {
510514
}
511515
}
512516

517+
513518
public void set(String name, boolean[] vec) {
514519
set(name, vec, 1);
515520
}
516521

517522

518523
public void set(String name, boolean[] boolvec, int ncoords) {
519524
int[] vec = new int[boolvec.length];
520-
for (int i=0; i<boolvec.length; i++) {
525+
for (int i = 0; i < boolvec.length; i++) {
521526
vec[i] = (boolvec[i])?1:0;
522527
}
523528
set(name, vec, ncoords);

0 commit comments

Comments
 (0)