变更DirectX SDK版本-DirectX8升级DirectX9(一)

最近要做项工作,需要将游戏代码中原本的DirectX8.1SDK库升级到9.0。

    整理思路如下:

    一、命名统一问题

    D8和D9内部细节本来就有很多变化,但先从表面上来看,D8和D9的类型函数名字,都存在或多或少的

差异,为了整合以前的代码,如果将类型名字一一作改变,那代码变动量将十分的巨大。通过宏命名方式

将会节省很多时间,举例如下:

#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

     可以将其放入一个公用的文件中,如Common.h文件,然后需要用到的包含此文件。同理,D8和D9所需要的库也不通,可通过同样的方式,将其库导入。
ifdef D3DX9
#pragma comment(lib , "d3d9")
#pragma comment(lib , "d3dx9")
#endif
#ifdef D3DX8
#pragma comment(lib , "d3d8")
#pragma comment(lib , "d3dx8")
#endif

      原游戏代码虽然十分巨大,通过宏命名后,将会使代码结构变的简单,如果再想更改到别的版本将会省很多工作量。剩下的大部分工作,将是对各个函数,方法属性的细节作版本不同的细微调整。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值