npcgamer 時常出沒的會員
註冊時間: 2007-11-02 文章: 47
3.00 果凍幣
|
發表於: 2008-3-7, AM 7:58 星期五 文章主題: [範例] Direct3D - 2D 基本繪圖 |
|
|
【附件】http://blog.yam.com/npcgamer/article/14152696
代碼: | struct VERTEX
{
FLOAT x, y, z;
FLOAT r;
DWORD diffuse;
enum { FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE };
};
//
// 在位置(10,20)畫出 100 x 20 大小的長方形
//
FLOAT X = 10;
FLOAT Y = 20;
FLOAT Z = 0;
DWORD Width = 100;
DWORD Height = 20;
DWORD C = D3DXCOLOR(0,255,0,255);
FLOAT rhw = 1;
VERTEX vertex [4] =
{
{X , Y, Z, rhw, C},
{X+Width, Y, Z, rhw, C},
{X+Width, Y+Height, Z, rhw, C},
{X , Y+Height, Z, rhw, C},
};
// 設定 Shader
pDevice->SetVertexShader(NULL);
pDevice->SetPixelShader(NULL);
// 設定 Render State
pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
// 設定頂點格式
pDevice->SetFVF(VERTEX::FVF);
// 描繪
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, vertex, sizeof(VERTEX)); |
|
|