Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

vflip & orientation #1976

Open
arturoc opened this Issue Mar 27, 2013 · 1 comment

Comments

Projects
None yet
2 participants
Owner

arturoc commented Mar 27, 2013

i'm trying to solve the orientation and vflip problems we constantly have. mostly in the new programable renderer but can be backported to the current ofGLRenderer.

some things i've found:

  1. ofViewport gets the viewport independent of the orientation, i think it should be aware of the orientation and swap the values accordingly to make it work. for example if you have an installation with the monitor turned 90º:

    ofViewport(20,20,320,240)

    is now setting the viewport in the right corner of the rotated screen with width 240, height 320

    I have this solved now but it could break some old code.

  2. ofSetupPerspective gets an ofOrientation parameter but it can also be set through ofSetOrientation. actually if you call ofSetupPerspective with a different orientation that the one currently set, you'll get unexpected behaviours. i think this is a bug and that we should remove that parameter from ofSetupPerspective and just have ofSetOrientation

  3. the vflip parameter should be a general setting instead of passing it to the viewport, setupPerspective, camera::setupPerspective... right now if you setup the perspective without vflip and then call ofViewport(rectangle) it'll try to flip the viewport since the ofViewport function has a default vflip to true. So what i propose is that we should have:

    ofSetVFlip(bool)

    which changes the behaviour for everything, it can also be queried so it's easier to do the right thing with cameras, fbos, cameras inside fbos...

  4. textures/images/fonts... with perspective without vflip are rendered upside down. if we had a general vflip setting this could be handled way easier

So in resume what i propose is:

ofSetupPerspective(float w, float h, float fov, float near, float far);
ofCamera::setupPerspective(float w, float h, float fov, float near, float far)


ofSetOrientation(ofOrientation o);
ofSetVFlip(bool)

or/and

ofSetOrientation(ofOrientation o, bool vflip)


ofViewport(ofRectangle)
ofViewport(float x, float y, float w, float h) 

where the viewport is set correctly according to the current orientation and vflip

ofGetCurrentViewport()  // returns the same viewport you set through ofViewport
ofGetNativeViewport()  // returns the viewport that is actually passed to openGL
Contributor

kylemcdonald commented Apr 4, 2013

i like the way you broke up the functions.

my only reaction is that it could be called ofSetVerticalFlip() for clarity. but the structure looks good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment