We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to use glScissor, which works fine.
But how can I end glScissor?
If i use gl.glDisable(GL.GL_SCISSOR_TEST);
then the scissor gets disabled for the whole draw frame.
import processing.opengl.*;
import com.jogamp.opengl.*;
GL gl;
void setup() {
size(500, 500, P2D);
}
void draw() {
background(255);
if (gl == null) {
gl = ((PJOGL)beginPGL()).gl.getGL();
}
gl.glEnable(GL.GL_SCISSOR_TEST);
gl.glScissor(mouseX-50, height-mouseY-50, 100, 100);
stroke(255, 0, 0);
for (int i = -width; i < width; i += 5) {
line(i*5, 0, width + i*5, height);
}
// how to draw what we currently have?
//gl.glDisable(GL.GL_SCISSOR_TEST);
fill(255,0,0);
rect(0, height/2, width, 10);
}
Answers
Haha turns out processing has clip :D
I never knew that ... https://processing.org/reference/clip_.html
Hih. I never, ever noticed that there was a
clip()
in the reference. How odd. Thanks for pointing it out!That's a nice quick alternative to rectangular masking or some forms of compositing.
I think it was added in silence :)
...although it looks like
clip()
was added to the default renderer in 2012...