Die Enumeration der Pixelformate klappt irgendwie net, er erkennt nur manche
-
Hallo,
ich habe ein Problem mit der Grafikkartenenumeration. Und zwar geht es im speziellen um die Pixelformate für Texture, Z, und Stencilbuffer. Die Devicetypen und Adapter werden korrekt erkannt, das Pixelformat zum Rendern (also Front- und Backbuffer auch) aber eben die besagten nicht. Stencilbufferformate findet er erst gar nicht, Texturebuffer nur 2, obwohl der D3DCAPS eine ganze Reihe findet.
Bitte seit mir nicht böse für den langen Code, aber ich werde ihn hier mal posten, damit ihr mir sagen könnt, was falsch ist. Ich mag es zwar selber nicht, wenn langer Source gepostet wird, aber in dem Fall halte ich es für vernünftig.
void MACD3DEnum::GetAdapterFormat (bool is_windowed, HWND combo, HWND devchoise) { *m_log << "Methode \"MACD3DEnum::GetAdapterFormat (void)\" aufgerufen" << endl; SendMessage (combo, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); *m_log << "Combobox für die Adaptermodes geleert" << endl; //Iterator auf den device vector std::vector<MACDEVICE*>::const_iterator device; *m_log << "Iterator auf DEVICE erstellt" << endl; D3DFORMAT tmp [] = { {D3DFMT_R8G8B8}, {D3DFMT_A8R8G8B8}, {D3DFMT_X8R8G8B8}, {D3DFMT_R5G6B5}, {D3DFMT_X1R5G5B5}, {D3DFMT_A1R5G5B5}, {D3DFMT_A4R4G4B4}, {D3DFMT_A8R3G3B2}, {D3DFMT_X4R4G4B4}, {D3DFMT_A2B10G10R10}, {D3DFMT_A8B8G8R8}, {D3DFMT_X8B8G8R8}, {D3DFMT_G16R16}, {D3DFMT_A2R10G10B10}, {D3DFMT_A16B16G16R16}, {D3DFMT_D16_LOCKABLE}, {D3DFMT_D32}, {D3DFMT_D15S1}, {D3DFMT_D24S8}, {D3DFMT_D24X8}, {D3DFMT_D24X4S4}, {D3DFMT_D32F_LOCKABLE}, {D3DFMT_D24FS8}, {D3DFMT_D16}, {D3DFMT_D24X8} }; MACDEVICECOMBINATION* combi = NULL; combi = new MACDEVICECOMBINATION [3 * m_int_adapter_count * sizeof(tmp)/sizeof (tmp[0])]; if (!combi) *m_log << "Fehler beim reservieren von speicher (Kombination)" << endl; else *m_log << "combi ok. " << endl; int nFormat = 0; *m_log << "Counter auf 0 gesetzt" << endl; /* für jeden Adapter */ for (int preloop=0; preloop<m_int_adapter_count; preloop++) { /*für jeden devicetyp (hal, ref und sw) */ device = m_adapter[preloop].deviceinfo.begin (); *m_log << "Interator device auf erstes Element von deviceinfo gesetzt" << endl; while (device != m_adapter[preloop].deviceinfo.end ()) { /* für jedes im Array gespeicherten Format */ for (int loop=0; loop<sizeof (tmp)/sizeof (tmp[0]); loop++) { if (m_ptr_d3d->CheckDeviceType (preloop, (*device)->devtype, tmp[loop], D3DFMT_UNKNOWN, is_windowed) == D3D_OK) { combi[nFormat].adapterFormat = tmp[loop]; *m_log << "Format wird unterstützt:" << (char*)D3DFormatToString (tmp[loop]) << endl; combi[nFormat].windowed = is_windowed; *m_log << "Windowmode ist:" << combi[nFormat].windowed << endl; /* nagut adapterformat wird unterstützt, was ist mit den anderen */ if (m_ptr_d3d->CheckDeviceFormat (preloop, (*device)->devtype, tmp[loop], D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, tmp[loop]) == D3D_OK) { *m_log << "Format wird unterstützt (Z-Buffer):" << (char*)D3DFormatToString (tmp[loop]) << endl; combi[nFormat].deepthFormat = tmp[loop]; combi[nFormat].stencilFormat = tmp[loop]; } if (m_ptr_d3d->CheckDeviceFormat (preloop, (*device)->devtype, tmp[loop], 0, D3DRTYPE_TEXTURE, tmp[loop]) == D3D_OK) { *m_log << "Format wird unterstützt (Texture Buffer):" << (char*)D3DFormatToString (tmp[loop]) << endl; combi[nFormat].textureFormat = tmp[loop]; } (*device)->ptr_combo.push_back (&combi[nFormat]); nFormat++; *m_log << "Counter hochgezählt auf: " << nFormat << endl; } /* wenn das Format als Backbuffer nicht untersützt wird, kann es trotzdem für andere aufgaben gebutzt werden*/ else if (m_ptr_d3d->CheckDeviceFormat (preloop, (*device)->devtype, tmp[loop], D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, tmp[loop]) == D3D_OK) { combi[nFormat].deepthFormat = tmp[loop]; combi[nFormat].stencilFormat = tmp[loop]; combi[nFormat].windowed = is_windowed; *m_log << "Format wird unterstützt (Stencil neu:" << (char*)D3DFormatToString (tmp[loop]) << endl; *m_log << "Windowmode ist:" << combi[nFormat].windowed << endl; if (m_ptr_d3d->CheckDeviceFormat (preloop, (*device)->devtype, tmp[loop], 0, D3DRTYPE_TEXTURE, tmp[loop]) == D3D_OK) { *m_log << "Format wird unterstützt (Texture Buffer):" << (char*)D3DFormatToString (tmp[loop]) << endl; combi[nFormat].textureFormat = tmp[loop]; } (*device)->ptr_combo.push_back (&combi[nFormat]); nFormat++; *m_log << "Counter hochgezählt auf: " << nFormat << endl; } /* wenn das Format als Backbuffer nicht untersützt wird, kann es trotzdem für andere aufgaben gebutzt werden*/ else if (m_ptr_d3d->CheckDeviceFormat (preloop, (*device)->devtype, tmp[loop], 0, D3DRTYPE_TEXTURE, tmp[loop]) == D3D_OK) { combi[nFormat].textureFormat = tmp[loop]; combi[nFormat].windowed = is_windowed; *m_log << "Format wird unterstützt (Texture neu:" << (char*)D3DFormatToString (tmp[loop]) << endl; *m_log << "Windowmode ist:" << combi[nFormat].windowed << endl; (*device)->ptr_combo.push_back (&combi[nFormat]); nFormat++; *m_log << "Counter hochgezählt auf: " << nFormat << endl; } } *m_log << (int)(*device)->ptr_combo.size () << "unterstützte Formate gefunden" << endl; device++; *m_log << "Interator device auf das nächste Element gesetzt" << endl; } } *m_log << endl << endl << endl; }