9
\$\begingroup\$

I'm following an OpenGL tutorial series at opengl-tutorial.org, but have run into a problem:

The following lines:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

cause my glfwCreateWindow() call to return null.

As I understand, this is caused by lack of support for OpenGL 3.3.

Why is my machine trying to render OpenGL 3.3 using my onboard graphics chipset (Intel HD Graphics 3000, which only supports OpenGL 3.1) instead of using my dedicated graphics card (GeForce 520M, which supports OpenGL 4.x)? I think this has something to do with power saving.

Note: I have newly updated nVidia drivers, installed as of yesterday. I know they are working because if I right-click my desktop I get a context menu for nVidia Control Panel.

Running OpenGL Extensions Viewer 4.x also displays that I'm using Intel HD Graphics 3000, supporting OpenGL <= 3.1, which is consistent with my theory regarding power saving.

Regards,

\$\endgroup\$

3 Answers 3

5
\$\begingroup\$

This is the NVidia manual to their Optimus, the driver which is responsible of switching between integrated GPU and NVidia GPU. From a quick look, it seems they describe how to set the default GPU for a program. I haven't tried it yet though.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Thanks for the response. I was able to force my application to run on my dedicated GPU by by right clicking the executable and choosing "Run with graphics processor -> High performance NVIDIA processor" However, I want my application to turn on Optimus automatically. I tried exporting the DWORD manually (which only works with windows.h included), and ran into an issue: NvOptimusEnablement already defined in playground.obj I think this has to do with the fact that CMake has a GLFW_USE_OPTIMUS_HPG flag, which is enabled - so why doesn't that flag suffice? \$\endgroup\$
    – Blake
    Mar 27, 2014 at 1:19
  • 2
    \$\begingroup\$ Sorry I have no idea. :( \$\endgroup\$ Mar 27, 2014 at 12:31
4
\$\begingroup\$

For Windows and GLFW - You can compile glfw library by yourself and add to cmake GLFW_USE_HYBRID_HPG option. More info here - Compiling GLFW

\$\endgroup\$
1
1
\$\begingroup\$

Going into the NVidia control panel by whatever method (From the"Change Default Graphics Processor" link on the "Run With Graphics Processor" menu is how I got there). This will give you the option to change the graphics processor per application: enter image description here

Or globally: enter image description here

For your particular case, I'd try adding a program setting for cmake, and, failing that, change the global setting.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Hi, since I'm writing an application, changing nvidia cpanel settings isn't a viable solution for other users, so I need to export the DWORD (either in CMake as you suggest or otherwise). As I said in comment to another response, CMake was already configured to export Optimus flags, but it didnt' work. Disabling this flag in cmake and including the export manually fixed the issue, but it makes the code windows-dependent. I googled for CMake bugs with optimus but didn't see anything. Maybe you have a suggestion? \$\endgroup\$
    – Blake
    Mar 27, 2014 at 12:08
  • \$\begingroup\$ Matt Sieker's solutions works great for my alienware m17xr3. Forcing nvidia's card to be primary instead of the integrated Intel card solved my openGL3.2+ above issues. \$\endgroup\$
    – user79688
    Feb 25, 2016 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .