Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Forcing Machine to Use Dedicated Graphics Card?  (Read 3162 times)

0 Members and 1 Guest are viewing this topic.

Anthony404

    Topic Starter


    Newbie

  • Experience: Experienced
  • OS: Windows 10
Forcing Machine to Use Dedicated Graphics Card?
« on: July 02, 2019, 12:05:03 AM »
I am part of a team developing an application using C++ with SDL and OpenGL.

On laptops when the application is ran the dedicated graphics card is not used and the GL context fails to create because the integrated graphics card does not support the version of GL we want.

I have a feeling that this problem is specific to the laptop in question and not something we can solve through code. But, if anyone knows if there is a solution that'd be great.

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Forcing Machine to Use Dedicated Graphics Card?
« Reply #1 on: July 03, 2019, 02:10:19 PM »
What laptop is in question and hardware specs?

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Forcing Machine to Use Dedicated Graphics Card?
« Reply #2 on: July 03, 2019, 10:11:02 PM »
What Graphics device is made available to an application is at the whim of the driver for the dedicated card.

The "proper way" to do this would be to add your application to the AMD and NVidia Application profiles to use the dedicated card when installed. Nvidia has NVAPI.DLL for accessing and setting that info (They've moved and changed how that info is saved more than once so it's not reliable accessing it directly).

The "cheat" way is to just export specific symbols from the main executable:
Code: [Select]
extern "C"
{
  __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
}
extern "C"
{
  __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
supposedly will trigger the dedicated driver to allow the software to use the dedicated hardware instead of passing it off to the integrated chipset.
I was trying to dereference Null Pointers before it was cool.