OpenGL viewport aspect ratio
Monkey Forums/Monkey Programming/OpenGL viewport aspect ratio
| ||
Hi all, I have been messing about with openGL module for monkey, Everything seems fine except for 1 thing, How on earth do you set the aspect ratio to avoid the dreaded stretching of drawn objects? I have googled and I am getting nowhere, surely it must be possible to change the aspect so objects are drawn properly but it's not at all obvious, can someone please help me :) Cheers, Grant. |
| ||
Have a look at AutoFit ;) |
| ||
Thanks therevills, I use the lovely autofit regular but sadly it's not what I'm looking for this time around. I want everything to run at the device native resolution and be independent of physical aspect ratios, no borders, OpenGL viewport with perspective rendering. IIRC from doing similar in XNA It's something to do with the view or projection matrix and a homogeneous viewport. Cheers, Grant. YAY, fixed!!! setting the aspect in glFrustumf done the damage :) |
| ||
isn't it just window width/height? Cheers Charlie |
| ||
Hi charlie, Almost dude, cheers, Grant. |
| ||
A little bit confused here, what does the above code actually do to the viewport? |
| ||
It's setting the clipping planes according to dimensions described by the floats, think of it as describing the shape you would see projected in space, a kind of distorted cube or pyramid with the top chopped of that describes the volume everything is rendered in. you need to tell opengl the shape of the window or screen so it can adjust this crazy pyramid to prevent stretching of rendered objects. Any ratio, any pixel aspect is catered for, some hardware uses non square pixels, so the viewport settings do not always describe the shape of the screen or window. left, right, bottom, top, near, far clipping planes. I'm assuming a 1:1 pixel aspect ratio (square pixels) in this code. cheers, grant. |
| ||
Ah, now I see, thanks for that explanation Grant. |