好了好了,
现在开始进行第四章,关于颜色的一个学习,
Ok、
话不多少,老规矩,上第一个d3dUtility.h
#ifndef __d3dUtilityH__
#define __d3dUtilityH__
#include <d3dx9.h>
#include <string>
namespace d3d
{
//函数的声明:
bool InitD3D(
HINSTANCE hInstance,
int width, int height,
bool windowed,
D3DDEVTYPE deviceType,
IDirect3DDevice9** device);
int EnterMsgLoop(
bool (*ptr_display)(float timeDelta));
LRESULT CALLBACK WndProc(
HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam);
//模板函数,通过起到清除内存空间的作用
template<class T>void Release(T t)
{
if(t)
{
t->Release();
t = 0;
}
}
template<class T>void Delete(T t)
{
if(t)
{
delete t;
t = 0;
}
}
//好!现在就到了本章的重点,创建一个D3DXCOLOR,——定义相应的颜色的值
const D3DXCOLOR WHITE( D3DCOLOR_XRGB(255,255,255));
const D3DXCOLOR BLACK( D3DCOLOR_XRGB( 0, 0, 0));
const D3DXCOLOR RED( D3DCOLOR_XRGB(255, 0, 0));
const D3DXCOLOR GREEN( D3DCOLOR_XRGB( 0,255, 0));
const D3DXCOLOR BLUE( D3DCOLOR_XRGB( 0, 0, 0));
const D3DXCOLOR YELLOW( D3DCOLOR_XRGB(255, 255, 0) );
const D3DXCOLOR CYAN( D3DCOLOR_XRGB( 0, 255, 255) );
const D3DXCOLOR MAGENTA( D3DCOLOR_XRGB(255, 0, 255) );
}
#endif
接着是d3dUtility.cpp
#include "d3dUtility.h"
bool d3d::InitD3D(
HINSTANCE hInstance,
int width, int height,
bool windowed,
D3DDEVTYPE deviceType,
IDirect3DDevice9** device)
{
WNDCLASS wc;
wc