How to draw rotated ofViewport?


Hi, I’m trying to make the viewport get affected by ofTranslate, ofRotate and ofScale just like other drawing objects.

Thanks to @arturo, I learned how to find the translated coordinate in the middle of draw() call.

So right before calling ofViewport(ofRectangle), now I know exactly where 4 points of the rectangle area should be given width and height. But since ofRectangle class doesn’t have any methods like setRotation or setting rect by 4 points, I don’t know how to pass the rotated rectangle points to ofViewport.

Is it impossible to draw rotated ofViewport’s rectangular bounding area?
If so, would there be any way to hack it with openGL?

void ofGLRenderer::viewport(float x, float y, float width, float height, bool vflip) {

ofRectangle nativeViewport = matrixStack.getNativeViewport();


I thought I solved it but it was a mistake.

The objects within ofViewport do get affected by ofTranslate, ofRotate and ofScale.

However, the visible viewport area itself doesn’t get affected by any of them.

So I’m still looking for a solution. Please help.


the viewport can only be a rectangle oriented the same way as the screen, it can’t be rotated. you could draw the scene into and fbo and then draw that rotated though


I see. Thanks for your answer!