Change the DirectX SDK version-directx8 to directx9 (1)

Source: Internet
Author: User
Recently, we have to work on Code The original directx8.1sdk library in is upgraded to 9.0.

   The logic is as follows:

   I. Unified naming

   The internal details of D8 and D9 have changed a lot, but on the surface, the type function names of D8 and D9 have more or less

Difference, in order to integrate the previous Code, if the type name is changed one by one, the amount of code changes will be very huge. Macro naming

This will save a lot of time, for example:

# Ifdef d3dx9
# Include <d3dx9. h>
Typedef idirect3ddevice9 device;
Typedef idirect3d9 direct3d;
Typedef idirect3dvertexbuffer9 vertexbuffer;
Typedef idirect3dindexbuffer9 indexbuffer;
Typedef idirect3dtexture9 texture;
Typedef d3dmaterial9 material;
Typedef idirect3dsurface9 surface;
Typedef void yvoid;
# Define direct3dcreate direct3dcreate9
# Endif

# Ifdef d3dx8
# Include <d3dx8. h>
Typedef byte yvoid;
Typedef idirect3ddevice8 device;
Typedef idirect3d8 direct3d;
Typedef idirect3dvertexbuffer8 vertexbuffer;
Typedef idirect3dindexbuffer8 indexbuffer;
Typedef idirect3dtexture8 texture;
Typedef d3dmaterial8 material;
Typedef idirect3dsurface8 surface;
# Define direct3dcreate direct3dcreate8
# Endif

    You can put it into a public file, such as a common. h file, and then use the file to include it. Similarly, the databases required by D8 and D9 cannot be connected. You can import the databases in the same way.
Ifdef d3dx9
# Pragma comment (Lib, "d3d9 ")
# Pragma comment (Lib, "d3dx9 ")
# Endif
# Ifdef d3dx8
# Pragma comment (Lib, "d3d8 ")
# Pragma comment (Lib, "d3dx8 ")
# Endif

     Although the original game code is huge, macro naming will make the code structure simple. If you want to change it to another version, it will save a lot of work. Most of the remaining work will be to slightly adjust the details of each function and method attribute in different versions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.