Ich schreibe eine DirectX-Anwendung im Fenstermodus. Nachdem Ich das Kapitel über die Device-Erstellung gelesen habe, habe ich meine Init()-Funktion bezüglich des z-Stencil-buffers wie folgt erweitert:
|
C-/C++-Quelltext
|
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
|
// Create z-buffer. Is D3DFMT_D16 available?
D3DFORMAT ZBufferFormat;
hr = m_lpD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT,
DeviceType,
Mode.Format,
D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE,
D3DFMT_D16);
if (FAILED(hr))
{
MessageBox(0,"Das DeviceFormat D3DFMT_D16 ist nicht verfügbar.",
"Fehler",MB_OK|MB_SYSTEMMODAL|MB_ICONSTOP);
return FALSE;
}
// We don't need to call CheckDeviceType() because the current window-mode
// (Mode.Format) and the current device type (DeviceType) are valid
hr = m_lpD3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT,
DeviceType,
Mode.Format,
Mode.Format,
D3DFMT_D16);
if (FAILED(hr))
{
MessageBox(0,"D3DFMT_D16 kann nicht verwendet werden.",
"Fehler",MB_OK|MB_SYSTEMMODAL|MB_ICONSTOP);
return FALSE;
}
// The previous code is ok -> We can use D3DFMT_D16
ZBufferFormat = D3DFMT_D16;
PParams.EnableAutoDepthStencil = TRUE;
PParams.AutoDepthStencilFormat = ZBufferFormat;
|
Zuvor (ich hatte nie damit Probleme):
|
C-/C++-Quelltext
|
1
2
|
PParams.EnableAutoDepthStencil = TRUE;
PParams.AutoDepthStencilFormat = D3DFMT_D16;
|
Obwohl ich momentan nur den Wert D3DFMT_D16 abfrage, ist dies jetzt schon beinahe zu viel. Wenn ich noch andere Werte abfragen will, werde ich dies wohl in eine eigene Funktion packen. Geht es auch einfacher d.h. kürzer?