PDA

View Full Version : Find Coordinates



11-04-2003, 03:51 AM
Hi,
I would like to display an horizontal line in the middle of a window of size (cx, cy) with OpenGL. I wish that my line be to entirely post and that it is largest possible. How to know the coordinates of the tops of my rectangle so that this one is posted correctly???
For the moment, I do that:
glViewport(0, 0, cx, cy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (float)cx/(float) cy, 0, 1000);
gluLookAt(0,0,-10,0,0,0,0,1,0);
glBegin(GL_LINES);
glVertex3f(X1,Y1,Z1);
glVertex3f(X2,Y2,Z2);
glEnd

I want find the values of X1, Y1, Z1, X2, Y2, Z2...


Do somebody know how to solve my problem??

Solen

gunslinger
11-04-2003, 04:44 AM
hi solen,
just to check if i understood clearly what u are asking: what u want to know is how large your frustum of view is at z=0? In other words you want that your line is exactly large as the screen is, right?
Bye the Gunslinger

11-04-2003, 04:59 AM
Yes that's it!

11-04-2003, 06:45 AM
Furthermore, I know that Z1=Z2=constant!
Do you know a solution to my problem?

gunslinger
11-10-2003, 12:06 AM
hi mimi, sorry for the delay in the answer, i hope it isn't too late.
Even if i am not able to give you the right expressions to solve your problems, i can give u a hint that may help you. On the site www.gametutorials.com (http://www.gametutorials.com) there are a couple of tutorials using the frustum culling tecnique. In those tutorials u may find the expressions of the screen frustum plane equations. Once u have em, well u just have to find where your line "hits" the frustum and voila, problem solved. Hope it will help...
bye The Gunslinger