Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Frustum Help in OpenGL
Index -> Graphics and Design, Graphics -> 3D Graphics
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
102jon




PostPosted: Tue Jan 11, 2011 12:02 pm   Post subject: Frustum Help in OpenGL

I created a frustum in openGL with the arguments glFrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 100.0). The last two arguments represent distances to near and far clipping planes respectively. My question is, how do I place an object at a given set of z-coordinates? x and y are easy enough to do as I can place the object anywhere in the range of -1.0 to 1.0, but I'm not exactly sure how the z-coordinates work.
Sponsor
Sponsor
Sponsor
sponsor
TerranceN




PostPosted: Tue Jan 11, 2011 4:21 pm   Post subject: Re: Frustum Help in OpenGL

What the near and far clipping planes mean is that openGL will only draw thing that have a distance from the camera d, in the range nearDistance < d < farDistance. Since the camera is at the origin, and facing down the -z axis, something with a negative z value in between -2.0 and -100.0 can be drawn to the screen.

Also, messing around with glFrustum, I noticed it will skew the image unless the values you give it for left/right and top/bottom are in the same ratio as the window width and window height. A better function to use is gluPerspective, as it takes this ratio into account. A typical call to gluPerspective would look like this:
c++:

gluPerspective(45.0f, (float)width / height, 0.1f, 100.0f);


Also, you should check out NeonHelium, as they hve some really good openGL tutorials.
Display posts from previous:   
   Index -> Graphics and Design, Graphics -> 3D Graphics
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: