kylemcdonald/ofxCv — pull request #122 by fieldOfView (2014-06-20 08:32:48+00:00)
Title: Refactor loadProjectionMatrix() to use OF matrix functions instead of gl

This patch changes the loadProjectionMatrix() method to use OF matrix functions instead of the underlying gl variants. This change is especially important when using the glprogrammablerenderer, which does not natively have (modelview/projection) matrix stacks. The ofMatrixStack was added to OF to work around this, but it is defeated if an app mixes OF and gl matrix functions.

One important sideeffect of using the OF functions is that gl assumes bottom-up coordinates and OF assumes top-down coordinates. See the discussion here:
http://forum.openframeworks.cc/t/why-is-ofmatrixstack-vflipped-by-default/16088
In this patch, I am creating the frustum matrix upsidedown to work around this change. This seems to work for me, but I am not sure how this influences the handedness of the projection and if this change affects backface-culling. This should be tested (by someone who understands this stuff)!

This patch also fixes a bug introduced in https://github.com/kylemcdonald/ofxCv/pull/105 which created the wrong lookatMatrix.