forked from neuks/libafx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
afx.h
144 lines (120 loc) · 3.63 KB
/
afx.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//*****************************************************************************
// Win32 Framework - Main
//
// Copyright (C) 2010, Martin Tang
//*****************************************************************************
#ifndef __CAFX_H__
#define __CAFX_H__
#include <d3d9.h>
#include <d3dx9.h>
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
struct CApp
{
CApp();
~CApp();
virtual int OnInit();
virtual int OnExit();
virtual int OnExec();
};
struct CWnd
{
HWND m_hWnd;
CWnd();
~CWnd();
virtual int MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
};
LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#define INFORM(cond) if (cond) \
{ \
printf("%s:%d:INFORM:%s\n", __FILE__, __LINE__, #cond); \
}
#define ASSERT(cond) if (cond) \
{ \
printf("%s:%d:ASSERT:%s\n", __FILE__, __LINE__, #cond); \
exit(-1); \
}
#define DECLARE_APP(appClass) \
extern appClass theApp;
#define IMPLEMENT_APP(appClass) \
appClass theApp; \
int main() { return theApp.OnExec(); }
HWND LoadToolbar(HINSTANCE hInstance, DWORD dwStyle, WORD wID, HWND hParent);
//=============================================================================
// CDXWnd Declaration
//=============================================================================
struct CDXCamera
{
D3DXVECTOR3 vPosition, vLookAt, vUpside;
double fFOV;
};
struct CDXLight : D3DLIGHT9
{
BOOL bState;
DWORD nIndex;
};
struct CDXObject
{
// Render Object Geometric Properties
D3DXVECTOR3 vPosition, vPVelocity, vPAcceleration;
D3DXVECTOR3 vRotation, vRVelocity, vRAcceleration;
DWORD nItems; // Item counter
LPD3DXMESH pMesh; // Mesh container
D3DMATERIAL9 *pMaterial; // Material container
LPD3DXEFFECT *pEffect; // Effect container
LPDIRECT3DTEXTURE9 *pTexture; // Texture container
};
struct CDXAnimate
{
LPD3DXFRAME pFrame;
LPD3DXANIMATIONCONTROLLER pController;
};
struct D3DXFRAME_DERIVED : public D3DXFRAME
{
D3DXMATRIXA16 CombinedTransformationMatrix;
};
struct D3DXMESHCONTAINER_DERIVED : public D3DXMESHCONTAINER
{
LPDIRECT3DTEXTURE9 *ppTextures;
LPD3DXEFFECT *ppEffects;
};
struct CAllocateHierarchy : ID3DXAllocateHierarchy
{
STDMETHOD(CreateFrame)(LPCSTR Name, LPD3DXFRAME *ppNewFrame);
STDMETHOD(CreateMeshContainer)(
LPCSTR Name,
CONST D3DXMESHDATA *pMeshData,
CONST D3DXMATERIAL *pMaterials,
CONST D3DXEFFECTINSTANCE *pEffectInstances,
DWORD NumMaterials,
CONST DWORD *pAdjacency,
LPD3DXSKININFO pSkinInfo,
LPD3DXMESHCONTAINER *ppNewMeshContainer
);
STDMETHOD(DestroyFrame)(LPD3DXFRAME pFrameToFree);
STDMETHOD(DestroyMeshContainer)(LPD3DXMESHCONTAINER pMeshContainer);
};
struct CDXWnd : CWnd
{
// Member Attributes
IDirect3DDevice9 *m_pDevice;
// Interface Functions
CDXWnd();
~CDXWnd();
// Operator Functions
void SetCamera(CDXCamera *pCamera);
void SetLight(CDXLight *pLight);
void DrawFrame(LPD3DXFRAME pFrame, double Time, double Delta);
void UpdateFrame(LPD3DXFRAME pFrame, LPD3DXMATRIX pParentMatrix);
void LoadAnimation(CDXAnimate *pAnimation, LPSTR pFileName);
void DrawAnimation(CDXAnimate *pAnimation, double Time, double Delta);
// Callback Functions
virtual void OnSetup(D3DPRESENT_PARAMETERS *d3dpp);
virtual void OnCreate();
virtual void OnRender(double Time, double Delta);
virtual void OnDestroy();
// Message Handler
int MsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
};
#endif // __CAFX_H__