Hi…,
I want to draw directly into my viewport, without an ofFBO, and I need some clipping.
I want only to draw in a rectangle (e.g. ofRectangle ( 100, 100, 500, 200), my objects should be clipped with this rectangle.
Can I clip left, right, top, and bottom with an ofCamera and how?
Thanks
Mike
arturo
June 26, 2014, 8:22pm
#2
camera.begin(ofRectangle ( 100, 100, 500, 200));
should work
1 Like
Hi Arturo,
yes, I’ve tried this one in the void ofApp::draw() method, but with no effect:
ofCamera camera;
camera.begin( ofRectangle ( 100, 100, 500, 200) );
camera.end();
ofRect(0,0,300,800);
Any ideas?
Thanks
Mike
arturo
June 27, 2014, 9:51am
#4
you have to draw things between begin/end, also when using a camera the default behaviour is 0,0 at the center of the viewport and y growing upwards so don’t expect the same code you might be using with the default perspective to work the same
Hi arturo,
I get nuts, my following code shows still nothing:
ofCamera camera;
camera.begin( ofRectangle ( 0, 0, 600, 600) );
ofRect(0,0,300,800);
camera.end();
Is there an working 2D example?
Thanks
Mike
Hi…,
I have found this
void ofViewport(ofRectangle viewport)
function, which does exactly what I need, without an ofCamera.
Thanks
Mike
Sorry again,
now I have found for me the best 2D border clipping function:
glScissor( x, y, width, height);
glEnable(GL_SCISSOR_TEST);
Thanks
Mike