Created
March 4, 2020 12:17
-
-
Save elsamuko/d3049d52ca235112c99ac3ee30282846 to your computer and use it in GitHub Desktop.
Print Direct3D information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env cppsh | |
#include <cstdio> | |
#include <windows.h> | |
#include <d3d9.h> | |
//! \sa https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/windows/qwindowsopengltester.cpp#L124 | |
void detect() { | |
typedef IDirect3D9 * ( WINAPI * PtrDirect3DCreate9 )( UINT ); | |
HMODULE d3d9lib = ::LoadLibraryA( "d3d9" ); | |
if( !d3d9lib ) { | |
return; | |
} | |
PtrDirect3DCreate9 direct3DCreate9 = ( PtrDirect3DCreate9 )GetProcAddress( d3d9lib, "Direct3DCreate9" ); | |
if( !direct3DCreate9 ) { | |
return; | |
} | |
IDirect3D9* direct3D9 = direct3DCreate9( D3D_SDK_VERSION ); | |
if( !direct3D9 ) { | |
return; | |
} | |
D3DADAPTER_IDENTIFIER9 adapterIdentifier; | |
const HRESULT hr = direct3D9->GetAdapterIdentifier( 0, 0, &adapterIdentifier ); | |
direct3D9->Release(); | |
if( SUCCEEDED( hr ) ) { | |
printf( "+--Direct 3D-----------------------------------\n" ); | |
printf( "| VendorId: 0x%x\n", adapterIdentifier.VendorId ); | |
printf( "| DeviceId: 0x%x\n", adapterIdentifier.DeviceId ); | |
printf( "| Revision: 0x%x\n", adapterIdentifier.Revision ); | |
printf( "| SubSysId: 0x%x\n", adapterIdentifier.SubSysId ); | |
printf( "| Product: %hu\n", HIWORD( adapterIdentifier.DriverVersion.HighPart ) ); // Product | |
printf( "| Version: %hu\n", LOWORD( adapterIdentifier.DriverVersion.HighPart ) ); // Version | |
printf( "| Sub version: %hu\n", HIWORD( adapterIdentifier.DriverVersion.LowPart ) ); // Sub version | |
printf( "| build: %hu\n", LOWORD( adapterIdentifier.DriverVersion.LowPart ) ); // build | |
printf( "| Driver: %s\n", adapterIdentifier.Driver ); | |
printf( "| Description: %s\n", adapterIdentifier.Description ); | |
printf( "+----------------------------------------------\n" ); | |
} | |
} | |
int main() { | |
detect(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On a real machine:
On a VMWare: