|
| 1 | +// This code contains NVIDIA Confidential Information and is disclosed to you |
| 2 | +// under a form of NVIDIA software license agreement provided separately to you. |
| 3 | +// |
| 4 | +// Notice |
| 5 | +// NVIDIA Corporation and its licensors retain all intellectual property and |
| 6 | +// proprietary rights in and to this software and related documentation and |
| 7 | +// any modifications thereto. Any use, reproduction, disclosure, or |
| 8 | +// distribution of this software and related documentation without an express |
| 9 | +// license agreement from NVIDIA Corporation is strictly prohibited. |
| 10 | +// |
| 11 | +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES |
| 12 | +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO |
| 13 | +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, |
| 14 | +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | +// |
| 16 | +// Information and code furnished is believed to be accurate and reliable. |
| 17 | +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such |
| 18 | +// information or for any infringement of patents or other rights of third parties that may |
| 19 | +// result from its use. No license is granted by implication or otherwise under any patent |
| 20 | +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. |
| 21 | +// This code supersedes and replaces all information previously supplied. |
| 22 | +// NVIDIA Corporation products are not authorized for use as critical |
| 23 | +// components in life support devices or systems without express written approval of |
| 24 | +// NVIDIA Corporation. |
| 25 | +// |
| 26 | +// Copyright 2016 NVIDIA Corporation. All rights reserved. |
| 27 | + |
| 28 | +#pragma once |
| 29 | +#include <ansel/Defines.h> |
| 30 | +#include <ansel/Session.h> |
| 31 | +#include <ansel/Version.h> |
| 32 | +#include <nv/Vec3.h> |
| 33 | +#include <stdint.h> |
| 34 | + |
| 35 | +namespace ansel |
| 36 | +{ |
| 37 | + enum SetConfigurationStatus |
| 38 | + { |
| 39 | + // successfully initialized the Ansel SDK |
| 40 | + kSetConfigurationSuccess, |
| 41 | + // the version provided in the Configuration structure is not the same as the one stored inside the SDK binary (header/binary mismatch) |
| 42 | + kSetConfigurationIncompatibleVersion, |
| 43 | + // the Configuration structure supplied for the setConfiguration call is not consistent |
| 44 | + kSetConfigurationIncorrectConfiguration, |
| 45 | + // the Ansel SDK is delay loaded and setConfiguration is called before the SDK is actually loaded |
| 46 | + kSetConfigurationSdkNotLoaded |
| 47 | + }; |
| 48 | + |
| 49 | + enum FovType |
| 50 | + { |
| 51 | + kHorizontalFov, |
| 52 | + kVerticalFov |
| 53 | + }; |
| 54 | + |
| 55 | + struct Configuration |
| 56 | + { |
| 57 | + // Basis vectors used by the game. They specify the handedness and orientation of |
| 58 | + // the game's coordinate system. Think of them as the default orientation of the game |
| 59 | + // camera. |
| 60 | + nv::Vec3 right, up, forward; |
| 61 | + // The speed at which camera moves in the world |
| 62 | + float translationalSpeedInWorldUnitsPerSecond; |
| 63 | + // The speed at which camera rotates |
| 64 | + float rotationalSpeedInDegreesPerSecond; |
| 65 | + // How many frames it takes for camera update to be reflected in a rendered frame |
| 66 | + uint32_t captureLatency; |
| 67 | + // How many frames we must wait for a new frame to settle - i.e. temporal AA and similar |
| 68 | + // effects to stabilize after the camera has been adjusted |
| 69 | + uint32_t captureSettleLatency; |
| 70 | + // Game scale, the size of a world unit measured in meters |
| 71 | + float metersInWorldUnit; |
| 72 | + // Integration will support Camera::projectionOffsetX/projectionOffsetY |
| 73 | + bool isCameraOffcenteredProjectionSupported; |
| 74 | + // Integration will support Camera::position |
| 75 | + bool isCameraTranslationSupported; |
| 76 | + // Integration will support Camera::rotation |
| 77 | + bool isCameraRotationSupported; |
| 78 | + // Integration will support Camera::horizontalFov |
| 79 | + bool isCameraFovSupported; |
| 80 | + // Game name, in utf8 encoding, used to name the resulting image files from capturing. |
| 81 | + // It is not mandatory to set this field. The name chosen is based on the following |
| 82 | + // selection order: |
| 83 | + // 1. If GeForce profile exists for the game that name will be used |
| 84 | + // 2. If 'titleNameUtf8' is set that will be used |
| 85 | + // 3. The executable name is used as a last resort |
| 86 | + const char* titleNameUtf8; |
| 87 | + // Camera structure will contain vertical FOV if this is set to kVerticalFov |
| 88 | + // but horizontal FOV if this is set to kHorizontalFov. To simplify integration set |
| 89 | + // this to the same orientation as the game is using. |
| 90 | + FovType fovType; |
| 91 | + |
| 92 | + // These callbacks will be called on the same thread Present()/glSwapBuffers is called |
| 93 | + // The thread calling to updateCamera() might be a different thread |
| 94 | + |
| 95 | + // User defined pointer which is then passed to all the callbacks (nullptr by default) |
| 96 | + void* userPointer; |
| 97 | + |
| 98 | + // The window handle for the game/application where input messages are processed |
| 99 | + void* gameWindowHandle; |
| 100 | + |
| 101 | + // Called when user activates Ansel. Return kDisallowed if the game cannot comply with the |
| 102 | + // request. If the function returns kAllowed the following must be done: |
| 103 | + // 1. Change the SessionConfigruation settings, but only where you need to (the object |
| 104 | + // is already populated with default settings). |
| 105 | + // 2. On the next update loop the game will be in an Ansel session. During an Ansel session |
| 106 | + // the game : |
| 107 | + // a) Must stop drawing UI and HUD elements on the screen, including mouse cursor |
| 108 | + // b) Must call ansel::updateCamera on every frame |
| 109 | + // c) Should pause rendering time (i.e. no movement should be visible in the world) |
| 110 | + // d) Should not act on any input from mouse and keyboard and must not act on any input |
| 111 | + // from gamepads |
| 112 | + // 3. Step 2 is repeated on every iteration of update loop until Session is stopped. |
| 113 | + StartSessionCallback startSessionCallback; |
| 114 | + |
| 115 | + // Called when Ansel is deactivated. This call will only be made if the previous call |
| 116 | + // to the startSessionCallback returned kAllowed. |
| 117 | + // Normally games will use this callback to restore their camera to the settings it had |
| 118 | + // when the Ansel session was started. |
| 119 | + StopSessionCallback stopSessionCallback; |
| 120 | + |
| 121 | + // Called when the capture of a multipart shot (highres, 360, etc) has started. |
| 122 | + // Handy to disable those fullscreen effects that aren't uniform (like vignette) |
| 123 | + // This callback is optional (leave nullptr if not needed) |
| 124 | + StartCaptureCallback startCaptureCallback; |
| 125 | + // Called when the capture of a multipart shot (highres, 360, etc) has stopped. |
| 126 | + // Handy to enable those fullscreen effects that were disabled by startCaptureCallback. |
| 127 | + // This callback is optional (leave nullptr if not needed) |
| 128 | + StopCaptureCallback stopCaptureCallback; |
| 129 | + // The 'isFilterOutsideSessionAllowed' setting has been phased out in version 1.3 of the |
| 130 | + // SDK. This feature was only temporarily supported and no games took advantage of it. |
| 131 | + bool unused2; |
| 132 | + // The 'isExrSupported' setting has been phased out in version 1.1 of the SDK. Use |
| 133 | + // 'isRawAllowed' setting in SessionConfiguration to enable/disable captures into EXR |
| 134 | + // format. |
| 135 | + bool unused1; |
| 136 | + // Holds the sdk version, doesn't require modifications |
| 137 | + uint64_t sdkVersion; |
| 138 | + |
| 139 | + Configuration() |
| 140 | + { |
| 141 | + right.x = 0.0f; |
| 142 | + right.y = 1.0f; |
| 143 | + right.z = 0.0f; |
| 144 | + up.x = 0.0f; |
| 145 | + up.y = 0.0f; |
| 146 | + up.z = 1.0f; |
| 147 | + forward.x = 1.0f; |
| 148 | + forward.y = 0.0f; |
| 149 | + forward.z = 0.0f; |
| 150 | + translationalSpeedInWorldUnitsPerSecond = 1.0f; |
| 151 | + rotationalSpeedInDegreesPerSecond = 45.0f; |
| 152 | + captureLatency = 1; |
| 153 | + captureSettleLatency = 0; |
| 154 | + metersInWorldUnit = 1.0f; |
| 155 | + isCameraOffcenteredProjectionSupported = true; |
| 156 | + isCameraTranslationSupported = true; |
| 157 | + isCameraRotationSupported = true; |
| 158 | + isCameraFovSupported = true; |
| 159 | + titleNameUtf8 = nullptr; |
| 160 | + fovType = kHorizontalFov; |
| 161 | + userPointer = nullptr; |
| 162 | + gameWindowHandle = 0; |
| 163 | + startSessionCallback = nullptr; |
| 164 | + stopSessionCallback = nullptr; |
| 165 | + startCaptureCallback = nullptr; |
| 166 | + stopCaptureCallback = nullptr; |
| 167 | + unused2 = true; |
| 168 | + unused1 = false; |
| 169 | + sdkVersion = ANSEL_SDK_VERSION; |
| 170 | + } |
| 171 | + }; |
| 172 | + |
| 173 | + // Called during startup by the game. See 'Configuration' for further documentation. |
| 174 | + ANSEL_SDK_API SetConfigurationStatus setConfiguration(const Configuration& cfg); |
| 175 | + |
| 176 | + // Can be called *after* D3D device has been created to see if Ansel is available. |
| 177 | + // If called prior to D3D device creation it will always return false. |
| 178 | + // Can be called *before* calling setConfiguration in which case it'll return true if Ansel is potentially available, otherwise false. |
| 179 | + // If setConfiguration fails for any reason this function will return false (even if Ansel would be available otherwise) |
| 180 | + // until a successfull call to setConfiguration has been made. |
| 181 | + ANSEL_SDK_API bool isAnselAvailable(); |
| 182 | +} |
| 183 | + |
0 commit comments