vertically mirror screen?

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.

glViewport(0, w, 0, h)
glViewport(w, 0, 0, h)

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 ) Viewport width and height are silently clamped to a range that depends on the implementation.

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

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


Change that to:

glScalef (-1.0, 1.0, 1.0);


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 :slight_smile:

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.


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