Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

24.05.2008, 03:15

Bildpuffer- und Z-Stencil-Buffer-Format

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?

2

24.05.2008, 13:19

Re: Bildpuffer- und Z-Stencil-Buffer-Format

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
    // Create z-buffer. Is D3DFMT_D16 available?

    D3DFORMAT ZBufferFormat;
    if (FAILED(m_lpD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT,
                                    DeviceType,
                                    Mode.Format,
                                    D3DUSAGE_DEPTHSTENCIL,
                                    D3DRTYPE_SURFACE,
                                    D3DFMT_D16))
||
FAILED(m_lpD3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT,
                                        DeviceType,
                                        Mode.Format,
                                        Mode.Format,
                                        D3DFMT_D16)))

    {   
        MessageBox(0,"Fehler",
        "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;


Wenn du das so toller findest, kürzer wärs jedenfalls.
Lieber dumm fragen, als dumm bleiben!

3

24.05.2008, 17:43

Danke für die Antwort!

Das Format D3DFMT_D16 scheint sehr verbreitet zu sein, da ich damit nie Probleme hatte. Es als gegeben vorauszusetzen wäre aber vermutlich falsch.

Ich dachte mir schon, dass ich um den Aufruf von CheckDeviceFormat() und CheckDepthStencilMatch() nicht herumkomme.

Werbeanzeige