Jump to content
  • Advertisement
Sign in to follow this  
tinu

OpenGL openGL Basics..

This topic is 3706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a basic doubt in rendering in OpenGL. I draw a point using the following code: glBegin(GL_POINTS); glColor3f(1, 1, 1); glVertex2f(1,0); glEnd(); I have the following code in the Display callback gluLookAt(0, 0, translateZ, 0, 0, 0, 0, 1, 0); I have the following code in reshape callback gluPerspective(45, (GLdouble)width/(GLdouble)height, 1, 100); For translateZ : 2 --> position of point on the screen from screen centre : 15 cms translateZ : 4 --> position of point on the screen from screen centre : 7.5 cms translateZ : 6 --> position of point on the screen from screen centre : 5 cms translateZ : 8 --> position of point on the screen from screen centre : 3.75 cms translateZ : 10 --> position of point on the screen from screen centre : 3 cms i get these values in the full screen mode.. screen resolution : 1024X768 How are the translateZ (camera Z position) & the position of the point on the screen related? Looking forward for your reply... [Edited by - tinu on May 28, 2008 8:17:50 AM]

Share this post


Link to post
Share on other sites
Advertisement
It's the perspective projection that links them. The farther away you (the camera) are from a point the closer it will be to the screen's center. (This doesn't apply to the points that always are projected to the screen center (like if your point was 0/0 and the camera location not changed - except for z) ;) ).

Just google "perspective projection" to find more thorough explanations as well as some images. ;)

Edit: BTW, if you used glOrtho instead of gluPerspective, you wouldn't get that effect since the frustum is a cube rather than a capped pyramid.

Share this post


Link to post
Share on other sites
okay I will search on perspective projection...

But can u elaborate on this more...

Because when I change the resolution of my screen to 1280*720

the position of the point changes again...
For
translateZ : 2 --> position of point on the screen from screen centre : 11 cms


Is this connected to resolution...

Very much confused...

[Edited by - tinu on May 28, 2008 8:33:07 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!