1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <nel/3d/driver.h>
21 #include <nel/3d/dru.h>
22 #include <QtOpenGL/QGLWidget>
37 bool CSystem::parseDriverVersion(const std::string
&device
, uint64 driver
, std::string
&version
)
40 uint32 version1
= driver
>> 48;
41 uint32 version2
= (driver
>> 32) & 0xffff;
42 uint32 version3
= (driver
>> 16) & 0xffff;
43 uint32 version4
= driver
& 0xffff;
45 if (device
.find("NVIDIA") != std::string::npos
)
47 // nvidia should be something like 9.18.13.2018 and 9.18.13.1422
48 // which respectively corresponds to drivers 320.18 and 314.22
49 uint32 nvVersionMajor
= (version3
% 10) * 100 + (version4
/ 100);
50 uint32 nvVersionMinor
= version4
% 100;
52 version
= NLMISC::toString("%u.%u", nvVersionMajor
, nvVersionMinor
);
56 version
= NLMISC::toString("%u.%u.%u.%u", version1
, version2
, version3
, version4
);
62 void CSystem::GatherSysInfo()
67 if( NLMISC::CSystemInfo::getVideoInfo( device
, driver
) )
69 sysInfo
.videoDevice
= device
;
71 CSystem::parseDriverVersion(device
, driver
, sysInfo
.videoDriverVersion
);
75 sysInfo
.videoDevice
= "video card";
76 sysInfo
.videoDriverVersion
= "0.0.0.0";
79 sysInfo
.osName
= NLMISC::CSystemInfo::getOS();
80 sysInfo
.cpuName
= NLMISC::CSystemInfo::getProc();
81 sysInfo
.totalRAM
= NLMISC::CSystemInfo::totalPhysicalMemory();
82 sysInfo
.totalRAM
/= ( 1024 * 1024 );
86 void CSystem::GatherD3DInfo()
88 NL3D::IDriver
*driver
= NULL
;
91 driver
= NL3D::CDRU::createD3DDriver();
93 NL3D::IDriver::CAdapter adapter
;
95 if( driver
->getAdapter( 0xffffffff, adapter
) )
97 d3dInfo
.device
= adapter
.Description
;
98 d3dInfo
.driver
= adapter
.Driver
;
100 CSystem::parseDriverVersion(d3dInfo
.device
, adapter
.DriverVersion
, d3dInfo
.driverVersion
);
103 GetVideoModes( d3dInfo
.modes
, driver
);
108 catch(const NLMISC::Exception
&e
)
110 nlwarning( e
.what() );
115 void CSystem::GatherOpenGLInfo()
117 QGLWidget
*gl
= new QGLWidget();
121 const char *s
= NULL
;
122 s
= reinterpret_cast< const char * >( glGetString( GL_VENDOR
) );
124 openglInfo
.vendor
.assign( s
);
126 s
= reinterpret_cast< const char * >( glGetString( GL_RENDERER
) );
128 openglInfo
.renderer
.assign( s
);
130 s
= reinterpret_cast< const char * >( glGetString( GL_VERSION
) );
132 openglInfo
.driverVersion
.assign( s
);
134 s
= reinterpret_cast< const char * >( glGetString( GL_EXTENSIONS
) );
137 openglInfo
.extensions
.assign( s
);
138 for( std::string::iterator itr
= openglInfo
.extensions
.begin(); itr
!= openglInfo
.extensions
.end(); ++itr
)
147 NL3D::IDriver
*driver
= NL3D::CDRU::createGlDriver();
149 GetVideoModes( openglInfo
.modes
, driver
);
152 catch(const NLMISC::Exception
&e
)
154 nlwarning( e
.what() );
158 void CSystem::GetVideoModes( std::vector
< CVideoMode
> &dst
, NL3D::IDriver
*driver
) const
160 std::vector
< NL3D::GfxMode
> modes
;
161 driver
->getModes( modes
);
170 dst
.push_back( mode
);
173 for( std::vector
< NL3D::GfxMode
>::iterator itr
= modes
.begin(); itr
!= modes
.end(); ++itr
)
175 if( ( itr
->Width
>= 800 ) && ( itr
->Height
>= 600 ) && ( itr
->Depth
>= 16 ) )
178 mode
.depth
= itr
->Depth
;
179 mode
.width
= itr
->Width
;
180 mode
.height
= itr
->Height
;
181 mode
.frequency
= itr
->Frequency
;
183 dst
.push_back( mode
);