OpenGL程序使用独显运行的方法

在exe里面导出下面两个变量,同时对N卡和A卡都有效,程序默认打开就会使用独显运行。
导出的变量名字必须和下面的一致,不能有前置下划线。
D3D这些年没琢磨过,理论这个设置D3D也能用。这个方法是系统层显卡驱动在程序执行时检测的一个标记,有这个标记,则用独显运行。

// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
// The following line is to favor the high performance NVIDIA GPU if there are multiple GPUs
// Has to be .exe module to be correctly detected.
// N卡使用独显运行
extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;

// And the AMD equivalent
// Also has to be .exe module to be correctly detected.
// A显卡使用独显运行
extern "C" __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 0x00000001;

猜你喜欢

转载自www.cnblogs.com/sdragonx/p/12183194.html