View Full Version : size of screen depends on what?
04-21-2011, 01:38 AM
i m trying to know how size of window i.e. height and width
and gluOrtho effect the unit of translation in opengl
i.e size is width=500,height=500 and glOrtho(-4.0,4.0,-4.0,4.0,-30,30);
and if i write glTranslatef(-4.0,0.0,0.0);
then object will go to right end of window
but if we give width =800 and height =500
then same object will not go to at end
i m not getting the relation ..
04-21-2011, 03:15 AM
Forgot about glViewport ? Change the viewport too any times your window size changes.
04-21-2011, 04:03 AM
void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal);
That is the definition of glOrtho. It defines a parallel projection matrix using what ever values you like.
Typically you would use this to define a "2D" overlay to your main scene. If you want that then you'd typcially like to use a convienient x and y coordinate scheme. I find using the window width and height convienient as so endup with:
glOrtho (0,0, width, height, 1, 100)
which means that (0,0) is the bottom left corner of the window and (width,height) is the upper right corner.
04-24-2011, 06:45 AM
if i will do this then unit size of translation will change with it ?...
i used it but i didn't get proper solution to my problem...
will the length taken in one unit movement (in x direction here) will change with change in view port size??
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.