PDA

View Full Version : vertically mirror screen?



karx11erx
02-07-2008, 05:29 PM
How do I horizontally mirror the rendering output of OpenGL (i.e. flip left and right around the vertical through the center of the screen)? glScalef (-1.0, 1.0, 1.0) doesn't do the trick.

arekkusu
02-07-2008, 08:12 PM
glViewport(0, w, 0, h)
vs
glViewport(w, 0, 0, h)

Interface
02-07-2008, 08:31 PM
void glViewport( GLint x, GLint y, GLsizei width, GLsizei height )

(0, w, 0, h) would have to be (0, 0, w, h).
Anyway, i haven't tried doing a negative width or height, not sure what happens.
According to the specs: ( link (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/viewport.html) ) Viewport width and height are silently clamped to a range that depends on the implementation.

edit:
Spec also says:
Error GL_INVALID_VALUE is generated if either width or height is negative.

-NiCo-
02-08-2008, 01:01 AM
glScalef (-1.0, 1.0, 1.0) doesn't do the trick.

Yes it does. It just depends where you put it. Normally you have

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(...);

Change that to:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glScalef (-1.0, 1.0, 1.0);
glFrustum(...);

N.

ZbuffeR
02-08-2008, 01:47 AM
And don't forget to reverse what opengl considers front-facing polygons, else backface culling will not work as you expect.
It happened to me :)

karx11erx
02-08-2008, 02:44 AM
I tried to flip the projection matrix too, but it didn't work. May well have been due to face culling though. Thank you all very much, I'll try your suggestions.

Edit:

Messing around with the viewport does not work. I need to flip the projection matrix and the face culling - the latter was the problem. :)