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
|
#include <d3dx9.h>
#include <dxerr9.h>
#include <d3d9.h>
#include <Windows.h>
#include <DSound.h>
#include <DInput.h>
PDIRECT3D9 g_pD3D;
PDIRECT3DDEVICE9 g_pD3DDevice;
void ExitD3D()
{
g_pD3D->Release();
g_pD3DDevice->Release();
}
void InitD3D (HWND hWnd)
{
D3DPRESENT_PARAMETERS P_Parms;
HRESULT hResult;
g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(&P_Parms, sizeof(D3DPRESENT_PARAMETERS));
P_Parms.BackBufferWidth =1024;
P_Parms.BackBufferHeight =768;
P_Parms.BackBufferFormat =D3DFMT_A8R8G8B8;
P_Parms.BackBufferCount =1;
P_Parms.MultiSampleType =D3DMULTISAMPLE_NONE,
P_Parms.MultiSampleQuality =0;
P_Parms.SwapEffect =D3DSWAPEFFECT_COPY;
P_Parms.hDeviceWindow =hWnd;
P_Parms.Windowed =TRUE;
P_Parms.EnableAutoDepthStencil =TRUE;
P_Parms.AutoDepthStencilFormat =D3DFMT_D24S8;
P_Parms.Flags =0;
P_Parms.FullScreen_RefreshRateInHz =120;
P_Parms.PresentationInterval =D3DPRESENT_INTERVAL_DEFAULT;
hResult = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&P_Parms,
&g_pD3DDevice);
if(FAILED(hResult))
{
MessageBox(NULL, TEXT("Fehler beim generieren der Schnittstelle"), TEXT("Fehler"), 0);
ExitD3D();
}
else
{
MessageBox(NULL, TEXT("Erfolgreice Erstellung der Schnittstelle"), TEXT("Erfolg"),0);
}
}
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("") ;
HWND hWnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
hWnd = CreateWindow (szAppName, // Name der Fensterklasse
TEXT (""), // Fenstertitel
WS_OVERLAPPEDWINDOW, // Fensterstil
CW_USEDEFAULT, // X-Position des Fensters
CW_USEDEFAULT, // Y-Position des Fensters
CW_USEDEFAULT, // Fensterbreite
CW_USEDEFAULT, // Fensterhöhe
NULL, // übergeordnetes Fenster
NULL, // Menü
hInstance, // Programm-Kopiezähler (Programm-ID)
NULL) ; // zusätzliche Parameter
ShowWindow (hWnd, iCmdShow) ;
UpdateWindow (hWnd) ;
InitD3D(hWnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint (hWnd, &ps);
EndPaint (hWnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
ExitD3D();
return 0 ;
}
return DefWindowProc (hWnd, message, wParam, lParam) ;
}
|