Sign in to follow this  

Problem with perspective projection(solved)

Recommended Posts

Hi folks, I've got a problem with my projection I think. I actually started writing a plattform independent 3D engine. OpenGL and DirectX 9 and 10. I ran into a problem when trying to render objects with DirectX. For the projection matrix I am using the following code:
D3DXMatrixPerspectiveFovLH( &ProjectionMatrix, D3DX_PI/4, 1.0f, 0.2f, 100.0f );
D3DXMatrixTranspose (&m_matWorldViewProjection, &ProjectionMatrix);

This matrix is then multiplied with the positions inside the vertex shader. When I am rendering the following triangle:
CVertex4(   250.0f,  50.0f, 0.05f, 1.0f),
CVertex4(   250.0f, 250.0f, 0.05f, 1.0f),
CVertex4(    50.0f, 250.0f, 0.05f, 1.0f)

I have two problems: A) The triangle is shown in the top left corner of my window. Assuming that the origin of my coordinate system should be in the center the triangle should be displayed at the top right corner. B) As soon as I pick z-values bigger than 1.0f the triangle is no longer rendered. Please excuse my noob question but I hope someone can drag me into the right direction of what I am missing when rendering objects in DirectX. Thanks a lot in advance Jan Problem has been solved ======================= I accidentally passed XYZRHW vertices! Should've been XYZ only. [Edited by - EXGE on April 9, 2007 12:54:13 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this