1
0
forked from 0ad/0ad

Changes graphics card name detection on Windows to use OpenGL, as a workaround for certain WMI related crashes on Nvidia Optimus and netbook systems. Fixes #1952, #1575

This was SVN commit r13536.
This commit is contained in:
historic_bruno 2013-07-06 18:30:29 +00:00
parent 30f8d6dae2
commit 8aa016a884

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012 Wildfire Games
/* Copyright (c) 2013 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -40,18 +40,17 @@ namespace gfx {
std::wstring CardName()
{
// GL_VENDOR+GL_RENDERER are good enough here, so we don't use wgfx_CardName,
// plus that can cause crashes with Nvidia Optimus and some netbooks
// see http://trac.wildfiregames.com/ticket/1952
// http://trac.wildfiregames.com/ticket/1575
wchar_t cardName[128];
#if OS_WIN
if(wgfx_CardName(cardName, ARRAY_SIZE(cardName)) != INFO::OK)
#endif
{
const char* vendor = (const char*)glGetString(GL_VENDOR);
const char* renderer = (const char*)glGetString(GL_RENDERER);
// (happens if called before ogl_Init or between glBegin and glEnd.)
if(!vendor || !renderer)
return L"";
swprintf_s(cardName, ARRAY_SIZE(cardName), L"%hs %hs", vendor, renderer);
}
const char* vendor = (const char*)glGetString(GL_VENDOR);
const char* renderer = (const char*)glGetString(GL_RENDERER);
// (happens if called before ogl_Init or between glBegin and glEnd.)
if(!vendor || !renderer)
return L"";
swprintf_s(cardName, ARRAY_SIZE(cardName), L"%hs %hs", vendor, renderer);
// remove crap from vendor names. (don't dare touch the model name -
// it's too risky, there are too many different strings)