Torque3D Documentation / _generateds / cardProfile.cpp

cardProfile.cpp

Engine/source/platformWin32/cardProfile.cpp

More...

Public Functions

DefineEngineFunction(initDisplayDeviceInfo , void , () , "()" "@brief Initializes variables that track device and vendor information/<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">IDs\n\n</a>" "@ingroup Rendering" )

Detailed Description

Public Functions

DefineEngineFunction(initDisplayDeviceInfo , void , () , "()" "@brief Initializes variables that track device and vendor information/<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">IDs\n\n</a>" "@ingroup Rendering" )

initDisplayDeviceInfo()

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#include "core/strings/stringFunctions.h"
25#include "console/console.h"
26#include "console/engineAPI.h"
27#include "platformWin32/platformWin32.h"
28
29
30void initDisplayDeviceInfo()
31{
32   Con::printf( "Reading Display Device information..." );
33
34   U8 i = 0;
35
36   DISPLAY_DEVICEA ddData;
37   ddData.cb = sizeof( DISPLAY_DEVICEA );
38
39   // Search for the primary display adapter, because that is what the rendering
40   // context will get created on.
41   while( EnumDisplayDevicesA( NULL, i, &ddData, 0 ) != 0 )
42   {
43      // If we find the primary display adapter, break out
44      if( ddData.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE )
45         break;
46
47      i++;
48   }
49
50   Con::printf( "   Primary Display Device Found:" );
51
52   // Ok, now we have the primary display device. Parse the device information.
53   char ven[9];
54   char dev[9];
55
56   ven[8] = dev[8] = '\0';
57
58   // It may seem a bit silly here to cast, but there are two implimentations in Platform.h
59   // This usage is the "const" version...
60   char *pos = dStrstr( ddData.DeviceID, (const char *)"VEN_");
61
62   dStrncpy( ven, ( pos ) ? pos : "VEN_0000", 8 );
63
64   Con::printf( "      Vendor Id: %s", ven );
65
66   pos = dStrstr( ddData.DeviceID, (const char *)"DEV_" );
67
68   dStrncpy( dev, ( pos ) ? pos : "DEV_0000", 8 );
69
70   Con::printf( "      Device Id: %s", dev );
71
72   // We now have the information, set them to console variables so we can parse
73   // the file etc in script using getField and so on.
74   Con::setVariable( "$PCI_VEN", ven );
75   Con::setVariable( "$PCI_DEV", dev );
76}
77
78DefineEngineFunction( initDisplayDeviceInfo, void, (), , "()"
79            "@brief Initializes variables that track device and vendor information/IDs\n\n"
80            "@ingroup Rendering")
81{
82   initDisplayDeviceInfo();
83}
84