Image Manipulation

I want to do the following in some code I am working on. I posted this to see if anybody could show me why it would be a bad idea. I have a 3D geometry rendered to the screen. I will be using both perspective and orthographic projection. I need the following functionality:

  1. Zoom to the center of the image - glScalef(z, z, 1)
  2. Pan the image - glTranslatef(x, y, 0)
  3. Rotate the image in plane - glRotatef(r, 0, 0, 1)
  4. Flip the image horizontally (fx) and vertically (fy) - glScalef(1 - 2 * fx, 1 - 2 * fy, 1)

I would like to perform all of these calculations in the projection matrix. I believe this should be fine, since none of the operations above affect the direction or size of Z. I also think this would be a good idea since lighting normals will be unaffected by the scaling. So, what, if anything, is wrong with this approach?

Hehe… Is this a quiz/riddle of some kind, jtipton? If so, what do we win if we get the right answer?

P.S. I could use a new set of lawn chairs.

Does it have to be a “new” set of lawn chairs? By the way, thanks again for the Delphi link. That site is great.

Sounds like it should work. The only thing that might go slightly wrong is that the frustum will change relative to the geometry, which can affect non-linear vertex operations (like per-vertex lighting). You can avoid that in the non-rotated case by fiddling with glViewport to keep the frustum the same, although performance under a strong zoom (very large viewport) may depend on the driver.

Also remember that if you flip the image on one axis, you need to change glFrontFace.

I am not following the first 2 scenarios, but the glFrontFace catch is a good one.

I do the zoom in projection matrix, use glFrustum or gluPickMatrix
With glFrustum, you just input smaller values than previous.
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 1000.0)
glFrustum(-0.9, 0.9, -0.9, 0.9, 0.9, 1000.0)

All the others, I do on the modelview else it messes up glTexGen(GL_SPHERE_MAP) and perhaps there was another reason.

How does it mess up texture generation? Wouldn’t it just compute the coords without factoring in the transforms that I put into the projection matrix. The effect I want is to rotate, zoom, pan, and flip the result of the rendering. The “image” should be the same, just transformed in 2D.