Hallo,
ich hab schonmal ein kleines Spielchen mit der Tribase Engine gemacht und wollte jetzt mal probieren, ob es auch ohne Engine klappt. Jetzt gibt das Programm aber beim Erstellen eines Devices für Direct3D "Invalid Call" aus. Ich hab absolut keine Ahnung, was ich Falsch mache.
Hier der Code für die Initialisierung:
|
Quellcode
|
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
|
#include "Main.h"
extern PDIRECT3D9 D3D;
extern PDIRECT3DDEVICE9 D3DDevice;
int InitDirect3D(HWND hWindow)
{
D3DPRESENT_PARAMETERS PresentParams;
HRESULT Result;
D3D = Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(&PresentParams, sizeof(D3DPRESENT_PARAMETERS));
PresentParams.BackBufferWidth = 640;
PresentParams.BackBufferHeight = 480;
PresentParams.BackBufferFormat = D3DFMT_R5G6B5;
PresentParams.BackBufferCount = 1;
PresentParams.MultiSampleType = D3DMULTISAMPLE_NONE;
PresentParams.MultiSampleQuality = 0;
PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
PresentParams.hDeviceWindow = hWindow;
PresentParams.Windowed = FALSE;
PresentParams.EnableAutoDepthStencil = TRUE;
PresentParams.AutoDepthStencilFormat = D3DFMT_D16;
PresentParams.Flags = 0;
PresentParams.FullScreen_RefreshRateInHz = 0;
PresentParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
if(FAILED(Result = D3D->CreateDevice(0, D3DDEVTYPE_HAL,
hWindow, 0,
&PresentParams, &D3DDevice)))
{
ExitDirect3D();
MessageBox(NULL, DXGetErrorDescription9(Result), "Fehler", MB_OK);
return 1;
}
ShowCursor(FALSE);
return 0;
}
int ExitDirect3D()
{
SAFE_RELEASE(D3D);
SAFE_RELEASE(D3DDevice);
return 0;
}
|
Hier der Aufruf:
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "Main.h"
PDIRECT3D9 D3D;
PDIRECT3DDEVICE9 D3DDevice;
HWND MyWindow;
char MyWindowName[] = "Mein Fenster";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
char* CmdLine, int ShowCmd)
{
MyWindow = InitWindow(MyWindowName, 640, 480);
ShowWindow(MyWindow, ShowCmd);
InitDirect3D(MyWindow);
DoMessageLoop();
ExitDirect3D();
ExitWindow(MyWindowName);
return 0;
}
|
Für Hilfe wäre ich sehr Dankbar.