ravi.joshi53's picture

Flip the entire full screen game window

I wanted to flip the game window, which is opened in full screen mode. I am using orthographic projection. Using GL.Rotate in OnRenderFrame is not flipping the window.

By saying flipping the entire window, I mean to say that each and every object of this window should be flipped.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Since you are using an orthographic projection, flipping every object is as simple as flipping the top and bottom coordinates in your orthographic projection matrix.

jrwatts's picture

If you're using the fixed function pipeline, you could also just use GL.Scale with -1 for the axis you wish to flip, 1 for the others (IIRC; I'm a bit rusty on OpenGL at the moment!).

ravi.joshi53's picture
the Fiddler wrote:

Since you are using an orthographic projection, flipping every object is as simple as flipping the top and bottom coordinates in your orthographic projection matrix.

Fiddler, Can you please elaborate it more? I am using GL.Ortho(0, 10, 0, 10, 1, -1); And for flipping the full screen gamewindow, I am rotating each object by 180 degree around z axis . This is easy but irritating, as I need to do this process every time before drawing any object.

Thanks

winterhell's picture

If you want just a vertical flip( like in Paint) you can swap the coordinates to GL.Ortho(0, 10, 10, 0, 1, -1);
Rotating the object is not the same, as the left coordinates will become the right and vice-versa,same for the vertical ones. This is in case you only wanted to flip on one axis.
Alternatively, if you just want the objects to be backwards, but their screen positions / the viewport axis to remain unchanged( you like where your model matrices place the objects), you can reverse the position vertices on the model directly during loading. vertices[i].Position.Y*=-1;
The solution really depends on if you want the whole screen to be upside down,or only the objects themselves and not their position/rotation transforms.

ravi.joshi53's picture

Hi winterhell,

By saying flip, I mean to say flip the entire full screen game window by 180 degree around z axis passing through the center of the screen, assuming screen is placed in x-y plane . This is same as selecting orientation to landscape (flipped) under screen resolution option available in Windows 7. You can see the following screenshot and try if you have the same OS.

Hope its clear to you...

the Fiddler's picture

In that case, as winterhell suggested:

GL.Ortho(0, 10, 10, 0, 1, -1);

will do exactly this.

ravi.joshi53's picture

Fiddler,

I noticed that after selecting "landscape (flipped)" each and every object flipped, which is exactly I want. Currently I am rotating each and every object to achieve it. It works fine but irritating.

I tried GL.Ortho(10, 0, 10, 0, 1, -1); which works perfectly fine. The only problem I am facing is with QuickFont. Everything is flipped now except QuickFont. It seems that QuickFont is not following GL.Ortho Any idea please?

the Fiddler's picture

QuickFont is probably setting up its own orthographic projection inside QFont.Begin() / QFont.End(). Read the documentation for QFontRenderOptions.TransformViewport: it suggests not calling QFont.Begin/End and setting up your own projection for the fonts.

I'd suggest checking the source code for QFont.Begin, it should be a simple modification to make it do what you want.