Creating Projection Matrix Using D3DXMatrixOrthoLH()???

Started by
1 comment, last by Spartacus 22 years, 8 months ago
Hi! Can someone tell me why nothing appears on the screen when I use D3DXMatrixOrthoLH() to create the projection matrix. I have followed the article "2D Rendering In DirectX 8" and it tells me that I should create the projection matrix using D3DXMatrixOrthoLH() but when I use it my textured quad changes into a blue dot (1x1 pixel) in the middle of the screen. But if I use D3DXMatrixPerspectiveFovLH() to create the projection matrix instead, everything works fine. But I don''t want to use D3DXMatrixPerspectiveFovLH() because in 2D I dont want a perspective. -Thanks René

Real programmers don't document, if it was hard to write it should be hard to understand

Advertisement
You should stick this post in the directx forum, but anyways-

I had some similiar woes with ortho stuff in directx. I''m assuming your passing the heigh and width of your screen to the function and passing probably -1,1 for the z part. This makes the point 0,0 in the center of your screen, so for example the bottom left would be -width/2, -height/2.

but the reason the quad changes into a 1x1 is not clear: explain more on how your passing the coordinates of the texture. and make sure your not rotating it.
-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
I know the exact problem you are having. The x and y size of D3DXMatrixOrthoLH is defined in world space , not screen space.

So if it''s declared as 640x480, you have a gigantic viewing frustum, making almost anything appear microscopic.

Instead, make your frustum 30x20. This should fix your problem, and keep the correst aspect ratio.

-----------------
The Goblin (madgob@aol.com)
-----------------
"Before critisizing somebody, walk a mile in their shoes. That way, when you do critisize them, not only will you be a mile away, but you''ll also have their shoes!"
- The Goblin (madgob@aol.com)

This topic is closed to new replies.

Advertisement