diff options
Diffstat (limited to 'samples/AnselSDKDelayLoader/source/DelayLoader.cpp')
| -rw-r--r-- | samples/AnselSDKDelayLoader/source/DelayLoader.cpp | 146 |
1 files changed, 82 insertions, 64 deletions
diff --git a/samples/AnselSDKDelayLoader/source/DelayLoader.cpp b/samples/AnselSDKDelayLoader/source/DelayLoader.cpp index 0756764..3184d6e 100644 --- a/samples/AnselSDKDelayLoader/source/DelayLoader.cpp +++ b/samples/AnselSDKDelayLoader/source/DelayLoader.cpp @@ -45,18 +45,29 @@ namespace namespace ansel { - namespace - { - typedef SetConfigurationStatus(__cdecl *PFNSETCONFIGURATION)(const Configuration& cfg); - typedef void(__cdecl *PFNUPDATECAMERA)(Camera& camera); - typedef void(__cdecl *PFNSESSIONFUNC)(); - typedef bool(__cdecl *PFNISANSELAVAILABLE)(); - typedef void(__cdecl *PFNMARKHDRBUFFERBIND)(HintType, uint64_t); - typedef void(__cdecl *PFNMARKHDRBUFFERFINISHED)(uint64_t); - typedef UserControlStatus(__cdecl *PFNADDUSERCONTROL)(const UserControlDesc&); - typedef UserControlStatus(__cdecl *PFNSETUSERCONTROLLABELLOCALIZATION)(uint32_t, const char*, const char*); - typedef UserControlStatus(__cdecl *PFNREMOVEUSERCONTROL)(uint32_t); - typedef UserControlStatus(__cdecl *PFNGETUSERCONTROLVALUE)(uint32_t, void*); + namespace + { + typedef SetConfigurationStatus(__cdecl *PFNSETCONFIGURATION)(const Configuration& cfg); + typedef void(__cdecl *PFNUPDATECAMERA)(Camera& camera); + typedef void(__cdecl *PFNSESSIONFUNC)(); + typedef bool(__cdecl *PFNISANSELAVAILABLE)(); + typedef void(__cdecl *PFNMARKHDRBUFFERBIND)(HintType, uint64_t); + typedef void(__cdecl *PFNMARKHDRBUFFERFINISHED)(uint64_t); + typedef UserControlStatus(__cdecl *PFNADDUSERCONTROL)(const UserControlDesc&); + typedef UserControlStatus(__cdecl *PFNSETUSERCONTROLLABELLOCALIZATION)(uint32_t, const char*, const char*); + typedef UserControlStatus(__cdecl *PFNREMOVEUSERCONTROL)(uint32_t); + typedef UserControlStatus(__cdecl *PFNGETUSERCONTROLVALUE)(uint32_t, void*); + + PFNMARKHDRBUFFERFINISHED markHdrBufferFinishedFunc = nullptr; + PFNMARKHDRBUFFERBIND markHdrBufferBindFunc = nullptr; + PFNSESSIONFUNC stopSessionFunc = nullptr; + PFNSESSIONFUNC startSessionFunc = nullptr; + PFNUPDATECAMERA updateCameraFunc = nullptr; + PFNSETCONFIGURATION setConfigurationFunc = nullptr; + PFNADDUSERCONTROL addUserControlFunc = nullptr; + PFNSETUSERCONTROLLABELLOCALIZATION setUserControlLabelLocalizationFunc = nullptr; + PFNREMOVEUSERCONTROL removeUserControlFunc = nullptr; + PFNGETUSERCONTROLVALUE getUserControlValueFunc = nullptr; PFNMARKHDRBUFFERFINISHED markHdrBufferFinishedFunc = nullptr; PFNMARKHDRBUFFERBIND markHdrBufferBindFunc = nullptr; @@ -69,21 +80,28 @@ namespace ansel PFNREMOVEUSERCONTROL removeUserControlFunc = nullptr; PFNGETUSERCONTROLVALUE getUserControlValueFunc = nullptr; - DelayLoadStatus resolveFunctionPointers() - { - if (anselSDK == NULL) - return kDelayLoadDllNotFound; - - setConfigurationFunc = reinterpret_cast<PFNSETCONFIGURATION>(GetProcAddress(anselSDK, "setConfiguration")); - stopSessionFunc = reinterpret_cast<PFNSESSIONFUNC>(GetProcAddress(anselSDK, "stopSession")); - startSessionFunc = reinterpret_cast<PFNSESSIONFUNC>(GetProcAddress(anselSDK, "startSession")); - updateCameraFunc = reinterpret_cast<PFNUPDATECAMERA>(GetProcAddress(anselSDK, "updateCamera")); - markHdrBufferBindFunc = reinterpret_cast<PFNMARKHDRBUFFERBIND>(GetProcAddress(anselSDK, "markHdrBufferBind")); - markHdrBufferFinishedFunc = reinterpret_cast<PFNMARKHDRBUFFERFINISHED>(GetProcAddress(anselSDK, "markHdrBufferFinished")); - addUserControlFunc = reinterpret_cast<PFNADDUSERCONTROL>(GetProcAddress(anselSDK, "addUserControl")); - setUserControlLabelLocalizationFunc = reinterpret_cast<PFNSETUSERCONTROLLABELLOCALIZATION>(GetProcAddress(anselSDK, "setUserControlLabelLocalization")); - removeUserControlFunc = reinterpret_cast<PFNREMOVEUSERCONTROL>(GetProcAddress(anselSDK, "removeUserControl")); - getUserControlValueFunc = reinterpret_cast<PFNGETUSERCONTROLVALUE>(GetProcAddress(anselSDK, "getUserControlValue")); + setConfigurationFunc = reinterpret_cast<PFNSETCONFIGURATION>(GetProcAddress(anselSDK, "setConfiguration")); + stopSessionFunc = reinterpret_cast<PFNSESSIONFUNC>(GetProcAddress(anselSDK, "stopSession")); + startSessionFunc = reinterpret_cast<PFNSESSIONFUNC>(GetProcAddress(anselSDK, "startSession")); + updateCameraFunc = reinterpret_cast<PFNUPDATECAMERA>(GetProcAddress(anselSDK, "updateCamera")); + markHdrBufferBindFunc = reinterpret_cast<PFNMARKHDRBUFFERBIND>(GetProcAddress(anselSDK, "markHdrBufferBind")); + markHdrBufferFinishedFunc = reinterpret_cast<PFNMARKHDRBUFFERFINISHED>(GetProcAddress(anselSDK, "markHdrBufferFinished")); + addUserControlFunc = reinterpret_cast<PFNADDUSERCONTROL>(GetProcAddress(anselSDK, "addUserControl")); + setUserControlLabelLocalizationFunc = reinterpret_cast<PFNSETUSERCONTROLLABELLOCALIZATION>(GetProcAddress(anselSDK, "setUserControlLabelLocalization")); + removeUserControlFunc = reinterpret_cast<PFNREMOVEUSERCONTROL>(GetProcAddress(anselSDK, "removeUserControl")); + getUserControlValueFunc = reinterpret_cast<PFNGETUSERCONTROLVALUE>(GetProcAddress(anselSDK, "getUserControlValue")); + + if (setConfigurationFunc == nullptr || + stopSessionFunc == nullptr || + startSessionFunc == nullptr || + updateCameraFunc == nullptr || + markHdrBufferBindFunc == nullptr || + markHdrBufferFinishedFunc == nullptr || + addUserControlFunc == nullptr || + setUserControlLabelLocalizationFunc == nullptr || + removeUserControlFunc == nullptr || + getUserControlValueFunc == nullptr) + return kDelayLoadIncompatibleVersion; if (setConfigurationFunc == nullptr || stopSessionFunc == nullptr || @@ -249,43 +267,43 @@ namespace ansel forward = { rot[0][2], rot[1][2], rot[2][2] }; } - void rotationMatrixVectorsToQuaternion(const nv::Vec3& right, const nv::Vec3& up, const nv::Vec3& forward, nv::Quat& q) - { - const float rot[3][3] = { - { right.x, up.x, forward.x }, - { right.y, up.y, forward.y }, - { right.z, up.z, forward.z } - }; - makeQuaternionFromRotationMatrix(q, rot); - } - - UserControlStatus addUserControl(const UserControlDesc& desc) - { - if (addUserControlFunc) - return addUserControlFunc(desc); - return UserControlStatus::kUserControlInvalidCallback; - } - - UserControlStatus setUserControlLabelLocalization(uint32_t userControlId, const char* lang, const char* labelUtf8) - { - if (setUserControlLabelLocalizationFunc) - return setUserControlLabelLocalizationFunc(userControlId, lang, labelUtf8); - return UserControlStatus::kUserControlInvalidCallback; - } - - UserControlStatus removeUserControl(uint32_t userControlId) - { - if (removeUserControlFunc) - return removeUserControlFunc(userControlId); - return UserControlStatus::kUserControlInvalidCallback; - } - - UserControlStatus getUserControlValue(uint32_t userControlId, void* value) - { - if (getUserControlValueFunc) - return getUserControlValueFunc(userControlId, value); - return UserControlStatus::kUserControlInvalidCallback; - } + void rotationMatrixVectorsToQuaternion(const nv::Vec3& right, const nv::Vec3& up, const nv::Vec3& forward, nv::Quat& q) + { + const float rot[3][3] = { + { right.x, up.x, forward.x }, + { right.y, up.y, forward.y }, + { right.z, up.z, forward.z } + }; + makeQuaternionFromRotationMatrix(q, rot); + } + + UserControlStatus addUserControl(const UserControlDesc& desc) + { + if (addUserControlFunc) + return addUserControlFunc(desc); + return UserControlStatus::kUserControlInvalidCallback; + } + + UserControlStatus setUserControlLabelLocalization(uint32_t userControlId, const char* lang, const char* labelUtf8) + { + if (setUserControlLabelLocalizationFunc) + return setUserControlLabelLocalizationFunc(userControlId, lang, labelUtf8); + return UserControlStatus::kUserControlInvalidCallback; + } + + UserControlStatus removeUserControl(uint32_t userControlId) + { + if (removeUserControlFunc) + return removeUserControlFunc(userControlId); + return UserControlStatus::kUserControlInvalidCallback; + } + + UserControlStatus getUserControlValue(uint32_t userControlId, void* value) + { + if (getUserControlValueFunc) + return getUserControlValueFunc(userControlId, value); + return UserControlStatus::kUserControlInvalidCallback; + } } DelayLoadStatus loadAnselSDKLibrary(const char* pathToLibraryUtf8) |