C++ – Select a graphic device in windows + opengl

copenglwinapi

I know how to open a window with openGL (using Win32 or other toolkits). But when the system have 2 graphics cards. How do I select a graphic device to render? My programming language is C++ and I'm focusing on windows but any sample will be welcome.

Edit: Maybe Its a good idea to explain my problem better, in order to add some perspective: My new laptop have two graphic cards. An integrated Intel HD and a GeForce GT 540M. The intel card works most of the time to render SO, because it save battery. When a game is started, then the GeForce is started automatically. This system is called "optimus" by nvidia ( http://www.nvidia.com/object/optimus_technology.html ). The problem is that when I start my application, de opengl driver detected is 2.1 and the vendor is Intel, and I don't know how to switch to the other device.

Finally I found this information. It isn't too useful if you are not using nvidia but I let it to any who could read http://developer.download.nvidia.com/compute/cuda/3_2/toolkit/docs/CUDA_Developer_Guide_for_Optimus_Platforms.pdf

Best Answer

The simplest solution is to paste this code snippet somewhere in your application. This will tell the Nvidia and AMD drivers to switch to the powerful GPU when your app starts.

// enable optimus!
extern "C" {
    _declspec(dllexport) DWORD NvOptimusEnablement = 1;
    _declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}

EDIT: add the AMD keyword

Related Topic