Jump to content
  • Advertisement

Archived

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

DXplayah

D3DX or not

This topic is 5856 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 just started trying to learn DX again, now DX 8. My problem is I can''t decide wether or not to use D3DX. I''m sort of the "reinvent the wheel" type of guy. I''ve allready written X/Y/Z rotation matrix routines based of D3DMATRIX (not D3DXMATRIX) but all samples and tutorials I find and so forth use D3DXMATRIX and the equivalent D3DXMatrixRotateY or what the function is. The reason I''m starting to think about using D3DX is that now I have to write functions to set view/projection matrices etc that means I have to write the matrix functions + vector functions (normalizing etc). So my question is. What positive effects does having ie a D3DMATRIX *ml_MatrixRotateX own made function have over just slamming inn a D3DX version of it and also a full mathlib. A positive effect I can think of is that I will get better at 3d maths in general because I will be writing the code myself and understanding it better. And could someone please point me to tutorials/source/examples of setting up the world/projection/view etc matrices WITHOUT D3DX? Cause I don''t want to use ie the LookAtLh D3DX func etc. Thanks in advance =)

Share this post


Link to post
Share on other sites
Advertisement
As a learning excersise, it is well worth writing your own math routines, especially more complex things like intersection tests etc (which are covered to a lesser extent by the d3dx math libs anyway). As for setting up the projection and view matrics, theres loads of info in the SDK about that, so that should be your first port of call.

Once you''re up to speed with your maths, then I can whole heartedly recommend using d3dx. Version 8.1 has been optimised greatly to benefit from any cool instructions your CPU might support, and is pretty damn fast.

As an example, I tried optimising a matrix invert routine myself, even to the point of using a little SSE assembly, and researched it quite a lot. In a comparison with the d3dx matrix invert func, mine was a tad slower, AND a tad less accurate. (The test I did multiplied a matrix with its inverse, so I could see how far it deviated from the identity.) I''ll be the first to admit, im pretty bad at low level optimisation like that, and I started with only a tiny bit of x86 asm knowledge. Even so, I think, unless you are very talented at such coding, you''d be foolish not to consider using the d3dx math functions.

T

Share this post


Link to post
Share on other sites
Ok thanks =) Then I guess I''ll use the damn D3DX lib

That just speeded up my coding progress a great deal

Share this post


Link to post
Share on other sites
The d3dx8.l libraries are faster eh? I guess I am going to have to reverse-engineer them to work with dx7

If the types and function symbols are the same, then I could just swap the OBJ files in the LIB. I may have to h4x0r the cpu detection function though, it probably looks at an external variable

Writing your own functions is ok to learn, but the d3dx functions make it so much faster to get started

Share this post


Link to post
Share on other sites
Don't rely on D3DX with your life. If for some fluke, Microsoft decided to remove it in the next version, a lot of people would be screwed over because they depend on it too much. I completely agree that you should use it because D3DX is fast and optomised like heck. What I do is code out anything that D3DX supports before using it so that if it were to be removed, I could use my slower but working code. That's what I would recommend but you may go the way of just using it's functionality. It just depends on whether you really have the time and to want to have the abilities and credit for creating the code yourself.

Edit: As for tutorials on using matrices and transforms yourself, the SDK has code samples of creating projection matrices by hand and such. Also, www.drunkenhyena.com has tutorials on using matrices without D3DX.

[edited by - RapidStunna on June 6, 2002 4:30:34 PM]

Share this post


Link to post
Share on other sites
I haven''t found anything in SDK but I probably haven''t looked good enough

I have written rotation, translation and scaling functions myself. I know how to do those. Also know how to do basic 3d math from school such as dot and cross product, plane intersection, vector scaling, products and so forth. I guess I''ll use D3DX now and if for some reason they are removed later I will finnish writing my mathlib.

Share this post


Link to post
Share on other sites
I remember reading that the D3DX8.1 functions are a lot more optimized than those in D3DX8.0.

Can anyone confirm or discredit this? 8.1 may have just added optimizations for 3DNow. I cannot remember anymore.

--TheMuuj



[edited by - themuuj on June 6, 2002 5:09:51 PM]

Share this post


Link to post
Share on other sites
Ok I finished hacking it! all I did was copy the OBJ files related to the math functions out of the DX8.1 LIB file into a custom one. Of cource I poked around the dissasembler a bit to see what I was up against

It is very optimized, it uses a jump table that points to different functions optimized for 3dnow, sse, sse2 and plain x86. The function interface and structures are IDENTICAL so it works perfect in dx7. The only problem is the projection matrix function broke, so now the aspect ratio is wrong!

Too bad the math library alone is 200kb. The dx8.1 library is 4 times larger than the dx7 one! They even have the ZLIB and PNG libraries included!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!