Jump to content
  • Advertisement
Sign in to follow this  

Creating the virtual camera.....

This topic is 5025 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

Hey everyone, I had a quick question. I was wondering what the farClip/nearClip do with this section of code:
createCamera(1.0f, 500.0f);		// near clip plane, far clip plane
//CreateCamera(...) function
* createCamera
* creates a virtual camera
void createCamera(float nearClip, float farClip)
	//Here we specify the field of view, aspect ration and near and far clipping planes.
    D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 640/480, nearClip, farClip);
	pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);

I was just wondering how the createCamera function works. I'm reading a book Beginning DirectX 9 by Wendy Jones (in case you've read it) and the book doesn't explain 100% on how the D3DXMatrixPerspectiveFovLH(...) works. Thanks in advance.

Share this post

Link to post
Share on other sites
The near clip is the minimum distance an object must be from the camera to be visible on screen, far clip is the maximum distance. The D3DX_PI / 4 is the vertical field of view (45 degrees in that case), the 640/480 is the aspect ratio (used to determine the horizontal field of view).

Check out the DirectX 9 SDK @ "DirectX Graphics -> Programming Guide -> Getting Started -> Viewports and Clipping" for more details about the projection transform.

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!