LWJGL uses wrong graphics card

Hi,

I have an little problem.
My LWJGL application uses the integrated intel HD graphics card, but not my external nvidia graphics card.
How can i change this, so Nvidia GTX960M will be used?

on windows : force “high performance gpu” to java.exe in the nvidia CP

I had the same problem, but for me adding javaw.exe did the trick. You could also give it a try if java.exe doesn’t solve the problem for you.

But than the user also has to take the trick.
I want to choose the right graphics card at runtime.

That’s simply not possible. The user has the control to choose which GPU will be used. It is a way of saving battery for notebooks.

The only thing you can do is to have your program always automatically use the dedicated graphics card by writing a custom javaw.exe/java.exe launcher using the JNI Invocation API and including that with your (hopefully shipped) JRE.
When this process exports a symbol called “NvOptimusEnablement” as a DWORD with value = 1, then the dedicated graphics card will be used (unless of course the user overrides this in the Nvidia settings).

The AMD equivalent:

int AmdPowerXpressRequestHighPerformance = 1;

Can confirm that the Nvidia DWORD works. Presumably the AMD DWORD works too.

What about that?
https://www.opengl.org/registry/specs/NV/gpu_affinity.txt

[quote]On systems with more than one GPU it is desirable to be able to
select which GPU(s) in the system become the target for OpenGL
rendering commands. This extension introduces the concept of a GPU
affinity mask.
[/quote]

This only works when having multiple Nvidia cards, and only when the dedicated graphics card is already being used, and therefore the NV extensions are available. As far as I know, there are no Optimus Notebook with multiple Nvidia cards.