【DirectX 2D游戏开发基础】DirectX的应用实例

       这次,主要就是利用前面几篇博客里面的例子,来做几个应用练习,主要就是,让图片闪烁,一次读取多张图片,和使用随机数随机读取图片(当然,这里的随机数用的是C语言,而不是C++的随机数引擎,但是原理是一样的),这次,我把我的代码工程上传上来,希望大家下载学习,毕竟 里面会涉及到一些资源问题,把代码复制去了,改起来挺麻烦也。地址:http://download.csdn.net/detail/shangdi712/7704977

     

//Utility.h

#ifndef WINDOWS_USEFUL_TOOLS_
#define WINDOWS_USEFUL_TOOLS_
#include <Windows.h>
#include <MMSystem.h>
#pragma comment(lib,"Winmm.lib")
#include <wchar.h>
#include <time.h>
#endif

#ifndef D3D_USEFUL_TOOLS_
#define D3D_USEFUL_TOOLS_
#include <d3d9.h>
#pragma comment(lib,"d3d9.lib")
#include <d3dx9.h>
#pragma comment(lib,"d3dx9.lib")
#endif

#ifndef SAFE_CLEANUP_
#define SAFE_CLEANUP_

//内联函数模板,参数为 T* 类型的引用
template<typename T>inline void Safe_Delete( T* & p )
{
	if(p){ delete p ; p = NULL;}
}

template<typename T>inline void Safe_Release( T* & p )
{
	if(p){ p->Release() ; p = NULL;}
}

#endif


#ifndef STL_TOOLS_
#define STL_TOOLS_
#include <vector>
#include <string>
using namespace std;
#endif

#ifdef UNICODE
#define string wstring
#define sprintf_s swprintf_s
#else
#define string string
#define sprintf_s sprintf_s
#endif


//WinMain.cpp

#include "Utility.h"

HWND g_hWnd = 0;
int g_iWidth = 800;
int g_iHeight = 600;
HINSTANCE g_hInstance = 0;

LRESULT CALLBACK WndProc(HWND hWnd ,UINT uMsg,
						 WPARAM wParam,LPARAM lParam);

LPDIRECT3D9 g_pD3D = nullptr;
LPDIRECT3DDEVICE9 g_pDevice = nullptr;

LPD3DXSPRITE g_pSprite = nullptr;	//精灵指针
D3DXMATRIX g_matIdentity;	//用于恢复渲染状态的单位矩阵


LPDIRECT3DTEXTURE9 g_pRole = n
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值