View Full Version : opengl viewport scaling
08-27-2012, 09:36 AM
Hello guys bluBee again.
I have been playing with opengles2.0 and working with viewports, now I am creating some art, basically I will draw 2 triangles and map it across the entire screen with a texture, then additional layers of meshes with additional art.
The question is, since this is hand drawn art and the devices that this will be displayed on can range quite a bit. I am curious and how to handle scaling of the viewport. I do not want to put black bars along the side, I would prefer to have more of the art shown ala widescreen. I was just wondering could anyone give some advice as to how one could go about setting up something like that.
09-06-2012, 10:14 AM
no one has any help?
Maybe I can try to state the question more clearly.
Say I design a opengl program for a view port 800x600.
Then I want to resize the view port to say 1024x600
How would I program it so that instead of streaching both vertical and horizontal or doing letterbox, I would prefer to do a widescreen effect to have the view port expand horizontally to fill the extra space.
I hope this is a little clearer and someone can offer some advice.
09-06-2012, 01:06 PM
If you setup your projection matrix correctly everything should be fine in the 3d part of your code.
One part of the projection matrix take account of the ration between height and width of the screen. Usually the vertical fov is considered constant and the orizontal fov is changed accordingly with the viewport. I usually set the fov for the biggest dimension and adjust the other Fov, in this way you can avoid big distortion when you have viewport like 1980x150. :D
For the 2d part (UI) usually the best solution is to move the buttons and other ui stuff, without scale them, but that's a design choise.
09-06-2012, 07:46 PM
What you explained is what I am trying to achieve but don't know how to do it yet, do you have any links or resources that can give me an example setup that I can follow just to get the hang of it my first time through?
09-07-2012, 11:38 AM
and let's say your window size is 1000 x 600 and you want to render a quad with 800 x 600, then you supply vertices from 0 to 800 and 0 to 600 for your quad.
09-08-2012, 07:35 AM
Mmm... I hoped you got the hint
<hint>If you setup your projection matrix correctly</hint>
If you are using gluPerspective the parameters name are explict
gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
aspect is the ratio between the height and the width of the screen
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.