-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoClass.h
42 lines (30 loc) · 907 Bytes
/
DemoClass.h
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
#pragma once
#include <d3d9.h>
class Demo
{
protected:
bool init_done;
public:
Demo(): init_done(false) {};
virtual ~Demo() {}
virtual int do_init(LPDIRECT3D9 d3d, LPDIRECT3DDEVICE9 device)
{
device->SetRenderState(D3DRS_LIGHTING, FALSE); // turn off the 3D lighting
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
device->SetRenderState(D3DRS_ZENABLE, FALSE); // turn on the z-buffer
init_done = true;
return 0;
}
virtual int loop(LPDIRECT3D9 d3d, LPDIRECT3DDEVICE9 device)
{
if (init_done == false)
if (0 != do_init(d3d, device))
return -1;
device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
device->BeginScene(); // begins the 3D scene
// do 3D rendering on the back buffer here
device->EndScene(); // ends the 3D scene
device->Present(NULL, NULL, NULL, NULL); // displays the created frame
return 0;
}
};