Skip to content

Commit 2ce80c3

Browse files
committed
Adding set(boolean) methods + fix w in set(int) method
1 parent 141458d commit 2ce80c3

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

core/src/processing/opengl/PShader.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public void set(String name, int x, int y, int z) {
264264
* @param w fourth component of the variable to modify. The variable has to be declared with an array/vector type in the shader (i.e.: int[4], vec4)
265265
*/
266266
public void set(String name, int x, int y, int z, int w) {
267-
setUniformImpl(name, UniformValue.INT4, new int[] { x, y, z });
267+
setUniformImpl(name, UniformValue.INT4, new int[] { x, y, z, w });
268268
}
269269

270270

@@ -296,6 +296,26 @@ public void set(String name, PVector vec) {
296296
}
297297

298298

299+
public void set(String name, boolean x) {
300+
setUniformImpl(name, UniformValue.INT1, new int[] { (x)?1:0 });
301+
}
302+
303+
304+
public void set(String name, boolean x, boolean y) {
305+
setUniformImpl(name, UniformValue.INT2, new int[] { (x)?1:0, (y)?1:0 });
306+
}
307+
308+
309+
public void set(String name, boolean x, boolean y, boolean z) {
310+
setUniformImpl(name, UniformValue.INT3, new int[] { (x)?1:0, (y)?1:0, (z)?1:0 });
311+
}
312+
313+
314+
public void set(String name, boolean x, boolean y, boolean z, boolean w) {
315+
setUniformImpl(name, UniformValue.INT4, new int[] { (x)?1:0, (y)?1:0, (z)?1:0, (w)?1:0 });
316+
}
317+
318+
299319
public void set(String name, int[] vec) {
300320
set(name, vec, 1);
301321
}
@@ -343,6 +363,20 @@ public void set(String name, float[] vec, int ncoords) {
343363
}
344364
}
345365

366+
public void set(String name, boolean[] vec) {
367+
set(name, vec, 1);
368+
}
369+
370+
371+
public void set(String name, boolean[] boolvec, int ncoords) {
372+
int[] vec = new int[boolvec.length];
373+
for (int i=0; i<boolvec.length; i++) {
374+
vec[i] = (boolvec[i])?1:0;
375+
}
376+
set(name, vec, ncoords);
377+
}
378+
379+
346380
/**
347381
* @param mat matrix of values
348382
*/

0 commit comments

Comments
 (0)