Archived

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

Correct D3D coding practices?

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

Hi, I'm fairly new to Direct3D; I'm currently learning using a combination of the directX 9.0 SDK documentation tutorials, and an online book that comes with Andre Lamothe's 'Tricks of Windows Game Programming Gurus' book. These two articles take very different approaches when initialising D3D. It seems to me that the SDK tutorial examples use a very straightforward approach - they perform no device enumeration, and assumes that the user has the latest version of DirectX installed (obviously this will work because its version 9.0 SDK). For example - the SDK example's do not query for the latest interfaces, they just go ahead and use D3D9 data structures. On the other hand, the examples from the book perform much more complex initialisation, such as device enumeration/querying for the latest interfaces. My question is, which of these two approaches is 'good practice'? I think the answer is that it depends on the complexity of your d3d application, but I wanted to check. My aim is to create an application that will only use basic facilities of d3d (at first), so is enumeration etc necessary? Lastly, my only other thought was that if modern games require (and are packaged with), the latest version of D3D, it surely is unnecessary to query for interfaces of later versions? Many thanks in advance, & plz forgive any dumb questions. [edited by - cheese on February 21, 2004 7:55:02 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well if you even if you bundle Direct3D9 with your app, it would still be good practice to check if its available, so that you can ''crash'' gracefully the user doesn''t have it installed. Enumeration is necessary depending on features your app intends to use, including screen format, Z-buffer, stencil buffer.

thats just my 2 cents worth.

Share this post


Link to post
Share on other sites
I''d say it''s probably unnecessary to drop back to older versions of DirectX. If you''re using DX9 then your game will not run on Windows 95, but there''s nothing wrong with requiring that the user''s machine have the DX9 runtimes installed (and if you''re not distributing via web download, you can usually include the runtime on your installation media, installing it for them if it''s not there).

Share this post


Link to post
Share on other sites
Yea, you can include the runtimes with your app, when you distribute it (it is perfectly legal, too). If you ever notice during the course of the installation of a new game, it usually checks your DX version, and if necessary, updates it. Since this is pretty complicated (and dangerous to the system, if done incorrectly), there is a DirectSetup interface that handles the entire thing for you.

Share this post


Link to post
Share on other sites
The simple DirectX SDK samples and tutorials use no enumeration because they're trying to illustrate the basics of how to make a program with DirectX and not confuse you. If you ever look at any of the intermediate and advanced SDK samples, they have a VERY complex method of enumeration that uses about 10 different structures and classes. Any serious program should do a thourough job of enumerating and picking a proper device mode.

[edited by - Subconscious on February 22, 2004 12:54:39 PM]

Share this post


Link to post
Share on other sites