1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#define FVF D3DFVF_XYZ/*RHW*/|D3DFVF_DIFFUSE
struct SVertex
{
float x,y,z/*,fRHW*/;
DWORD dwColor;
};
SVertex Vertices[] =
{
/* { 100.0f, 100.0f, .0f, 1.0f, color( .0f, 1.0f, 1.0f) },
{ 500.0f, 100.0f, .0f, 1.0f, color(1.0f, 1.0f, 1.0f) },
{ 100.0f, 500.0f, .0f, 1.0f, color(1.0f, .0f, .0f) }*/
{ .0f, 1.0f, .0f, color( .0f, 1.0f, 1.0f) },
{ 1.0f,-1.0f, .0f, color(1.0f, 1.0f, 1.0f) },
{ -1.0f,-1.0f, .0f, color(1.0f, .0f, .0f) }
};
void Render(float fTime)
{
Direct3D.SetRenderState(D3DRS_LIGHTING, FALSE);
Direct3D.SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
Direct3D.Clear(0, 0, D3DCLEAR_TARGET|D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER, color(.0f, .0f, 1.0f), 1.0f, 0);
Direct3D.BeginScene();
Direct3D.SetTransform(D3DTS_VIEW, MatrixCamera(vector3(.0f,-5.0f,.0f), vector3(.0f,.0f,.0f), vector3(.0f,1.0f,.0f)));
Direct3D.SetTransform(D3DTS_PROJECTION, MatrixProjection(PI/2, .75f, .5f, 1000.0f));
Direct3D.SetTransform(D3DTS_WORLD, MatrixIdentity());
VB.SetVertexBuffer();
/*
IDirect3D::GetSingleton()->SetFVF(m_dwFVF);
IDirect3D::GetSingleton()->GetD3DDevice()->SetStreamSource(0,
m_pVertexBuffer,
0,
m_iVertexSize);
*/
IB.SetIndexBuffer();
/*
IDirect3D::GetSingleton()->GetD3DDevice()->SetIndices(m_pIndexBuffer);
*/
Direct3D.GetD3DDevice()->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 3, 0, 1);
Font.Begin();
char c[1024];
sprintf(c, "Framerate: %.2f fps", 1.0f/fTime);
Font.DrawText(c, color(1.0f, 1.0f, 1.0f), vector2(10.0f, 10.0f));
Font.End();
Direct3D.EndScene();
Direct3D.Present(NULL, NULL, NULL, NULL);
}
|