Archived

This topic is now archived and is closed to further replies.

D3DXMatrixPerspectiveFovLH Question

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

I''m writing a Direct3D wrapper and I am trying to avoid the use of the extra libraries, such as D3DX. My question is: How do you calculate the perspective matrix using the information that is passed to D3DXMatrixPerspectiveFovLH? I want to replace the call to this function with a self-made function that doesn''t use the D3DX library. Thanks in advance.

Share this post


Link to post
Share on other sites
Why don''t you want to use D3DX? This sort of thing always confuses me...

In most cases, D3DX is highly optimized and all the actual code is stored in d3dx8.dll, so consider the following scenario:

You implement your own version of D3DXWhatever. In order to match the performance of D3DX, you add optimizations for different CPU instruction sets and architecture. You also make sure that the overall function itself is highly optimized. Then you compile all this into the library. You do this for several D3DXWhatevers.

In the end, you''ve spent alot more time, written alot more code, and *maybe* you''ve matched the performance and functionality of D3DX. All the while, the d3dx8.dll is sitting happily on the harddrive waiting to be used.

So, why are you rewriting D3DX?

Share this post


Link to post
Share on other sites
Ahhh.... I just read your OpenGL equivalent question, so I think I understand. With OpenGL, you can''t necessarily assume that the user has the glu DLLs installed, with D3DX you can assume that if DX8 is installed then D3DX is installed.

In either case you''re better off using the helpers, just wrap them up:

void MyOwnMatrixFunction(stuff)
{
if (I''m using an OpenGL driver)
gluWhatever(stuff);
else
D3DXWhatever(stuff);
}

To see one example of this, look at the code for the Unreal Tournament drivers. Source code used to be available and probably still is somewhere on Sourceforge.

Share this post


Link to post
Share on other sites
I did forget the fact that D3DX is part of the Direct3D8 distribution, so it would be okay to just use it. =) But it does leave the replacement for gluPerspective in question. I''m looking over the Unreal OpenGL driver code right now, thanks for the suggestion.

Share this post


Link to post
Share on other sites
The documentation of the fixed function rendering pipline in the DX SDK contains information of how a projection matrix should look like. With some additional trigonometric knowlege you should be able to code the appropriate function.

Share this post


Link to post
Share on other sites