ofViewport clipped inside ofViewport?

Is it possible to draw ofViewport clipped inside another ofViewport?
Here’s my code below.

void ofApp::draw(){
    
ofPushView();

ofViewport(100,100,400,400);
ofSetupScreen();
ofSetColor(ofColor::yellow);
ofDrawCircle(0, 0, 1000);

ofViewport(200,200,400,400);
ofSetupScreen();
ofSetColor(ofColor::red);
ofDrawCircle(0, 0, 1000);

ofPopView();
}

And this is the result I get


I was expecting the second viewport area to be clipped inside the first one but as you can see it didn’t clip.
Does ofViewport always work separately?
Isn’t it possible to make sub-viewports inside another one?

not directly, ofViewport always sets the state of opengl directly based on the whole screen. you can use the tools in ofRectangle to do this kind of thing and then use the resulting rectangle to setup the viewport

1 Like

Thank you @arturo