TheCherno / Sparky

Cross-Platform High Performance 2D/3D game engine for people like me who like to write code.
Apache License 2.0
1.09k stars 222 forks source link

Nvidia Optimus #97

Open Ilohama opened 8 years ago

Ilohama commented 8 years ago

I'm working on a laptop with an Optimus option but when I run Sparky, it still using the intel graphic card and not my Nvidia card....

I found a way to force optimus enabled :

extern "C" {
    _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}

but i'm not sure it's the best way

wallertech commented 8 years ago

You doing this on OpenGL or directx?

JeppeSRC commented 8 years ago

It should be the same either way.

Ilohama commented 8 years ago

DirectX don't print it on consol but yeah, it's the same on both of them xD

wallertech commented 8 years ago

http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf

That says you can also fix it the following way, but it doesn't mention wich one is the better way.

Static Library Bindings For any application without an existing application profile, there is a set of libraries which, when statically linked to a given application executable, will direct the Optimus driver to render the application using High Performance Graphics. As of Release 302, the current list of libraries are vcamp110.dll, vcamp110d.dll, nvapi.dll, nvapi64.dll, opencl.dll, nvcuda.dll, and cudart..