Forcing hardware accelerated rendering

前端 未结 5 889
迷失自我
迷失自我 2021-01-08 00:58

I have an OpenGL library written in c++ that is used from a C# application using C++/CLI adapters. My problem is that if the application is used on laptops with Nvidia Optim

5条回答
  •  情书的邮戳
    2021-01-08 01:31

    From the document it seems to be rather simple. You are given multiple options how to do that. Unfortunately, the exe needs to do that, not the dll. According to this tutorial, it might be possible to do something like:

    class OptimusEnabler {
        [DllExport("NvOptimusEnablement")]
        public static int NvOptimusEnablement = 1;
    };
    

    This then needs to be included in your C++ library interface so that any C# application that uses it would be forced to export this. Alternately, you can try linking against nvapi.dll:

    class OptimusEnabler {
        [DllImport("nvapi.dll")]
        public static extern int NvAPI_Initialize();
    };
    

    According to the document, this should also be enough to recognize your application as NV-enabled. The imported function should not even be required to be called.

提交回复
热议问题