DefaultPrefs >> Vendor is always VEN_0000 (+fix)
by amaranthia · in Torque Game Builder · 07/01/2008 (10:15 pm) · 4 replies
In TGB 1.7.2, the vendor is always returned as VEN_0000.
No wonder we've been seeing so many video bugs on the forums recently. The vendor is never adjusted for the picky cards like Intel and ATI.
Bryce and I have been looking into the problem tonight and it looks like there is an easy fix. However, the fix must occur in the engine.
The culprit:
In cardProfile.cpp, a unicode value is retrieved for the video card, and is passed as a char. This causes things to go a little haywire and the video card always is returned as an unknown via script.
No wonder we've been seeing so many video bugs on the forums recently. The vendor is never adjusted for the picky cards like Intel and ATI.
Bryce and I have been looking into the problem tonight and it looks like there is an easy fix. However, the fix must occur in the engine.
The culprit:
In cardProfile.cpp, a unicode value is retrieved for the video card, and is passed as a char. This causes things to go a little haywire and the video card always is returned as an unknown via script.
Associate amaranthia
In cardProfile.cpp:
void initDisplayDeviceInfo() { Con::printf( "Reading Display Device information..." ); U8 i = 0; // Bryce Fix: changed to ansii DISPLAY_DEVICEA ddData; // Bryce Fix: changed to ansii ddData.cb = sizeof( DISPLAY_DEVICEA ); // Search for the primary display adapter, because that is what the rendering // context will get created on. // Bryce Fix: changed to ansii while( EnumDisplayDevicesA( NULL, i, &ddData, 0 ) != 0 ) { // If we find the primary display adapter, break out if( ddData.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ) break; i++; } Con::printf( " Primary Display Device Found:" ); // Ok, now we have the primary display device. Parse the device information. char ven[9]; char dev[9]; ven[8] = dev[8] = '[[6280dc331128e]]'; // It may seem a bit silly here to cast, but there are two implimentations in Platform.h // This usage is the "const" version... // Bryce note: before fix, unicode was created, but cast as char pointer. char *pos = dStrstr( ddData.DeviceID, (const char *)"VEN_"); // Bryce suggestion: changed to strn copy because string and length known dStrncpy( ven, ( pos ) ? pos : "VEN_0000", 8 ); Con::printf( " Vendor Id: %s", ven ); pos = dStrstr( ddData.DeviceID, (const char *)"DEV_" ); // Bryce suggestion: changed to strn copy because string and length known dStrncpy( dev, ( pos ) ? pos : "DEV_0000", 8 ); Con::printf( " Device Id: %s", dev ); // We now have the information, set them to console variables so we can parse // the file etc in script using getField and so on. Con::setVariable( "$PCI_VEN", ven ); Con::setVariable( "$PCI_DEV", dev ); }