The easiest way from C++ to ensure that the dedicated graphics card is used instead of chipset switchable graphics under Windows is to export the following symbols (MSVC sample code):
Enable dedicated graphics for NVIDIA:
extern "C"
{
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
}
Enable dedicated graphics for AMD Radeon:
extern "C"
{
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
Caveat: If the user has created a profile for the application to use integrated chipset, then these will not work.
I am unsure if this would work similarly under Linux / MacOS (unlikely).