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
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#include<Windows.h> #include<stdio.h> #include<d3d9.h> #pragma comment(lib, "d3d9.lib") #define APP_OK 0 #define APP_NOK 1 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char* pcCmdLine, int iShowCmd) { // erstellen der D3D IUnknown Schnittstelle PDIRECT3D9 pd3d = Direct3DCreate9(D3D_SDK_VERSION); if( !pd3d ) { // Fehlerausgabe wenn die Schnittstelle nicht erstellt werden konnte. MessageBox(NULL, "Es ist ein Fehler beim erstellen der Direct3D Schnittstelle aufgetretten", "FEHLER", MB_OK | MB_ICONEXCLAMATION); return APP_NOK; } int iAdapterCount = pd3d->GetAdapterCount(); D3DADAPTER_IDENTIFIER9* pAdapterIdentifier = new D3DADAPTER_IDENTIFIER9; for( int adapterIndex = 0 ; adapterIndex < iAdapterCount ; adapterIndex++ ) { if( FAILED ( pd3d->GetAdapterIdentifier( adapterIndex, 0, pAdapterIdentifier ) ) ) { MessageBox(NULL, "Es ist ein Fehler beim laden des Adapters aufgetretten", "FEHLER", MB_OK | MB_ICONEXCLAMATION); pd3d->Release(); delete pAdapterIdentifier; return APP_NOK; } //Ausgeben der Anzahl Adapter char caAdapterCount[100]; sprintf_s(caAdapterCount, "Die Anzahl gefundener Adapter ist : %d", iAdapterCount); MessageBox(NULL, caAdapterCount , "INFO", MB_OK | MB_ICONEXCLAMATION); //erstellen der Ausgabe für die Adapterinformationen char caAdapterOutput[1024]; sprintf_s(caAdapterOutput, "Drivername : %s\nDriver : %s\nDriverversion : %d\n\nBeschreibung : %s", pAdapterIdentifier->DeviceName, pAdapterIdentifier->Driver, pAdapterIdentifier->DriverVersion, pAdapterIdentifier->Description ); MessageBox(NULL, caAdapterOutput, "Gefundener Adapater", MB_OK | MB_ICONEXCLAMATION); } pd3d->Release(); delete pAdapterIdentifier; return APP_OK; } |
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 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 |
#include<Windows.h> #include<stdio.h> #include<d3d9.h> #include<list> #pragma comment(lib, "d3d9.lib") #define APP_OK 0 #define APP_NOK 1 using namespace std; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, char* pcCmdLine, int iShowCmd ) { D3DFORMAT aFormats [] = {D3DFMT_X8R8G8B8, D3DFMT_R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5}; // erstellen der D3D IUnknown Schnittstelle PDIRECT3D9 pd3d = Direct3DCreate9(D3D_SDK_VERSION); if( !pd3d ) { // Fehlerausgabe wenn die Schnittstelle nicht erstellt werden konnte. MessageBox( NULL, "Es ist ein Fehler beim erstellen der Direct3D Schnittstelle aufgetretten", "FEHLER", MB_OK | MB_ICONEXCLAMATION ); return APP_NOK; } int iAdapterCount = pd3d->GetAdapterCount(); D3DDISPLAYMODE stAdapterDisplayMode; if( iAdapterCount == 1 ) { // char[] für die Ausgabe der Modi des einzelnen Foromate char caAdapterModeOutput[50000]; for each( D3DFORMAT nextFormat in aFormats ) { // ermittle alle Modi für das aktuelle Format int modeCount = pd3d->GetAdapterModeCount( iAdapterCount, nextFormat ); // test char caAnzahlModi[1024]; sprintf_s(caAnzahlModi, "Anzahl Gefundene Modi : %d für Format : %d", modeCount, (UINT) nextFormat ); MessageBox( NULL, caAnzahlModi, "Anzahl Gefundene Modi", MB_OK | MB_ICONEXCLAMATION ); // for( int nextMode = 0 ; nextMode < modeCount ; nextMode++ ) { // ermittle Moduseigenschaften des nächsten Modus pd3d->EnumAdapterModes( iAdapterCount, nextFormat, nextMode, &stAdapterDisplayMode ); // erstellen der Ausgabe für die Video Modi der gefundenen Adapter sprintf_s(caAdapterModeOutput, "Format : %d\nResolution : %d x %d\nRefresh : %d\n\n\n", stAdapterDisplayMode.Format, stAdapterDisplayMode.Width, stAdapterDisplayMode.Height, stAdapterDisplayMode.RefreshRate ); } // noch den aktuellen mode anhängen pd3d->GetAdapterDisplayMode ( iAdapterCount, &stAdapterDisplayMode ); sprintf_s(caAdapterModeOutput, "Aktuell\n--------\n\nFormat : %d\nResolution : %d x %d\nRefresh : %d\n\n\n", stAdapterDisplayMode.Format, stAdapterDisplayMode.Width, stAdapterDisplayMode.Height, stAdapterDisplayMode.RefreshRate ); } MessageBox( NULL, caAdapterModeOutput, "Gefundene Modi", MB_OK | MB_ICONEXCLAMATION ); } pd3d->Release(); return APP_OK; } |
C-/C++-Quelltext |
|
1 2 3 4 5 |
char caAdapterOutput[1024]; sprintf_s(caAdapterOutput, "Drivername : %s\nDriver : %s\nDriverversion : %d", pAdapterIdentifier->DeviceName, pAdapterIdentifier->Driver, pAdapterIdentifier->DriverVersion ); MessageBox(NULL, caAdapterOutput, "Gefundener Adapater", MB_OK | MB_ICONEXCLAMATION); |
C-/C++-Quelltext |
|
1 2 3 4 |
// noch den aktuellen mode anhängen pd3d->GetAdapterDisplayMode ( iAdapterCount, &stAdapterDisplayMode ); sprintf_s(caAdapterModeOutput, "Aktuell\n--------\n\nFormat : %d\nResolution : %d x %d\nRefresh : %d\n\n\n", stAdapterDisplayMode.Format, stAdapterDisplayMode.Width, stAdapterDisplayMode.Height, stAdapterDisplayMode.RefreshRate ); |
Werbeanzeige