Why is ofMatrixStack vFlipped by default?

For an app that I am converting so it runs on a Raspberry PI (GL ES, programmable renderer), I am replacing all glViewport(), glMatrixMode() and glMultMatrix() etc calls to their new oF8 ofViewport(), ofSetMatrixMode() and ofMultMatrix() counterparts. This works great except that everything renders upsidedown.

This seems to be caused by the vFlipped variable in the renderers ofMatrixStack. In this commit, @arturo changed this variable to be true by default:

I think this is may have been done to prevent FBOs from rendering upside down, but as a result now everything (that uses the ofMatrixStack) that is not rendered to FBOs renders upside down (unless you reset vFlipped by calling ofSetOrientation(ofGetOrientation(), false);. Note not consistently using the of* counterparts of the mentioned gl* functions succesfully circumvents the ofMatrixStack of the renderer, so unless you have to use of* (eg because glutLookat() is not available for gl es) you will not notice this.

I don’t know much about FBOs or even view matrices, so I may be quite wrong about this. I just kept poking at code until it rendered right-side-up. Please enlighten me, is this an oversight or by design?

OF has the coordinates origin at top-left by default, while usually opengl has the origin in the center of the screen or bottom-down corned with y growing upwards. so vflip is always true by default in OF. if you’ve been setting your own matrices… OF applies one more matrix, an orientation one to apply the vflip and any other orientation. You can disable it doing:


in setup

Ah, so the difference between using the gl*/glut* calls directly and using the new of* calls (going the ofMatrixStack route) is that gl* assumes gl coordinates and of* assumes openframeworks coordinates? Then my misconception was that the of* calls were supposed to be drop-in replacements.


they are mostly drop-in replacements except for that bit

I’m sure this has been given ample thought, but would it not be less confusing if they were actual drop-in replacements (including that bit)? Or is there going to be an active push towards openframeworks-coordinate-ness?

OF has always behaved like that so changing it now would break a ton of code, it’s also easy to set OF to behave like default openGL with the call i posted before so it’s the best solution we think

I’m trying not to be argumentative, but this code (ofMatrixStack) did not exist until april last year, at which point (it seems to me) it behaved like openGL until it was changed not to behave like openGL a few months later. But I’ll admit I have no idea of the code-breakage in changing this (back).

I love how the ofMatrixStack brings parity to the GLRenderer and GLProgrammableRenderer. And thanks for clearing up the decision.

yes what i meant is that OF always have had the 0,0 at the top, left with y growing downwards so if we had switched to vflip=false by default every old project using mostly OF calls will have rendered upside down.

also, before, this whole behaviour was kind of erratic, with some complex combinations, like fbo or fbo + shader… you never knew what was going to happen. with the programmable renderer we have much more control over that. now everything has 0,0 at top.left but you can always switch it by setting the orientation