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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "Scene.hpp"
Vertex Triangle [3];
void InitScene (PDIRECT3DDEVICE9 D3DD, const TempParams& Temp)
{
D3DD->SetFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE);
D3DD->SetRenderState (D3DRS_LIGHTING, false);
D3DD->SetRenderState (D3DRS_CULLMODE, D3DCULL_NONE);
D3DD->SetRenderState (D3DRS_DITHERENABLE, true);
float Aspect = static_cast<float> (Temp.VideoModeWidth)
/static_cast<float> (Temp.VideoModeHeight);
tbMatrixProjection (TB_DEG_TO_RAD (90.0f), Aspect, 0.1f, 100.0f);
Triangle[0].Position = tbVector3 (0.0f, 1.0f, 0.0f);
Triangle[1].Position = tbVector3 (1.0f, -1.0f, 0.0f);
Triangle[2].Position = tbVector3 (-1.0f, -1.0f, 0.0f);
Triangle[0].Color = tbColor (1.0f, 0.0f, 0.0f);
Triangle[1].Color = tbColor (0.0f, 1.0f, 0.0f);
Triangle[2].Color = tbColor (0.0f, 0.0f, 1.0f);
}
void Render (PDIRECT3DDEVICE9 D3DD, float Time)
{
tbMatrix Rotation (tbMatrixRotationY (TB_DEG_TO_RAD (90.0f * Time) ) );
tbMatrix Translation (tbMatrixTranslation (tbVector3 (0.0f, 0.0f, 2.0f) ) );
tbMatrix World (Rotation * Translation);
D3DD->SetTransform (D3DTS_WORLD, (D3DMATRIX*)(&World) );
D3DD->Clear (0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,
D3DCOLOR_XRGB (25, 0, 70), 1.0f, 0);
D3DD->BeginScene ();
D3DD->DrawPrimitiveUP (D3DPT_TRIANGLELIST, 1, Triangle, sizeof (Vertex) );
D3DD->EndScene ();
D3DD->Present (0, 0, 0, 0);
}
void MessageLoop (PDIRECT3DDEVICE9 D3DD)
{
MSG Message;
bool Active = true;
ZeroMemory (&Message, sizeof(MSG) );
while (Active == true)
{
while(PeekMessage (&Message, NULL, 0, 0, PM_REMOVE) )
{
TranslateMessage(&Message);
DispatchMessage(&Message);
if(Message.message == WM_QUIT)
{
Active = false;
}
}
Render (D3DD, 0.0f);
}
}
|