Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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,

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
1  
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? –  Cokemonkey11 Mar 27 at 1:19
1  
Sorry I have no idea. :( –  János Turánszki Mar 27 at 12:31

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.

share|improve this answer
    
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? –  Cokemonkey11 Mar 27 at 12:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.