Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ How to detect graphics card model

Tags:

c++

gpu

detect

I'm writing an application that can be sped up a lot if a graphics card is available.

I've got the necessary DLL's to make my application utilize NVIDIA and AMD cards. But it requires being launched with specific command line arguments depending on which card is available.

I'd like to make an installer that will detect the specific brand of GPU and then launch the real application with the necessary command line arguments.

What's the best way to detect the type of card?

like image 673
mocode8 Avatar asked Dec 14 '25 02:12

mocode8


1 Answers

You have to detect it during runtime by using OpenGL. Use the command glGetString(GL_VENDOR) or GL_VERSION.

To do so using Direct3D 9 API:

Step 1 D3DADAPTER_IDENTIFIER AdapterIdentifier;

Step 2 m_pD3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &AdapterIdentifier);

Step 3 Get the max size of the graphics card identifier string const int cch = sizeof(AdapterIdentifier.Description);

Step 4 Define a TCHAR to hold the description TCHAR szDescription[cch];

Step 5 Use the unicode DX utility to convert the char string to TCHAR DXUtil_ConvertAnsiStringToGenericCch( szDescription, AdapterIdentifier.Description, cch );

Credit goes to: Anonymous_Poster_* @ http://www.gamedev.net/topic/358770-obtain-video-card-name-size-etc-in-c/

like image 75
MichaelMMeskhi Avatar answered Dec 15 '25 17:12

MichaelMMeskhi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!