openframeworks / openframeworks/openFrameworks
vflip & orientation
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
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:
-
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.
-
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
-
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...
-
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 guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the ofViewport, ofSetupPerspective, ofCamera::setupPerspective, and ofSetOrientation entry points in the programmable renderer and current ofGLRenderer. Compare how orientation and vflip reach the viewport, cameras, textures, images, and fonts. Done means the intended API and consistent orientation/vflip behavior are defined and verified across these paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100