• Breaking News

    Friday, May 3, 2019

    How to make a grid snapping cursor in Unity

    gamedev - game development, programming, design, writing, math, art, jams, postmortems, marketing

    How to make a grid snapping cursor in Unity


    How to make a grid snapping cursor in Unity

    Posted: 03 May 2019 03:21 AM PDT

    PSA For anyone developing a game/engine in C++!

    Posted: 03 May 2019 05:30 AM PDT

    Some people have a hybrid graphics setup! It's designed to auto-detect when an application should probably run on the high-performance GPU instead of the integrated one, but you'll need to give it a little help. To make NVIDIA Optimus realize your game is a game, and save laptop users the pain of configuring it manually, add this to your source code when targeting Windows:

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

    This line, from Optimus Rendering Policies, will allow laptop users to run your game with better performance, without them having to set it up themselves. Trust me, as an often-laptop-user, the process of manually configuring an app to use the discrete GPU is surprisingly slow (especially on the mid-range, low-performance sort of laptop that offers switchable graphics! The NVIDIA settings app lags like crazy!)

    As a laptop user, I'd love if people would actually start including these lines in their code.

    Edit: This version should help with AMD hybrid graphics, too:

    #ifdef WIN32 #include <windows.h> extern "C" { __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } 
    

    No comments:

    Post a Comment