1 | /* |
2 | * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. |
3 | * |
4 | * NVIDIA CORPORATION and its licensors retain all intellectual property |
5 | * and proprietary rights in and to this software, related documentation |
6 | * and any modifications thereto. Any use, reproduction, disclosure or |
7 | * distribution of this software and related documentation without an express |
8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. |
9 | */ |
10 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. |
11 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. |
12 | |
13 | |
14 | #ifndef PX_FOUNDATION_PX_FOUNDATION_H |
15 | #define PX_FOUNDATION_PX_FOUNDATION_H |
16 | |
17 | /** \addtogroup foundation |
18 | @{ |
19 | */ |
20 | |
21 | #include "foundation/PxVersionNumber.h" |
22 | #include "foundation/PxErrors.h" |
23 | |
24 | #ifndef PX_DOXYGEN |
25 | namespace physx |
26 | { |
27 | #endif |
28 | |
29 | class PxErrorCallback; |
30 | class PxAllocatorCallback; |
31 | class PxBroadcastingAllocator; |
32 | |
33 | /** |
34 | \brief Foundation SDK singleton class. |
35 | |
36 | You need to have an instance of this class to instance the higher level SDKs. |
37 | */ |
38 | class PX_FOUNDATION_API PxFoundation |
39 | { |
40 | public: |
41 | /** |
42 | \brief Destroys the instance it is called on. |
43 | |
44 | The operation will fail, if there are still modules referencing the foundation object. Release all dependent modules prior |
45 | to calling this method. |
46 | |
47 | @see PxCreateFoundation() |
48 | */ |
49 | virtual void release() = 0; |
50 | |
51 | /** |
52 | retrieves error callback |
53 | */ |
54 | virtual PxErrorCallback& getErrorCallback() const = 0; |
55 | |
56 | /** |
57 | Sets mask of errors to report. |
58 | */ |
59 | virtual void setErrorLevel(PxErrorCode::Enum mask = PxErrorCode::eMASK_ALL) = 0; |
60 | |
61 | /** |
62 | Retrieves mask of errors to be reported. |
63 | */ |
64 | virtual PxErrorCode::Enum getErrorLevel() const = 0; |
65 | |
66 | /** |
67 | retrieves the current allocator. |
68 | */ |
69 | virtual PxBroadcastingAllocator& getAllocator() const = 0; |
70 | |
71 | /** |
72 | Retrieves the allocator this object was created with. |
73 | */ |
74 | virtual PxAllocatorCallback& getAllocatorCallback() const = 0; |
75 | |
76 | /** |
77 | Retrieves if allocation names are being passed to allocator callback. |
78 | */ |
79 | virtual bool getReportAllocationNames() const = 0; |
80 | |
81 | /** |
82 | Set if allocation names are being passed to allocator callback. |
83 | \details Enabled by default in debug and checked build, disabled by default in profile and release build. |
84 | */ |
85 | virtual void setReportAllocationNames(bool value) = 0; |
86 | |
87 | protected: |
88 | virtual ~PxFoundation() {} |
89 | }; |
90 | |
91 | #ifndef PX_DOXYGEN |
92 | } // namespace physx |
93 | #endif |
94 | |
95 | |
96 | /** |
97 | \brief Creates an instance of the foundation class |
98 | |
99 | The foundation class is needed to initialize higher level SDKs. There may be only one instance per process. |
100 | Calling this method after an instance has been created already will result in an error message and NULL will be returned. |
101 | |
102 | \param version Version number we are expecting (should be PX_PHYSICS_VERSION) |
103 | \param allocator User supplied interface for allocating memory(see #PxAllocatorCallback) |
104 | \param errorCallback User supplied interface for reporting errors and displaying messages(see #PxErrorCallback) |
105 | \return Foundation instance on success, NULL if operation failed |
106 | |
107 | @see PxFoundation |
108 | */ |
109 | |
110 | PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation* PX_CALL_CONV PxCreateFoundation(physx::PxU32 version, |
111 | physx::PxAllocatorCallback& allocator, |
112 | physx::PxErrorCallback& errorCallback); |
113 | /** |
114 | \brief Retrieves the Foundation SDK after it has been created. |
115 | |
116 | \note The behavior of this method is undefined if the foundation instance has not been created already. |
117 | |
118 | @see PxCreateFoundation() |
119 | */ |
120 | PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation& PX_CALL_CONV PxGetFoundation(); |
121 | |
122 | /** @} */ |
123 | #endif // PX_FOUNDATION_PX_FOUNDATION_H |
124 | |