diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Samples/SampleFramework/renderer/include | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'PhysX_3.4/Samples/SampleFramework/renderer/include')
45 files changed, 3859 insertions, 0 deletions
diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/GLIncludes.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/GLIncludes.h new file mode 100644 index 00000000..25ad462b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/GLIncludes.h @@ -0,0 +1,53 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef GL_INCLUDES_H +#define GL_INCLUDES_H + +#if defined(RENDERER_WINDOWS) + #if defined(RENDERER_ENABLE_OPENGL) + #include <windows/WindowsGLIncludes.h> + #endif +#elif defined(RENDERER_PS3) + #include <ps3/PS3GLIncludes.h> +#elif defined(RENDERER_MACOSX) + #include <osx/OSXGLIncludes.h> +#elif defined(RENDERER_XBOX360) + #include <xbox360/Xbox360GLIncludes.h> +#elif defined(RENDERER_PS4) + #include <ps4/PS4GLIncludes.h> +#elif defined(RENDERER_LINUX) + #include <linux/LinuxGLIncludes.h> +#elif defined(RENDERER_ANDROID) + #include <android/AndroidGLIncludes.h> +#elif defined(RENDERER_IOS) +#else +#error Undefined platform. +#endif + + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/Renderer.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/Renderer.h new file mode 100644 index 00000000..b051e225 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/Renderer.h @@ -0,0 +1,438 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_H +#define RENDERER_H + +#include <RendererConfig.h> + +#include <RendererMaterial.h> +#include <RendererWindow.h> +#include <RendererColor.h> +#include <RendererUtils.h> +#include <SampleUserInput.h> + +#include <vector> +#include <string> +#include <queue> + +#if PX_VC +#pragma warning(push) +#pragma warning(disable:4702) +#include <map> +#pragma warning(pop) +#else +#include <map> +#endif + +#include "foundation/PxVec2.h" +#include "foundation/PxProfiler.h" + +namespace SampleRenderer +{ + + class RendererDesc; + class RendererWindow; + class RendererVertexBuffer; + class RendererVertexBufferDesc; + class RendererIndexBuffer; + class RendererIndexBufferDesc; + class RendererSurfaceBuffer; + class RendererSurfaceBufferDesc; + class RendererInstanceBuffer; + class RendererInstanceBufferDesc; + class RendererTexture; + class RendererTextureDesc; + class RendererTarget; + class RendererTargetDesc; + class RendererMaterial; + class RendererMaterialDesc; + class RendererMesh; + class RendererMeshDesc; + class RendererMeshContext; + class RendererLight; + class RendererLightDesc; + + class RendererColor; + class RendererProjection; + + class ScreenQuad + { + public: + ScreenQuad(); + + RendererColor mLeftUpColor; //!< Color for left-up vertex + RendererColor mLeftDownColor; //!< Color for left-down vertex + RendererColor mRightUpColor; //!< Color for right-up vertex + RendererColor mRightDownColor; //!< Color for right-down vertex + PxReal mAlpha; //!< Alpha value + PxReal mX0, mY0; //!< Up-left coordinates + PxReal mX1, mY1; //!< Bottom-right coordinates + }; + + class Renderer + { + public: + struct TextVertex + { + PxVec3 p; + PxReal rhw; + PxU32 color; + PxReal u,v; + }; + + struct TessellationParams + { + TessellationParams(); + + void setDefault(); + std::string toString(); + + PxVec4 tessFactor; + PxReal tessMinMaxDistance[2]; + PxReal tessHeightScaleAndBias[2]; + PxReal tessUVScale[2]; + }; + + typedef enum DriverType + { + DRIVER_OPENGL = 0, // Supports Windows, Linux, MacOSX and PS3. + DRIVER_GLES2, // Supports Android (> 2.2) and iPhone. + DRIVER_DIRECT3D9, // Supports Windows, XBOX360. + DRIVER_LIBGCM, // Supports PS3, currently unused (PS3 uses OpenGL) + DRIVER_LIBGNM, // Supports PS4 + DRIVER_DIRECT3D11, // Supports Windows 7/Vista. + DRIVER_NULL, + } DriverType; + + public: + // assetDir should point to the directory where shaders can be found in the assetDir/shaders/ subdirectory and textures are in assetDir/textures + // enableMaterialCaching will try to compile as few shaders as possible + static Renderer *createRenderer(const RendererDesc &desc, const char* assetDir, bool enableMaterialCaching = true); + + static const char *getDriverTypeName(DriverType type); + + protected: + Renderer(DriverType driver, PxErrorCallback* errorCallback, const char* shaderDir); + virtual ~Renderer(void); + + public: + void release(void); + + // get the driver type for this renderer. + DriverType getDriverType(void) const; + + // get the offset to the center of a pixel relative to the size of a pixel (so either 0 or 0.5). + PxF32 getPixelCenterOffset(void) const; + + // get the name of the hardware device. + const char *getDeviceName(void) const; + + // adds a mesh to the render queue. + void queueMeshForRender(RendererMeshContext &mesh); + void removeMeshFromRenderQueue(RendererMesh& mesh); + + // adds a light to the render queue. + void queueLightForRender(RendererLight &light); + void removeLightFromRenderQueue(RendererLight &light); + + // renders the current scene to the offscreen buffers. empties the render queue when done. + void render(const physx::PxMat44 &eye, const RendererProjection &proj, RendererTarget *target=0, bool depthOnly=false); + + // sets fog + void setFog(const RendererColor &fogColor, float fogDistance); + + // sets the ambient lighting color. + void setAmbientColor(const RendererColor &ambientColor); + // get the ambient lighting color. + RendererColor getAmbientColor(); + + // sets the clear color. + void setClearColor(const RendererColor &clearColor); + RendererColor& getClearColor() { return m_clearColor; } + + // sets whether tessellation is enabled. must be supported by the underlying renderer implementation + void setEnableTessellation(bool enable) { m_enableTessellation = enable && isTessellationSupported(); } + bool getEnableTessellation() const { return m_enableTessellation; } + virtual bool isTessellationSupported(void) const { return false; } + + // sets appropriate tessellation parameters + void setTessellationParams(const TessellationParams&); + TessellationParams& getTessellationParams() { return m_tessellationParams; } + + // sets whether wireframe mode is enabled + void toggleWireframe() { m_enableWireframe = !m_enableWireframe; } + bool wireframeEnabled() const { return m_enableWireframe; } + + // sets whether to override the blending of individual meshes + void setEnableBlendingOverride(bool enable) { m_enableBlendingOverride = enable; } + bool blendingOverrideEnabled() const { return m_enableBlendingOverride; } + + // sets whether to use culling on meshes with blending + void setEnableBlendingCull(bool enable) { m_enableBlendingCull = enable; } + bool blendingCull() const { return m_enableBlendingCull; } + + // get and set the output message stream + void setErrorCallback(PxErrorCallback* errc) { m_errorCallback = errc; } + PxErrorCallback* getErrorCallback() { return m_errorCallback; } + + // sprite renderer is not available on dx11 feature level dx9 + virtual bool isSpriteRenderingSupported(void) const { return true; } + + // clears the offscreen buffers. + virtual void clearBuffers(void) = 0; + + // presents the current color buffer to the screen. + // returns true on device reset and if buffers need to be rewritten. + virtual bool swapBuffers(void) = 0; + + // get the device pointer (void * abstraction) + virtual void *getDevice() = 0; + + // save the screen data to disk + virtual bool captureScreen(const char* filename); + + // gets a handle to the current frame's data, in bitmap format + // note: subsequent calls will invalidate any previously returned data + virtual bool captureScreen(PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData) = 0; + + virtual void getWindowSize(PxU32 &width, PxU32 &height) const = 0; + + virtual PxU32 convertColor(const RendererColor& color) const = 0; + virtual void finishRendering() {} + + virtual RendererVertexBuffer *createVertexBuffer( const RendererVertexBufferDesc &desc) = 0; + virtual RendererIndexBuffer *createIndexBuffer( const RendererIndexBufferDesc &desc) = 0; +// virtual RendererSurfaceBuffer *createSurfaceBuffer( const RendererSurfaceBufferDesc &desc) = 0; + virtual RendererInstanceBuffer *createInstanceBuffer(const RendererInstanceBufferDesc &desc) = 0; + virtual RendererTexture *createTexture( const RendererTextureDesc &desc); + virtual RendererTexture2D *createTexture2D( const RendererTexture2DDesc &desc) = 0; + virtual RendererTexture3D *createTexture3D( const RendererTexture3DDesc &desc) = 0; + virtual RendererTarget *createTarget( const RendererTargetDesc &desc) = 0; + virtual RendererMaterial *createMaterial( const RendererMaterialDesc &desc) = 0; + virtual RendererMesh *createMesh( const RendererMeshDesc &desc) = 0; + virtual RendererLight *createLight( const RendererLightDesc &desc) = 0; + + virtual void disableDepthTest() {} + virtual void enableDepthTest() {} + + // These two methods are only necessary for internal caching of compiled materials + bool getEnableMaterialCaching() { return mEnableMaterialCaching; } + + virtual void setVsync(bool on) = 0; + protected: + void setEnableMaterialCaching(bool enable) { mEnableMaterialCaching = enable; } + RendererMaterial *hasMaterialAlready( const RendererMaterialDesc& desc); + void registerMaterial( const RendererMaterialDesc& desc, RendererMaterial* mat); + void releaseAllMaterials(); + + void formatScreenshot(PxU32 width, PxU32 height, PxU32 sizeInBytes, int rPosition, int gPosition, int bPosition, bool bFlipY, void* screenshotData); + public: + + // Text rendering + virtual bool initTexter(); + virtual void closeTexter(); + void print(PxU32 x, PxU32 y, const char* text, PxReal scale=0.5f, PxReal shadowOffset=6.0f, RendererColor textColor = RendererColor(255, 255, 255, 255), bool forceFixWidthNumbers = false); + void print(PxU32* x, PxU32* y, const char** text, PxU32 textCount, PxReal scale=0.5f, PxReal shadowOffset=6.0f, RendererColor* textColors = NULL, bool forceFixWidthNumbers = false); + const char* getAssetDir(); + + // assetDir should point to the directory where shaders can be found in the assetDir/shaders/ subdirectory and textures are in assetDir/textures + void setAssetDir( const char * assetDir ); + + void setCacheShaderDir( const char * cacheDir ) { m_cacheDir = cacheDir; } + const char* getCacheShaderDir() { return m_cacheDir; } + // On-screen controls/sticks for tablets +#if defined(RENDERER_TABLET) + struct TabletButton + { + PxVec2 leftBottom; + PxVec2 rightTop; + physx::PxU8 pressedCount; + physx::PxU16 emulatedKeyCode; + std::string text; + RendererMesh* mesh; + RendererMaterial* material; + RendererMaterialInstance* materialInstance; + + PxVec4 defaultColor, pressedColor; + + void (*callback)(); + + TabletButton(); + void setPressedCount(physx::PxU8); + void incPressed(); + void decPressed(); + }; + + virtual bool initControls(RendererMaterial* controlMaterial, RendererMaterialInstance* controlMaterialInstance); + void setControlPosition(int ctrl_idx, const PxVec2&); + void setControlDefaultPosition(int ctrl_idx); + PxBounds3 getControlBounds(int ctrl_idx); + PxBounds3 getCenteredControlBounds(int ctrl_idx); + PxVec2 getControlPosition(int ctrl_idx); + PxVec2 getCenteredControlPosition(int ctrl_idx); + // On-screen buttons for tablets + void addButton(const PxVec2& leftBottom, + const PxVec2& rightTop, + void (*func_ptr)(), + RendererMaterial* controlMaterial, + RendererMaterialInstance* controlMaterialInstance); + void releaseAllButtons(); + void bindButtonToUserInput(size_t buttonIndex, physx::PxU16 userInputId, const char* buttonName); + std::vector<TabletButton>& screenButtons(); +#endif + + // Screenquad + virtual bool initScreenquad(); + virtual void closeScreenquad(); + bool drawScreenQuad(const ScreenQuad& screenQuad); + bool drawTouchControls(); + bool drawLines2D(PxU32 nbVerts, const PxReal* vertices, const RendererColor& color); + bool drawLines2D(PxU32 nbVerts, const PxReal* vertices, const RendererColor* colors); + + private: + void renderMeshes(std::vector<RendererMeshContext>& meshes, RendererMaterial::Pass pass); + void renderDeferredLights(void); + void sortMeshes(const physx::PxMat44& eye); + + private: + RendererMesh* initControl(PxReal* vertices, PxReal* texcoords, PxU32 verticesCount); + friend class ScopedRender; + virtual bool beginRender(void) { return true;} + virtual void endRender(void) {} + virtual void bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj) = 0; + virtual void bindFogState(const RendererColor &fogColor, float fogDistance) = 0; + virtual void bindAmbientState(const RendererColor &ambientColor) = 0; + virtual void bindDeferredState(void) = 0; + virtual void bindMeshContext(const RendererMeshContext &context) = 0; + virtual void beginMultiPass(void) = 0; + virtual void endMultiPass(void) = 0; + virtual void beginTransparentMultiPass(void) = 0; + virtual void endTransparentMultiPass(void) = 0; + virtual void renderDeferredLight(const RendererLight &light) = 0; + + virtual bool isOk(void) const = 0; + + public: + virtual void setupTextRenderStates() = 0; + virtual void resetTextRenderStates() = 0; + virtual void renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material) = 0; + virtual void renderLines2D(const void* vertices, PxU32 nbVerts) = 0; + +#if defined(RENDERER_TABLET) + void renderControls(); + void renderButtons(); +#endif + virtual void setupScreenquadRenderStates() = 0; + virtual void resetScreenquadRenderStates() = 0; + + private: + Renderer &operator=(const Renderer&) { return *this; } + + + const DriverType m_driver; + + protected: + PxErrorCallback* m_errorCallback; + // Texter data + RendererMaterial* m_textMaterial; + RendererMaterialInstance* m_textMaterialInstance; + + private: + typedef std::vector<RendererMeshContext> MeshVector; + MeshVector m_visibleLitMeshes; + MeshVector m_visibleUnlitMeshes; + MeshVector m_screenSpaceMeshes; + MeshVector m_visibleLitTransparentMeshes; + + //std::priority_queue<RendererMeshContext, MeshVector, CompareMeshCameraDistance> m_visibleLitTransparentMeshes; + std::vector<RendererLight*> m_visibleLights; + + RendererColor m_fogColor; + float m_fogDistance; + + RendererColor m_ambientColor; + RendererColor m_clearColor; + + // Screenquad data + RendererMaterial* m_screenquadOpaqueMaterial; + RendererMaterialInstance* m_screenquadOpaqueMaterialInstance; + RendererMaterial* m_screenquadAlphaMaterial; + RendererMaterialInstance* m_screenquadAlphaMaterialInstance; + +#if defined(RENDERER_TABLET) + RendererMaterial* m_controlMaterial; + RendererMaterialInstance* m_controlMaterialInstance; + RendererMesh* m_controlMesh[2]; + PxVec2 m_controlHalfSize; + PxVec2 m_controlCenteredPos[2]; + PxVec2 m_controlPos[2]; + std::vector<TabletButton> m_buttons; +#endif + + protected: + PxF32 m_pixelCenterOffset; + char m_deviceName[256]; + bool m_useShadersForTextRendering; + std::string m_assetDir; + const char* m_cacheDir; + + // Tessellation data + TessellationParams m_tessellationParams; + bool m_enableTessellation; + + bool m_enableWireframe; + bool m_enableBlendingOverride; + bool m_enableBlendingCull; + + bool mEnableMaterialCaching; + struct CompareRenderMaterialDesc + { + bool operator()(const RendererMaterialDesc& desc1, const RendererMaterialDesc& desc2) const; + }; + typedef std::map<RendererMaterialDesc, RendererMaterial*, CompareRenderMaterialDesc> tMaterialCache; + tMaterialCache m_materialCache; + }; + + // Ensure that endRender() is called after each successful beginRender() + class ScopedRender : public safe_bool<> + { + public: + ScopedRender(Renderer& renderer) : mRenderer(renderer), mBeginRenderSuccessful(mRenderer.beginRender()) { } + ~ScopedRender() { if (boolean_test()) mRenderer.endRender(); } + ScopedRender& operator=(const ScopedRender&) {return *this;} + + bool boolean_test() const { return mBeginRenderSuccessful; } + + protected: + Renderer& mRenderer; + bool mBeginRenderSuccessful; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererBoxShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererBoxShape.h new file mode 100644 index 00000000..d08f5eb9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererBoxShape.h @@ -0,0 +1,55 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +// +// RendererBoxShape : convenience class for generating a box mesh. +// +#ifndef RENDERER_BOX_SHAPE_H +#define RENDERER_BOX_SHAPE_H + +#include <RendererShape.h> + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + class RendererIndexBuffer; + + class RendererBoxShape : public RendererShape + { + public: + RendererBoxShape(Renderer &renderer, const PxVec3 &extents, const PxReal* uvs=NULL); + virtual ~RendererBoxShape(void); + + private: + RendererVertexBuffer *m_vertexBuffer; + RendererIndexBuffer *m_indexBuffer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererCapsuleShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererCapsuleShape.h new file mode 100644 index 00000000..9dbcf3e2 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererCapsuleShape.h @@ -0,0 +1,60 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +// +// RendererCapsuleShape : convenience class for generating a capsule mesh. +// +#ifndef RENDERER_CAPSULE_SHAPE_H +#define RENDERER_CAPSULE_SHAPE_H + +#include <RendererShape.h> +#include <RendererBoxShape.h> + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + class RendererIndexBuffer; + + class RendererCapsuleShape : public RendererShape + { + public: + RendererCapsuleShape(Renderer &renderer, PxF32 halfHeight, PxF32 radius); + + // resize the capsule + void setDimensions(PxF32 halfHeight, PxF32 radius0, PxF32 radius1); + + virtual ~RendererCapsuleShape(void); + + private: + RendererVertexBuffer *m_vertexBuffer; + RendererIndexBuffer *m_indexBuffer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererClothShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererClothShape.h new file mode 100644 index 00000000..d93817eb --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererClothShape.h @@ -0,0 +1,88 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_CLOTH_SHAPE_H +#define RENDERER_CLOTH_SHAPE_H + +#include <RendererShape.h> +#include "gpu/PxGpu.h" + +// fwd to avoid including cuda.h +#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) +typedef unsigned long long CUdeviceptr; +#else +typedef unsigned int CUdeviceptr; +#endif + + +namespace SampleRenderer +{ + class RendererVertexBuffer; + class RendererIndexBuffer; + + class RendererClothShape : public RendererShape + { + enum VertexBufferEnum + { + STATIC_VB, + DYNAMIC_VB, + NUM_VERTEX_BUFFERS + }; + public: + RendererClothShape(Renderer& renderer, + const PxVec3* verts, PxU32 numVerts, + const PxVec3* normals, + const PxReal* uvs, + const PxU16* faces, PxU32 numFaces, bool flipWinding=false, + PxCudaContextManager* ctxMgr=NULL); + + // must acquire the cuda context and map buffers before calling + bool update(CUdeviceptr srcVerts, PxU32 numVerts); + void update(const PxVec3* verts, PxU32 numVerts, const PxVec3* normals); + + // helper functions to map the buffers for multiple shapes + // at once because interop mapping has a large per-call overhead + // thread must acquire the cuda context before calling + static void mapShapes(RendererClothShape** shapes, PxU32 n); + static void unmapShapes(RendererClothShape** shapes, PxU32 n); + + virtual ~RendererClothShape(); + + bool isInteropEnabled() const { return m_ctxMgr != NULL; } + + private: + RendererVertexBuffer* m_vertexBuffer[NUM_VERTEX_BUFFERS]; + RendererIndexBuffer* m_indexBuffer; + + PxU32 m_numFaces; + + PxCudaContextManager* m_ctxMgr; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererColor.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererColor.h new file mode 100644 index 00000000..de1dc37c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererColor.h @@ -0,0 +1,67 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_COLOR_H +#define RENDERER_COLOR_H + +#include <RendererConfig.h> + +namespace SampleRenderer +{ + + class RendererColor + { + public: + + // use the API color format for OpenGL platforms +#if !(defined(RENDERER_PS3) || defined(RENDERER_ANDROID)) + PxU8 b, g, r, a; +#else + PxU8 r, g, b, a; +#endif + + public: + RendererColor(void); + RendererColor(PxU8 r, PxU8 g, PxU8 b, PxU8 a = 255); + + // conversion constructor, format must be 0xAARRGGBB (but alpha is ignored) + RendererColor(PxU32 rgba); + void swizzleRB(void); + }; + + PX_INLINE RendererColor lerp( const RendererColor& start, const RendererColor& end, float s ) + { + return RendererColor( + start.r + PxU8(( end.r - start.r ) * s), + start.g + PxU8(( end.g - start.g ) * s), + start.b + PxU8(( end.b - start.b ) * s), + start.a + PxU8(( end.a - start.a ) * s)); + } + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererConfig.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererConfig.h new file mode 100644 index 00000000..e8d1c7b4 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererConfig.h @@ -0,0 +1,277 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_CONFIG_H +#define RENDERER_CONFIG_H + +#include <RendererFoundation.h> +#include <assert.h> + +#define RENDERER_TEXT(_foo) #_foo +#define RENDERER_TEXT2(_foo) RENDERER_TEXT(_foo) + +// number of lights required before it switches from forward rendering to deferred rendering. +#define RENDERER_DEFERRED_THRESHOLD 0x7FFFFFFF // set to a big number just to disable it for now... + +// Enables/Disables support for dresscode in the renderer... +#define RENDERER_ENABLE_DRESSCODE 0 + +// If turned on, asserts get compiled in as print statements in release mode. +#define RENDERER_ENABLE_CHECKED_RELEASE 0 + +// If enabled, all lights will be bound in a single pass. Requires appropriate shader support. +#define RENDERER_ENABLE_SINGLE_PASS_LIGHTING 0 + +// maximum number of bones per-drawcall allowed. +#define RENDERER_MAX_BONES 60 + +#define RENDERER_TANGENT_CHANNEL 5 +#define RENDERER_BONEINDEX_CHANNEL 6 +#define RENDERER_BONEWEIGHT_CHANNEL 7 +#define RENDERER_INSTANCE_POSITION_CHANNEL 8 +#define RENDERER_INSTANCE_NORMALX_CHANNEL 9 +#define RENDERER_INSTANCE_NORMALY_CHANNEL 10 +#define RENDERER_INSTANCE_NORMALZ_CHANNEL 11 +#define RENDERER_INSTANCE_VEL_LIFE_CHANNEL 12 +#define RENDERER_INSTANCE_DENSITY_CHANNEL 13 + +#define RENDERER_INSTANCE_UV_CHANNEL 12 +#define RENDERER_INSTANCE_LOCAL_CHANNEL 13 + +#define RENDERER_DISPLACEMENT_CHANNEL 14 +#define RENDERER_X_DISPLACEMENT_CHANNEL 13 +#define RENDERER_Y_DISPLACEMENT_CHANNEL 14 +#define RENDERER_Z_DISPLACEMENT_CHANNEL 15 +#define RENDERER_DISPLACEMENT_FLAGS_CHANNEL 15 + +// Compiler specific configuration... +#if defined(_MSC_VER) +#define RENDERER_VISUALSTUDIO +#pragma warning(disable : 4127) // conditional expression is constant +#pragma warning(disable : 4100) // unreferenced formal parameter + +#elif defined(__ghs__) + #define RENDERER_GHS +#elif defined(__GNUC__) + #define RENDERER_GCC +#else +#error Unknown Compiler! + +#endif + +#if PX_PS4 +#pragma clang diagnostic push +// variadic macros are incompatible with C++98 +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +// Platform specific configuration... +#if defined(WIN32) || defined(WIN64) || defined(_M_ARM) || PX_XBOXONE + #define RENDERER_WINDOWS +#if !PX_XBOXONE + #define RENDERER_ENABLE_DIRECT3D9 +#endif + #define RENDERER_ENABLE_DIRECT3D11 + #define RENDERER_ENABLE_NVPERFHUD + #define RENDERER_ENABLE_TGA_SUPPORT + #if !defined(RENDERER_PVD) && !PX_XBOXONE && PX_SUPPORT_GPU_PHYSX + //Removed this to get PhysX distro working without shipping CUDA. + //#define RENDERER_ENABLE_CUDA_INTEROP + #endif + #define DIRECT3D9_SUPPORT_D3DUSAGE_DYNAMIC + #if defined(WIN64) + #define RENDERER_64BIT + #endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#define NOMINMAX +#include <windows.h> +#elif defined(__APPLE__) && !defined(__arm__) && !defined(__arm64__) +#define RENDERER_MACOSX +#define RENDERER_ENABLE_OPENGL +#define RENDERER_ENABLE_CG +#if !PX_PPC +#define RENDERER_ENABLE_TGA_SUPPORT +#endif + +#elif defined(_XBOX) && _XBOX_VER == 200 +#define RENDERER_XBOX360 +#define RENDERER_ENABLE_DIRECT3D9 +#define NOMINMAX +#define RENDERER_ENABLE_TGA_SUPPORT +#define RENDERER_BIG_ENDIAN + +#elif PX_PS4 + #define RENDERER_PS4 + #define RENDERER_ENABLE_LIBGNM + #define RENDERER_ENABLE_CG + #define RENDERER_ENABLE_TGA_SUPPORT + +#elif defined(__CYGWIN__) +#define RENDERER_LINUX +#define RENDERER_ENABLE_OPENGL +#define RENDERER_ENABLE_CG +#define RENDERER_ENABLE_TGA_SUPPORT + +#elif defined(ANDROID) + #define RENDERER_DEBUG + #define RENDERER_ANDROID + #define RENDERER_TABLET + #define RENDERER_ENABLE_GLES2 + #define RENDERER_ENABLE_TGA_SUPPORT + +#elif defined(__linux__) + #define RENDERER_LINUX + #define RENDERER_ENABLE_OPENGL + #define RENDERER_ENABLE_CG + #define RENDERER_ENABLE_TGA_SUPPORT + +#elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) + #define RENDERER_DEBUG + #define RENDERER_IOS + #define RENDERER_TABLET + #define RENDERER_ENABLE_GLES2 + #define RENDERER_ENABLE_TGA_SUPPORT + #define RENDERER_ENABLE_PVR_SUPPORT + +#elif defined(RENDERER_GHS) + #define RENDERER_WIIU + #define RENDERER_ENABLE_GX2 + #define RENDERER_ENABLE_TGA_SUPPORT + #define RENDERER_BIG_ENDIAN + +#else +#error "Unknown Platform!" + +#endif + +#if PX_DEBUG +#define RENDERER_DEBUG +#endif + + +#if defined(RENDERER_DEBUG) + #if defined(RENDERER_WINDOWS) && !PX_XBOXONE + #define RENDERER_ASSERT(_exp, _msg) \ + if(!(_exp)) \ + { \ + MessageBoxA(0, _msg, "Renderer Assert", MB_OK); \ + __debugbreak(); \ + } + #elif defined(RENDERER_ANDROID) + #include <android/log.h> + #define RENDERER_ASSERT(_exp, _msg) \ + if(!(_exp)) \ + __android_log_print(ANDROID_LOG_INFO, _msg, "RENDERER_ASSERT: %s\n", #_exp);\ + assert(_exp && (_msg)); + #else + #define RENDERER_ASSERT(_exp, _msg) assert(_exp && (_msg)); + #endif +#elif RENDERER_ENABLE_CHECKED_RELEASE +#if defined(RENDERER_VISUALSTUDIO) +#define RENDERER_ASSERT(_exp, _msg) \ + if(!(_exp)) \ + { \ + OutputDebugStringA("*** (" __FILE__":"RENDERER_TEXT2(__LINE__)") "); \ + OutputDebugStringA(_msg); \ + OutputDebugStringA(" ***\n"); \ + } +#else +#define RENDERER_ASSERT(_exp, _msg) if(!(_exp)) shdfnd::printFormatted("*** (" __FILE__ ":" RENDERER_TEXT2(__LINE__)") %s ***\n", _msg); +#endif +#else +#define RENDERER_ASSERT(_exp, _msg) +#endif + +#define RENDERER_OUTPUT_MESSAGE(_rendererPtr, _msg) \ + if((_rendererPtr) && (_rendererPtr)->getErrorCallback()) \ + { \ + (_rendererPtr)->getErrorCallback()->reportError(PxErrorCode::eDEBUG_INFO, (_msg), __FILE__, __LINE__); \ + } + + +#if defined(RENDERER_ANDROID) + #include <android/log.h> + #define LOG_INFO(title, ...) ((void)__android_log_print(ANDROID_LOG_INFO, title, __VA_ARGS__)) +#else + +#if 0 + #include <stdio.h> + #include <stdarg.h> + + static void printInfo(const char* title, const char* message, ...) + { + char buff[4096]; + + shdfnd::printFormatted("%s ", title); + va_list va; + va_start(va, message); + vsprintf(buff, message, va); + va_end(va); + if (strlen(buff)>=4096) + assert(!"buffer overflow!!"); + + shdfnd::printFormatted("%s\n", buff); + } + + #define LOG_INFO(title, ...) (printInfo(title, __VA_ARGS__)) +#else + #define LOG_INFO(title, ...) +#endif + +#endif + +#if defined(RENDERER_XBOX360) +#define RENDERER_INSTANCING 0 +#else +#define RENDERER_INSTANCING 1 +#endif + +namespace SampleRenderer +{ + // 2D and 3D Textures have identical external interfaces + // Using a typedef provides compatibility with legacy code that used only 2D textures + class RendererTexture; + class RendererTextureDesc; + typedef RendererTexture RendererTexture2D; + typedef RendererTextureDesc RendererTexture2DDesc; + typedef RendererTexture RendererTexture3D; + typedef RendererTextureDesc RendererTexture3DDesc; +} +#if defined(RENDERER_ANDROID) && !defined(LOGI) +# include <android/log.h> +# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "RendererConfig", __VA_ARGS__)) +#else +# define LOGI(...) LOG_INFO("LOGI: ", __VA_ARGS__) +#endif + +#if PX_PS4 +#pragma clang diagnostic pop +#endif + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDesc.h new file mode 100644 index 00000000..8fa8c9da --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDesc.h @@ -0,0 +1,60 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_DESC_H +#define RENDERER_DESC_H + +#include <RendererConfig.h> +#include <Renderer.h> + +namespace SampleRenderer +{ + + class RendererWindow; + + class RendererDesc + { + public: + Renderer::DriverType driver; + + /* optional error callback */ + PxErrorCallback* errorCallback; + physx::PxU64 windowHandle; + + bool vsync; + + /* enable depth bias for multipass rendering */ + bool multipassDepthBias; + public: + RendererDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDirectionalLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDirectionalLight.h new file mode 100644 index 00000000..900614e5 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDirectionalLight.h @@ -0,0 +1,54 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_DIRECTIONAL_LIGHT_H +#define RENDERER_DIRECTIONAL_LIGHT_H + +#include <RendererLight.h> + +namespace SampleRenderer +{ + + class RendererDirectionalLightDesc; + + class RendererDirectionalLight : public RendererLight + { + protected: + RendererDirectionalLight(const RendererDirectionalLightDesc &desc); + virtual ~RendererDirectionalLight(void); + + public: + const PxVec3 &getDirection(void) const; + void setDirection(const PxVec3 &dir); + + protected: + PxVec3 m_direction; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDirectionalLightDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDirectionalLightDesc.h new file mode 100644 index 00000000..ee608356 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererDirectionalLightDesc.h @@ -0,0 +1,49 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_DIRECTIONAL_LIGHT_DESC_H +#define RENDERER_DIRECTIONAL_LIGHT_DESC_H + +#include <RendererLightDesc.h> + +namespace SampleRenderer +{ + + class RendererDirectionalLightDesc : public RendererLightDesc + { + public: + PxVec3 direction; + + public: + RendererDirectionalLightDesc(void); + + virtual bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererFoundation.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererFoundation.h new file mode 100644 index 00000000..ed56285c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererFoundation.h @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_FOUNDATION_H +#define RENDERER_FOUNDATION_H + +#include <stdio.h> +#include "foundation/PxPreprocessor.h" +#include "task/PxTask.h" + +namespace physx +{ + namespace shdfnd{} +} + +namespace SampleRenderer +{ + using namespace physx; + namespace Fnd = physx::shdfnd; + + typedef ::FILE File; + +} // namespace Renderer + +#include <foundation/PxSimpleTypes.h> +#include <foundation/PxVec3.h> +#include <foundation/PxMat33.h> +#include <foundation/PxMat44.h> +#include <foundation/PxTransform.h> +#include <foundation/PxErrorCallback.h> + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererGridShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererGridShape.h new file mode 100644 index 00000000..383a98e8 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererGridShape.h @@ -0,0 +1,63 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +// +// RendererGridShape : convenience class for generating a grid mesh. +// +#ifndef RENDERER_GRID_SHAPE_H +#define RENDERER_GRID_SHAPE_H + +#include <RendererShape.h> + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + + class RendererGridShape : public RendererShape + { + public: + enum UpAxis + { + UP_X, + UP_Y, + UP_Z, + }; + + RendererGridShape(Renderer &renderer, PxU32 size, float cellSize, bool showAxis = false, UpAxis = UP_Y); + virtual ~RendererGridShape(void); + + UpAxis getUpAxis() { return m_UpAxis; } + + private: + RendererVertexBuffer *m_vertexBuffer; + UpAxis m_UpAxis; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererIndexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererIndexBuffer.h new file mode 100644 index 00000000..28d84718 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererIndexBuffer.h @@ -0,0 +1,90 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_INDEXBUFFER_H +#define RENDERER_INDEXBUFFER_H + +#include <RendererConfig.h> +#include "RendererInteropableBuffer.h" + +namespace SampleRenderer +{ + + class RendererIndexBufferDesc; + + class RendererIndexBuffer: public RendererInteropableBuffer + { + friend class RendererMesh; + friend class GLES2Renderer; + public: + enum Format + { + FORMAT_UINT16 = 0, + FORMAT_UINT32, + + NUM_FORMATS + }_Format; + + enum Hint + { + HINT_STATIC = 0, + HINT_DYNAMIC, + }_Hint; + + public: + static PxU32 getFormatByteSize(Format format); + + protected: + RendererIndexBuffer(const RendererIndexBufferDesc &desc); + virtual ~RendererIndexBuffer(void); + + public: + void release(void) { delete this; } + + Hint getHint(void) const; + Format getFormat(void) const; + PxU32 getMaxIndices(void) const; + + public: + virtual void *lock(void) = 0; + virtual void unlock(void) = 0; + + private: + virtual void bind(void) const = 0; + virtual void unbind(void) const = 0; + + RendererIndexBuffer &operator=(const RendererIndexBuffer &) { return *this; } + + protected: + const Hint m_hint; + const Format m_format; + PxU32 m_maxIndices; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererIndexBufferDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererIndexBufferDesc.h new file mode 100644 index 00000000..dda9ec78 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererIndexBufferDesc.h @@ -0,0 +1,59 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_INDEXBUFFER_DESC_H +#define RENDERER_INDEXBUFFER_DESC_H + +#include <RendererIndexBuffer.h> + +namespace SampleRenderer +{ + + class RendererIndexBufferDesc + { + public: + RendererIndexBuffer::Hint hint; + RendererIndexBuffer::Format format; + + PxU32 maxIndices; + + ///mark this buffer can be read back by lock, lock flag should not be discard + bool canReadBack; + ///choose if the resource must be registered in CUDA upon creation + bool registerInCUDA; + ///This context must be used to register and unregister the resource everytime the device is lost and recreated + physx::PxCudaContextManager *interopContext; + + public: + RendererIndexBufferDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInstanceBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInstanceBuffer.h new file mode 100644 index 00000000..041c61fa --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInstanceBuffer.h @@ -0,0 +1,130 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_INSTANCEBUFFER_H +#define RENDERER_INSTANCEBUFFER_H + +#include <RendererConfig.h> +#include "RendererInteropableBuffer.h" + +namespace SampleRenderer +{ + + class RendererInstanceBufferDesc; + + class RendererInstanceBuffer: public RendererInteropableBuffer + { + friend class RendererMesh; + public: + enum Semantic + { + SEMANTIC_POSITION = 0, + SEMANTIC_NORMALX, + SEMANTIC_NORMALY, + SEMANTIC_NORMALZ, + SEMANTIC_VELOCITY_LIFE,// life remain (0-1] is packed into w + SEMANTIC_DENSITY, + SEMANTIC_UV_OFFSET, + SEMANTIC_LOCAL_OFFSET, + + NUM_SEMANTICS + }_Semantic; + + enum Format + { + FORMAT_FLOAT1 = 0, + FORMAT_FLOAT2, + FORMAT_FLOAT3, + FORMAT_FLOAT4, + + NUM_FORMATS, + }_Format; + + enum Hint + { + HINT_STATIC = 0, + HINT_DYNAMIC, + }_Hint; + + public: + static PxU32 getFormatByteSize(Format format); + + protected: + RendererInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual ~RendererInstanceBuffer(void); + + public: + void release(void) { delete this; } + + Hint getHint(void) const; + Format getFormatForSemantic(Semantic semantic) const; + PxU32 getMaxInstances(void) const; + PxU32 getOffsetForSemantic(Semantic semantic) const; + + void *lockSemantic(Semantic semantic, PxU32 &stride); + void unlockSemantic(Semantic semantic); + + virtual void *lock(void) = 0; + virtual void unlock(void) = 0; + virtual PxU32 getStride(void) const { return m_stride; } + private: + + virtual void bind(PxU32 streamID, PxU32 firstInstance) const = 0; + virtual void unbind(PxU32 streamID) const = 0; + + RendererInstanceBuffer &operator=(const RendererInstanceBuffer &) { return *this; } + + protected: + class SemanticDesc + { + public: + Format format; + PxU32 offset; + bool locked; + public: + SemanticDesc(void) + { + format = NUM_FORMATS; + offset = 0; + locked = false; + } + }; + + protected: + const Hint m_hint; + PxU32 m_maxInstances; + PxU32 m_stride; + SemanticDesc m_semanticDescs[NUM_SEMANTICS]; + + private: + void *m_lockedBuffer; + PxU32 m_numSemanticLocks; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInstanceBufferDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInstanceBufferDesc.h new file mode 100644 index 00000000..50d594dd --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInstanceBufferDesc.h @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_INSTANCEBUFFER_DESC_H +#define RENDERER_INSTANCEBUFFER_DESC_H + +#include <RendererInstanceBuffer.h> + +namespace SampleRenderer +{ + + class RendererInstanceBufferDesc + { + public: + RendererInstanceBuffer::Hint hint; + RendererInstanceBuffer::Format semanticFormats[RendererInstanceBuffer::NUM_SEMANTICS]; + + PxU32 maxInstances; + + ///mark this buffer can be read back by lock, lock flag should not be discard + bool canReadBack; + + bool registerInCUDA; + physx::PxCudaContextManager *interopContext; + + public: + RendererInstanceBufferDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInteropableBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInteropableBuffer.h new file mode 100644 index 00000000..74387672 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererInteropableBuffer.h @@ -0,0 +1,73 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_INTEROPABLE_BUFFER_H +#define RENDERER_INTEROPABLE_BUFFER_H + +#include <RendererConfig.h> +#include "cudamanager/PxCudaContextManager.h" + +typedef struct CUgraphicsResource_st *CUgraphicsResource; + +namespace SampleRenderer +{ + + class RendererInteropableBuffer + { + public: + RendererInteropableBuffer(bool mustBeRegistered, physx::PxCudaContextManager *interopContext) + : m_mustBeRegisteredInCUDA(mustBeRegistered) + , m_registeredInCUDA(false) + , m_interopContext(interopContext) + , m_InteropHandle(NULL) + + { + } + + bool getInteropResourceHandle(CUgraphicsResource &handle) + { + if(m_registeredInCUDA && m_InteropHandle) + { + handle = m_InteropHandle; + + return true; + } + + return false; + } + + protected: + + bool m_mustBeRegisteredInCUDA; + bool m_registeredInCUDA; + physx::PxCudaContextManager* m_interopContext; + CUgraphicsResource m_InteropHandle; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererLight.h new file mode 100644 index 00000000..03031b83 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererLight.h @@ -0,0 +1,104 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef RENDERER_LIGHT_H +#define RENDERER_LIGHT_H + +#include <RendererConfig.h> +#include <RendererColor.h> +#include <RendererMaterial.h> +#include <RendererProjection.h> + +namespace SampleRenderer +{ + + class RendererLightDesc; + class Renderer; + class RendererLight + { + friend class Renderer; + public: + enum Type + { + TYPE_POINT = 0, + TYPE_DIRECTIONAL, + TYPE_SPOT, + + NUM_TYPES + }_Type; + + protected: + RendererLight(const RendererLightDesc &desc); + virtual ~RendererLight(void); + + public: + void release(void); + + Type getType(void) const; + + RendererMaterial::Pass getPass(void) const; + + const RendererColor &getColor(void) const; + void setColor(const RendererColor &color); + + float getIntensity(void) const; + void setIntensity(float intensity); + + bool isLocked(void) const; + + RendererTexture2D *getShadowMap(void) const; + void setShadowMap(RendererTexture2D *shadowMap); + + const physx::PxTransform &getShadowTransform(void) const { return m_shadowTransform; } + void setShadowTransform(const physx::PxTransform &shadowTransform) { m_shadowTransform = shadowTransform; } + + const RendererProjection &getShadowProjection(void) const; + void setShadowProjection(const RendererProjection &shadowProjection); + + private: + RendererLight &operator=(const RendererLight &) { return *this; } + + virtual void bind(void) const = 0; + + protected: + const Type m_type; + + RendererColor m_color; + float m_intensity; + + RendererTexture2D *m_shadowMap; + physx::PxTransform m_shadowTransform; + RendererProjection m_shadowProjection; + + private: + Renderer *m_renderer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererLightDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererLightDesc.h new file mode 100644 index 00000000..12b6ade6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererLightDesc.h @@ -0,0 +1,62 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_LIGHT_DESC_H +#define RENDERER_LIGHT_DESC_H + +#include <RendererLight.h> +#include <RendererProjection.h> + +namespace SampleRenderer +{ + + class RendererLightDesc + { + public: + const RendererLight::Type type; + + RendererColor color; + float intensity; + + RendererTexture2D *shadowMap; + physx::PxTransform shadowTransform; + RendererProjection shadowProjection; + + protected: + RendererLightDesc(RendererLight::Type _type); + virtual ~RendererLightDesc() {} + + public: + virtual bool isValid(void) const; + + private: + RendererLightDesc &operator=(const RendererLightDesc&) { return *this; } + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterial.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterial.h new file mode 100644 index 00000000..2ac8d77f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterial.h @@ -0,0 +1,194 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_MATERIAL_H +#define RENDERER_MATERIAL_H + +#include <RendererConfig.h> +#include <vector> + +namespace SampleRenderer +{ + + class RendererMaterialDesc; + + class RendererTexture; + class RendererTextureDesc; + + //ps3 need this declare + class RendererMaterialInstance; + + //ps3 need this declare + class Renderer; + + class RendererMaterial + { + friend class Renderer; + friend class RendererMaterialInstance; + public: + typedef enum Type + { + TYPE_UNLIT = 0, + TYPE_LIT, + NUM_TYPES, + } Type; + + typedef enum AlphaTestFunc + { + ALPHA_TEST_ALWAYS = 0, // disabled alpha testing... + ALPHA_TEST_EQUAL, + ALPHA_TEST_NOT_EQUAL, + ALPHA_TEST_LESS, + ALPHA_TEST_LESS_EQUAL, + ALPHA_TEST_GREATER, + ALPHA_TEST_GREATER_EQUAL, + + NUM_ALPHA_TEST_FUNCS, + } AlphaTestFunc; + + typedef enum BlendFunc + { + BLEND_ZERO = 0, + BLEND_ONE, + BLEND_SRC_COLOR, + BLEND_ONE_MINUS_SRC_COLOR, + BLEND_SRC_ALPHA, + BLEND_ONE_MINUS_SRC_ALPHA, + BLEND_DST_ALPHA, + BLEND_ONE_MINUS_DST_ALPHA, + BLEND_DST_COLOR, + BLEND_ONE_MINUS_DST_COLOR, + BLEND_SRC_ALPHA_SATURATE, + } BlendFunc; + + typedef enum Pass + { + PASS_UNLIT = 0, + + PASS_AMBIENT_LIGHT, + PASS_POINT_LIGHT, + PASS_DIRECTIONAL_LIGHT, + PASS_SPOT_LIGHT_NO_SHADOW, + PASS_SPOT_LIGHT, + + PASS_NORMALS, + PASS_DEPTH, + + // LRR: The deferred pass causes compiles with the ARB_draw_buffers profile option, creating + // multiple color draw buffers. This doesn't work in OGL on ancient Intel parts. + //PASS_DEFERRED, + + NUM_PASSES, + } Pass; + + typedef enum VariableType + { + VARIABLE_FLOAT = 0, + VARIABLE_FLOAT2, + VARIABLE_FLOAT3, + VARIABLE_FLOAT4, + VARIABLE_FLOAT4x4, + VARIABLE_INT, + VARIABLE_SAMPLER2D, + VARIABLE_SAMPLER3D, + + NUM_VARIABLE_TYPES + } VariableType; + + class Variable + { + friend class RendererMaterial; + protected: + Variable(const char *name, VariableType type, PxU32 offset); + virtual ~Variable(void); + + public: + const char *getName(void) const; + VariableType getType(void) const; + PxU32 getDataOffset(void) const; + PxU32 getDataSize(void) const; + + void setSize(PxU32); + + private: + char *m_name; + VariableType m_type; + PxU32 m_offset; + PxI32 m_size; + }; + + public: + static const char *getPassName(Pass pass); + virtual void setModelMatrix(const PxF32 *matrix) = 0; + + protected: + RendererMaterial(const RendererMaterialDesc &desc, bool enableMaterialCaching); + virtual ~RendererMaterial(void); + + public: + void incRefCount() { m_refCount++; } + void release(void); + const Variable *findVariable(const char *name, VariableType varType); + + PX_FORCE_INLINE Type getType(void) const { return m_type; } + PX_FORCE_INLINE AlphaTestFunc getAlphaTestFunc(void) const { return m_alphaTestFunc; } + PX_FORCE_INLINE float getAlphaTestRef(void) const { return m_alphaTestRef; } + PX_FORCE_INLINE bool getBlending(void) const { return m_blending && !rendererBlendingOverrideEnabled(); } + PX_FORCE_INLINE BlendFunc getSrcBlendFunc(void) const { return m_srcBlendFunc; } + PX_FORCE_INLINE BlendFunc getDstBlendFunc(void) const { return m_dstBlendFunc; } + PX_FORCE_INLINE PxU32 getMaterialInstanceDataSize(void) const { return m_variableBufferSize; } + + protected: + virtual const Renderer& getRenderer() const = 0; + virtual void bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const; + virtual void bindMeshState(bool instanced) const = 0; + virtual void unbind(void) const = 0; + virtual void bindVariable(Pass pass, const Variable &variable, const void *data) const = 0; + + RendererMaterial &operator=(const RendererMaterial&) { return *this; } + + bool rendererBlendingOverrideEnabled() const; + + protected: + const Type m_type; + + const AlphaTestFunc m_alphaTestFunc; + float m_alphaTestRef; + + bool m_blending; + const BlendFunc m_srcBlendFunc; + const BlendFunc m_dstBlendFunc; + + std::vector<Variable*> m_variables; + PxU32 m_variableBufferSize; + + PxI32 m_refCount; + bool mEnableMaterialCaching; + }; +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterialDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterialDesc.h new file mode 100644 index 00000000..3c4257b3 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterialDesc.h @@ -0,0 +1,68 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_MATERIAL_DESC_H +#define RENDERER_MATERIAL_DESC_H + +#include <RendererMaterial.h> + +namespace SampleRenderer +{ + + class RendererMaterialDesc + { + public: + RendererMaterial::Type type; + + RendererMaterial::AlphaTestFunc alphaTestFunc; + float alphaTestRef; + + bool blending; + bool instanced; + RendererMaterial::BlendFunc srcBlendFunc; + RendererMaterial::BlendFunc dstBlendFunc; + + const char *geometryShaderPath; + const char *hullShaderPath; + const char *domainShaderPath; + const char *vertexShaderPath; + const char *fragmentShaderPath; + + //all passes enabled + bool enabledPasses[RendererMaterial::NUM_PASSES]; + //instancing enabled + bool enableInstancing; + + public: + RendererMaterialDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterialInstance.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterialInstance.h new file mode 100644 index 00000000..6669faeb --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMaterialInstance.h @@ -0,0 +1,65 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_MATERIAL_INSTANCE_H +#define RENDERER_MATERIAL_INSTANCE_H + +#include <RendererConfig.h> + +#include <RendererMaterial.h> + +namespace SampleRenderer +{ + + class RendererMaterialInstance + { + friend class RendererMaterial; + public: + RendererMaterialInstance(RendererMaterial &material); + RendererMaterialInstance(const RendererMaterialInstance& other); + ~RendererMaterialInstance(void); + + PX_FORCE_INLINE RendererMaterial &getMaterial(void) { return m_material; } + + PX_FORCE_INLINE const RendererMaterial::Variable *findVariable(const char *name, RendererMaterial::VariableType varType) + { + return m_material.findVariable(name, varType); + } + + void writeData(const RendererMaterial::Variable &var, const void *data); + + RendererMaterialInstance &operator=(const RendererMaterialInstance&); + + private: + RendererMaterial &m_material; + PxU8 *m_data; + + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMemoryMacros.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMemoryMacros.h new file mode 100644 index 00000000..6ef58e78 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMemoryMacros.h @@ -0,0 +1,39 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + + +#ifndef RENDERER_MEMORY_MACROS_H +#define RENDERER_MEMORY_MACROS_H + + // PT: if you don't like those macros, don't use them. But don't touch/remove them! + #define DELETESINGLE(x) if(x){ delete x; x = NULL; } + #define DELETEARRAY(x) if(x){ delete []x; x = NULL; } + #define SAFE_RELEASE(x) if(x){ x->release(); x = NULL; } + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMesh.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMesh.h new file mode 100644 index 00000000..f2edb8fd --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMesh.h @@ -0,0 +1,118 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_MESH_H +#define RENDERER_MESH_H + +#include <RendererConfig.h> +#include <RendererIndexBuffer.h> + +namespace SampleRenderer +{ + class Renderer; + class RendererMeshDesc; + class RendererVertexBuffer; + class RendererIndexBuffer; + class RendererInstanceBuffer; + class RendererMaterial; + + class RendererMesh + { + friend class Renderer; + friend class GLES2Renderer; + public: + enum Primitive + { + PRIMITIVE_POINTS = 0, + PRIMITIVE_LINES, + PRIMITIVE_LINE_STRIP, + PRIMITIVE_TRIANGLES, + PRIMITIVE_TRIANGLE_STRIP, + PRIMITIVE_POINT_SPRITES, + + NUM_PRIMITIVES + }_Primitive; + + protected: + RendererMesh(const RendererMeshDesc &desc); + virtual ~RendererMesh(void); + + public: + void release(void); + + Primitive getPrimitives(void) const; + + PxU32 getNumVertices(void) const; + PxU32 getNumIndices(void) const; + PxU32 getNumInstances(void) const; + + void setVertexBufferRange(PxU32 firstVertex, PxU32 numVertices); + void setIndexBufferRange(PxU32 firstIndex, PxU32 numIndices); + void setInstanceBufferRange(PxU32 firstInstance, PxU32 numInstances); + + PxU32 getNumVertexBuffers(void) const; + const RendererVertexBuffer *const*getVertexBuffers(void) const; + + const RendererIndexBuffer *getIndexBuffer(void) const; + + const RendererInstanceBuffer *getInstanceBuffer(void) const; + + virtual bool willRender() const { return true; } + + protected: + void bind(void) const; + void render(RendererMaterial *material) const; + void unbind(void) const; + + virtual void renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const = 0; + virtual void renderVertices(PxU32 numVertices, RendererMaterial *material) const = 0; + + virtual void renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const = 0; + virtual void renderVerticesInstanced(PxU32 numVertices,RendererMaterial *material) const = 0; + + virtual Renderer& renderer() = 0; + + protected: + Primitive m_primitives; + + RendererVertexBuffer **m_vertexBuffers; + PxU32 m_numVertexBuffers; + PxU32 m_firstVertex; + PxU32 m_numVertices; + + RendererIndexBuffer *m_indexBuffer; + PxU32 m_firstIndex; + PxU32 m_numIndices; + + RendererInstanceBuffer *m_instanceBuffer; + PxU32 m_firstInstance; + PxU32 m_numInstances; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshContext.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshContext.h new file mode 100644 index 00000000..f7e96385 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshContext.h @@ -0,0 +1,85 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_MESH_CONTEXT_H +#define RENDERER_MESH_CONTEXT_H + +#include <RendererConfig.h> + +namespace SampleRenderer +{ + + class Renderer; + class RendererMesh; + class RendererMaterial; + class RendererMaterialInstance; + + class RendererMeshContext + { + friend class Renderer; + public: + const RendererMesh *mesh; + RendererMaterial *material; + RendererMaterialInstance *materialInstance; + const physx::PxMat44 *transform; + const physx::PxF32 *shaderData; + + bool negativeScale; + + // TODO: this is kind of hacky, would prefer a more generalized + // solution via RendererMatrialInstance. + const physx::PxMat44 *boneMatrices; + PxU32 numBones; + + enum CullMode + { + CLOCKWISE = 0, + COUNTER_CLOCKWISE, + NONE + }; + + CullMode cullMode; + bool screenSpace; //TODO: I am not sure if this is needed! + + enum FillMode + { + SOLID, + LINE, + POINT, + }; + FillMode fillMode; + + public: + RendererMeshContext(void); + ~RendererMeshContext(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshDesc.h new file mode 100644 index 00000000..1b717b74 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshDesc.h @@ -0,0 +1,66 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_MESH_DESC_H +#define RENDERER_MESH_DESC_H + +#include <RendererMesh.h> + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + class RendererIndexBuffer; + class RendererInstanceBuffer; + + class RendererMeshDesc + { + public: + RendererMesh::Primitive primitives; + + RendererVertexBuffer **vertexBuffers; + PxU32 numVertexBuffers; + PxU32 firstVertex; + PxU32 numVertices; + + RendererIndexBuffer *indexBuffer; + PxU32 firstIndex; + PxU32 numIndices; + + RendererInstanceBuffer *instanceBuffer; + PxU32 firstInstance; + PxU32 numInstances; + + public: + RendererMeshDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshShape.h new file mode 100644 index 00000000..f6f83e45 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererMeshShape.h @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_MESH_SHAPE_H +#define RENDERER_MESH_SHAPE_H + +#include <RendererShape.h> + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + class RendererIndexBuffer; + + class RendererMeshShape : public RendererShape + { + public: + RendererMeshShape(Renderer& renderer, + const PxVec3* verts, PxU32 numVerts, + const PxVec3* normals, + const PxReal* uvs, + const PxU16* faces16, const PxU32* faces32, PxU32 numFaces, bool flipWinding=false); + virtual ~RendererMeshShape(); + + private: + RendererVertexBuffer* m_vertexBuffer; + RendererIndexBuffer* m_indexBuffer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererParticleSystemShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererParticleSystemShape.h new file mode 100644 index 00000000..f6b504a1 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererParticleSystemShape.h @@ -0,0 +1,111 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_PARTICLE_SYSTEM_SHAPE_H +#define RENDERER_PARTICLE_SYSTEM_SHAPE_H + +#include <RendererShape.h> +#include "gpu/PxGpu.h" + +// fwd to avoid including cuda.h +#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) +typedef unsigned long long CUdeviceptr; +#else +typedef unsigned int CUdeviceptr; +#endif + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + class RendererInstanceBuffer; + class RendererIndexBuffer; + + class RendererParticleSystemShape : public RendererShape + { + enum VertexBufferEnum + { + STATIC_VB, + DYNAMIC_POS_VB, + DYNAMIC_COL_VB, + NUM_VERTEX_BUFFERS + }; + + public: + RendererParticleSystemShape(Renderer &renderer, + physx::PxU32 num_vertices, + bool _mInstanced, + bool _mFading, + PxReal fadingPeriod = 1.0f, + PxReal debriScaleFactor = 1.0f, + PxCudaContextManager* ctxMgr=NULL + ); + virtual ~RendererParticleSystemShape(void); + + bool updateBillboard(PxU32 validParticleRange, + CUdeviceptr positions, + CUdeviceptr validParticleBitmap, + CUdeviceptr lifetimes, + PxU32 numParticles); + + bool updateInstanced(PxU32 validParticleRange, + CUdeviceptr positions, + CUdeviceptr validParticleBitmap, + CUdeviceptr orientations, + PxU32 numParticles); + + void updateBillboard(PxU32 validParticleRange, + const PxVec3* positions, + const PxU32* validParticleBitmap, + const PxReal* lifetime = NULL); + + void updateInstanced(PxU32 validParticleRange, + const PxVec3* positions, + const PxU32* validParticleBitmap, + const PxMat33* orientation); + + bool isInteropEnabled() { return mCtxMgr != NULL; } + + private: + bool mInstanced; + bool mFading; + PxReal mFadingPeriod; + PxU32 mMaxParticles; + RendererVertexBuffer* mVertexBuffer[NUM_VERTEX_BUFFERS]; + RendererInstanceBuffer* mInstanceBuffer; + RendererIndexBuffer* mIndexBuffer; + + PxCudaContextManager* mCtxMgr; + + void initializeVertexBuffer(PxU32 color); + void initializeBuffersAsSimpleConvex(PxU32 color, PxReal scaleFactor); + void initializeInstanceBuffer(); + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererProjection.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererProjection.h new file mode 100644 index 00000000..b64b1b4d --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererProjection.h @@ -0,0 +1,60 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_PROJECTION_H +#define RENDERER_PROJECTION_H + +#include <RendererConfig.h> + +namespace SampleRenderer +{ + + class RendererProjection + { + public: + RendererProjection(float fov, float aspectRatio, float nearPlane, float farPlane); + RendererProjection(float left, float right, float bottom, float top, float near, float far); + RendererProjection(const PxMat44 mat); + + void getColumnMajor44(float *f) const; + void getRowMajor44(float *f) const; + operator PxMat44 () const { return *reinterpret_cast<const PxMat44*>( m_matrix ); } + PxMat44& getPxMat44() { return reinterpret_cast<PxMat44&>(*m_matrix ); } + const PxMat44& getPxMat44() const { return reinterpret_cast<const PxMat44&>(*m_matrix ); } + + private: + float m_matrix[16]; + }; + + void buildProjectMatrix(float *dst, const RendererProjection &proj, const physx::PxTransform &view); + void buildUnprojectMatrix(float *dst, const RendererProjection &proj, const physx::PxTransform &view); + PxVec3 unproject(const RendererProjection &proj, const physx::PxTransform &view, PxF32 x, PxF32 y, PxF32 z = 0); + PxVec3 project( const RendererProjection &proj, const physx::PxTransform &view, const PxVec3& pos); + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererShape.h new file mode 100644 index 00000000..18cec741 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererShape.h @@ -0,0 +1,65 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +// +// RendererShape : base class for convenience classes for generating meshes based on shapes. +// +#ifndef RENDERER_SHAPE_H +#define RENDERER_SHAPE_H + +#include <RendererConfig.h> + +namespace SampleRenderer +{ + + class Renderer; + class RendererMesh; + + class RendererShape + { + protected: + RendererShape(Renderer &renderer); + + public: + virtual ~RendererShape(void); + + RendererMesh *getMesh(void); + Renderer& getRenderer() const { return m_renderer; } + + private: + RendererShape &operator=(const RendererShape &) { return *this; } + + protected: + Renderer& m_renderer; + RendererMesh* m_mesh; + public: + void* m_userData; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSimpleParticleSystemShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSimpleParticleSystemShape.h new file mode 100644 index 00000000..b7959f83 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSimpleParticleSystemShape.h @@ -0,0 +1,62 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_SIMPLE_PARTICLE_SYSTEM_SHAPE_H +#define RENDERER_SIMPLE_PARTICLE_SYSTEM_SHAPE_H + +#include <RendererShape.h> + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + class RendererIndexBuffer; + + // this shape is used when no sprite rendering is possible - dx11 with feature dx9 for example + class RendererSimpleParticleSystemShape : public RendererShape + { + public: + RendererSimpleParticleSystemShape(Renderer &renderer, + physx::PxU32 num_vertices); + virtual ~RendererSimpleParticleSystemShape(void); + + void updateBillboard(PxU32 validParticleRange, + const PxVec3* positions, + const PxU32* validParticleBitmap, + const PxReal* lifetime = NULL); + + private: + PxU32 mMaxParticles; + RendererVertexBuffer* mVertexBuffer; + RendererIndexBuffer* mIndexBuffer; + + void initializeVertexBuffer(PxU32 color); + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSpotLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSpotLight.h new file mode 100644 index 00000000..effd11f1 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSpotLight.h @@ -0,0 +1,70 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_SPOT_LIGHT_H +#define RENDERER_SPOT_LIGHT_H + +#include <RendererLight.h> + +namespace SampleRenderer +{ + + class RendererSpotLightDesc; + + class RendererSpotLight : public RendererLight + { + protected: + RendererSpotLight(const RendererSpotLightDesc &desc); + virtual ~RendererSpotLight(void); + + public: + const PxVec3 &getPosition(void) const; + void setPosition(const PxVec3 &pos); + + const PxVec3 &getDirection(void) const; + void setDirection(const PxVec3 &dir); + + PxF32 getInnerRadius(void) const; + PxF32 getOuterRadius(void) const; + void setRadius(PxF32 innerRadius, PxF32 outerRadius); + + PxF32 getInnerCone(void) const; + PxF32 getOuterCone(void) const; + void setCone(PxF32 innerCone, PxF32 outerCone); + + protected: + PxVec3 m_position; + PxVec3 m_direction; + PxF32 m_innerRadius; + PxF32 m_outerRadius; + PxF32 m_innerCone; + PxF32 m_outerCone; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSpotLightDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSpotLightDesc.h new file mode 100644 index 00000000..676ae2f0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererSpotLightDesc.h @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_SPOT_LIGHT_DESC_H +#define RENDERER_SPOT_LIGHT_DESC_H + +#include <RendererLightDesc.h> + +namespace SampleRenderer +{ + + class RendererSpotLightDesc : public RendererLightDesc + { + public: + PxVec3 position; + PxVec3 direction; + + PxF32 innerRadius; + PxF32 outerRadius; + + // cone = dot(direction, directionToFragment); + // so cone value of 0 is completely open and value of 1 is completely closed. + PxF32 innerCone; + PxF32 outerCone; + + public: + RendererSpotLightDesc(void); + + virtual bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTarget.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTarget.h new file mode 100644 index 00000000..698404ab --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTarget.h @@ -0,0 +1,50 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_TARGET_H +#define RENDERER_TARGET_H + +namespace SampleRenderer +{ + + class RendererTarget + { + friend class Renderer; + public: + RendererTarget(void); + virtual ~RendererTarget(void); + + void release(void) { delete this; } + + private: + virtual void bind(void)=0; + virtual void unbind(void)=0; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTargetDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTargetDesc.h new file mode 100644 index 00000000..d8a055b4 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTargetDesc.h @@ -0,0 +1,52 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_TARGET_DESC_H +#define RENDERER_TARGET_DESC_H + +#include <RendererConfig.h> + +namespace SampleRenderer +{ + + class RendererTargetDesc + { + public: + RendererTexture2D **textures; + PxU32 numTextures; + + RendererTexture2D *depthStencilSurface; + + public: + RendererTargetDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTerrainShape.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTerrainShape.h new file mode 100644 index 00000000..c066617a --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTerrainShape.h @@ -0,0 +1,59 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +// +// RendererTerrainShape : convenience class for generating a terrain mesh. +// +#ifndef RENDERER_TERRAIN_SHAPE_H +#define RENDERER_TERRAIN_SHAPE_H + +#include <RendererShape.h> + +namespace SampleRenderer +{ + + class RendererVertexBuffer; + class RendererIndexBuffer; + + class RendererTerrainShape : public RendererShape + { + public: + RendererTerrainShape(Renderer &renderer, + PxVec3 *verts, PxU32 numVerts, + PxVec3 *normals, PxU32 numNorms, + PxU16 *faces, PxU32 numFaces, + PxF32 uvScale); + virtual ~RendererTerrainShape(void); + + private: + RendererVertexBuffer *m_vertexBuffer; + RendererIndexBuffer *m_indexBuffer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture.h new file mode 100644 index 00000000..bc15dcd0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture.h @@ -0,0 +1,131 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_TEXTURE_H +#define RENDERER_TEXTURE_H + +#include <RendererConfig.h> + +namespace SampleRenderer +{ + + class RendererTextureDesc; + + class RendererTexture + { + public: + enum Format + { + FORMAT_B8G8R8A8 = 0, + FORMAT_R8G8B8A8, + FORMAT_A8, + FORMAT_R32F, + + FORMAT_DXT1, + FORMAT_DXT3, + FORMAT_DXT5, + + FORMAT_D16, + FORMAT_D24S8, + + FORMAT_GXT, + + FORMAT_PVR_2BPP, + FORMAT_PVR_4BPP, + + NUM_FORMATS + }_Format; + + enum Filter + { + FILTER_NEAREST = 0, + FILTER_LINEAR, + FILTER_ANISOTROPIC, + + NUM_FILTERS + }_Filter; + + enum Addressing + { + ADDRESSING_WRAP = 0, + ADDRESSING_CLAMP, + ADDRESSING_MIRROR, + + NUM_ADDRESSING + }_Addressing; + + public: + static PxU32 computeImageByteSize(PxU32 width, PxU32 height, PxU32 depth, Format format); + static PxU32 getLevelDimension(PxU32 dimension, PxU32 level); + static bool isCompressedFormat(Format format); + static bool isDepthStencilFormat(Format format); + static PxU32 getFormatNumBlocks(PxU32 dimension, Format format); + static PxU32 getFormatBlockSize(Format format); + + protected: + RendererTexture(const RendererTextureDesc &desc); + virtual ~RendererTexture(void); + + public: + void release(void) { delete this; } + + Format getFormat(void) const { return m_format; } + Filter getFilter(void) const { return m_filter; } + Addressing getAddressingU(void) const { return m_addressingU; } + Addressing getAddressingV(void) const { return m_addressingV; } + PxU32 getWidth(void) const { return m_width; } + PxU32 getHeight(void) const { return m_height; } + PxU32 getDepth(void) const { return m_depth; } + PxU32 getNumLevels(void) const { return m_numLevels; } + + PxU32 getWidthInBlocks(void) const; + PxU32 getHeightInBlocks(void) const; + PxU32 getBlockSize(void) const; + + public: + //! pitch is the number of bytes between the start of each row. + virtual void *lockLevel(PxU32 level, PxU32 &pitch) = 0; + virtual void unlockLevel(PxU32 level) = 0; + virtual void select(PxU32 stageIndex) = 0; + + private: + RendererTexture &operator=(const RendererTexture&) { return *this; } + + private: + Format m_format; + Filter m_filter; + Addressing m_addressingU; + Addressing m_addressingV; + PxU32 m_width; + PxU32 m_height; + PxU32 m_depth; + PxU32 m_numLevels; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture2D.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture2D.h new file mode 100644 index 00000000..601a3eb3 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture2D.h @@ -0,0 +1,33 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_TEXTURE_2D_H +#define RENDERER_TEXTURE_2D_H + +#include <RendererTexture.h> + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture2DDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture2DDesc.h new file mode 100644 index 00000000..4d8b16ab --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTexture2DDesc.h @@ -0,0 +1,33 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_TEXTURE_2D_DESC_H +#define RENDERER_TEXTURE_2D_DESC_H + +#include <RendererTextureDesc.h> + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTextureDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTextureDesc.h new file mode 100644 index 00000000..08a7929e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererTextureDesc.h @@ -0,0 +1,62 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_TEXTURE_DESC_H +#define RENDERER_TEXTURE_DESC_H + +#include <RendererTexture.h> + +namespace SampleRenderer +{ + + class RendererTextureDesc + { + public: + RendererTexture::Format format; + RendererTexture::Filter filter; + RendererTexture::Addressing addressingU; + RendererTexture::Addressing addressingV; + RendererTexture::Addressing addressingW; + + PxU32 width; + PxU32 height; + PxU32 depth; + PxU32 numLevels; + + bool renderTarget; + + void* data; + + public: + RendererTextureDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererUtils.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererUtils.h new file mode 100644 index 00000000..d750a9de --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererUtils.h @@ -0,0 +1,90 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef RENDERER_UTILS_H +#define RENDERER_UTILS_H + +namespace SampleRenderer +{ + +class safe_bool_base +{ +protected: + typedef void (safe_bool_base::*bool_type)() const; + void this_type_does_not_support_comparisons() const {} + + safe_bool_base() {} + safe_bool_base(const safe_bool_base&) {} + safe_bool_base& operator=(const safe_bool_base&) {return *this;} + ~safe_bool_base() {} +}; + +template <typename T=void> class safe_bool : public safe_bool_base +{ +public: + operator bool_type() const + { + return (static_cast<const T*>(this))->boolean_test() ? + //&safe_bool_base::this_type_does_not_support_comparisons : 0; + &safe_bool<T>::this_type_does_not_support_comparisons : 0; + } +protected: + ~safe_bool() {} +}; + +template<> class safe_bool<void> : public safe_bool_base +{ +public: + operator bool_type() const + { + return boolean_test()==true ? + //&safe_bool_base::this_type_does_not_support_comparisons : 0; + &safe_bool<void>::this_type_does_not_support_comparisons : 0; + } +protected: + virtual bool boolean_test() const=0; + virtual ~safe_bool() {} +}; + +template <typename T, typename U> +PX_INLINE bool operator==(const safe_bool<T>& lhs,const safe_bool<U>& rhs) +{ + lhs.this_type_does_not_support_comparisons(); + return false; +} + +template <typename T,typename U> +PX_INLINE bool operator!=(const safe_bool<T>& lhs,const safe_bool<U>& rhs) +{ + lhs.this_type_does_not_support_comparisons(); + return false; +} + +} + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererVertexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererVertexBuffer.h new file mode 100644 index 00000000..a1914677 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererVertexBuffer.h @@ -0,0 +1,156 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_VERTEXBUFFER_H +#define RENDERER_VERTEXBUFFER_H + +#include <RendererConfig.h> +#include "RendererInteropableBuffer.h" + +namespace SampleRenderer +{ + + class RendererVertexBufferDesc; + + class RendererVertexBuffer: public RendererInteropableBuffer + { + friend class RendererMesh; + friend class GLES2Renderer; + public: + enum Semantic + { + SEMANTIC_POSITION = 0, + SEMANTIC_COLOR, + SEMANTIC_NORMAL, + SEMANTIC_TANGENT, + + SEMANTIC_DISPLACEMENT_TEXCOORD, + SEMANTIC_DISPLACEMENT_FLAGS, + + SEMANTIC_BONEINDEX, + SEMANTIC_BONEWEIGHT, + + SEMANTIC_TEXCOORD0, + SEMANTIC_TEXCOORD1, + SEMANTIC_TEXCOORD2, + SEMANTIC_TEXCOORD3, + SEMANTIC_TEXCOORDMAX = SEMANTIC_TEXCOORD3, + + NUM_SEMANTICS, + NUM_TEXCOORD_SEMANTICS = SEMANTIC_TEXCOORDMAX - SEMANTIC_TEXCOORD0, + }_Semantic; + + enum Format + { + FORMAT_FLOAT1 = 0, + FORMAT_FLOAT2, + FORMAT_FLOAT3, + FORMAT_FLOAT4, + + FORMAT_UBYTE4, + FORMAT_USHORT4, + + FORMAT_COLOR_BGRA, // RendererColor + FORMAT_COLOR_RGBA, // OGL format + FORMAT_COLOR_NATIVE, // do not convert + + NUM_FORMATS, + }_Format; + + enum Hint + { + HINT_STATIC = 0, + HINT_DYNAMIC, + }_Hint; + + public: + static PxU32 getFormatByteSize(Format format); + + protected: + RendererVertexBuffer(const RendererVertexBufferDesc &desc); + virtual ~RendererVertexBuffer(void); + + public: + void release(void) { delete this; } + + PxU32 getMaxVertices(void) const; + + Hint getHint(void) const; + Format getFormatForSemantic(Semantic semantic) const; + + void *lockSemantic(Semantic semantic, PxU32 &stride); + void unlockSemantic(Semantic semantic); + + //Checks buffer written state for vertex buffers in D3D + virtual bool checkBufferWritten() { return true; } + + virtual void *lock(void) = 0; + virtual void unlock(void) = 0; + PxU32 getStride(void) const { return m_stride; } + + private: + virtual void swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat) = 0; + + virtual void bind(PxU32 streamID, PxU32 firstVertex) = 0; + virtual void unbind(PxU32 streamID) = 0; + + RendererVertexBuffer &operator=(const RendererVertexBuffer &) { return *this; } + + protected: + void prepareForRender(void); + + protected: + class SemanticDesc + { + public: + Format format; + PxU32 offset; + bool locked; + public: + SemanticDesc(void) + { + format = NUM_FORMATS; + offset = 0; + locked = false; + } + }; + + protected: + const Hint m_hint; + PxU32 m_maxVertices; + PxU32 m_stride; + bool m_deferredUnlock; + SemanticDesc m_semanticDescs[NUM_SEMANTICS]; + + private: + void *m_lockedBuffer; + PxU32 m_numSemanticLocks; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererVertexBufferDesc.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererVertexBufferDesc.h new file mode 100644 index 00000000..aef6ecc6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererVertexBufferDesc.h @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef RENDERER_VERTEXBUFFER_DESC_H +#define RENDERER_VERTEXBUFFER_DESC_H + +#include <RendererVertexBuffer.h> + +namespace SampleRenderer +{ + + class RendererVertexBufferDesc + { + public: + RendererVertexBuffer::Hint hint; + RendererVertexBuffer::Format semanticFormats[RendererVertexBuffer::NUM_SEMANTICS]; + + PxU32 maxVertices; + + ///mark this buffer can be read back by lock, lock flag should not be discard + bool canReadBack; + + bool registerInCUDA; + physx::PxCudaContextManager* interopContext; + + public: + RendererVertexBufferDesc(void); + + bool isValid(void) const; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererWindow.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererWindow.h new file mode 100644 index 00000000..ace5bbe7 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererWindow.h @@ -0,0 +1,88 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef RENDERER_WINDOW_H +#define RENDERER_WINDOW_H + +#include <RendererConfig.h> + +namespace SampleFramework { + class SamplePlatform; +} + +namespace SampleRenderer +{ + + class RendererWindow + { + public: + RendererWindow(void); + virtual ~RendererWindow(void); + + bool open(PxU32 width, PxU32 height, const char *title, bool fullscreen=false); + void close(void); + + bool isOpen(void) const; + + // update the window's state... handle messages, etc. + void update(void); + + // resize the window... + void setSize(PxU32 width, PxU32 height); + + // get/set the window's title... + void getTitle(char *title, PxU32 maxLength) const; + void setTitle(const char *title); + + bool hasFocus() const; + void setFocus(bool b); + + SampleFramework::SamplePlatform* getPlatform() { return m_platform; } + public: + // called just AFTER the window opens. + virtual void onOpen(void) {} + + // called just BEFORE the window closes. return 'true' to confirm the window closure. + virtual bool onClose(void) { return true; } + + // called just AFTER the window is resized. + virtual void onResize(PxU32 /*width*/, PxU32 /*height*/) {} + + // called when the window's contents needs to be redrawn. + virtual void onDraw(void) = 0; + + protected: + SampleFramework::SamplePlatform* m_platform; + + private: + bool m_isOpen; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/include/windows/WindowsGLIncludes.h b/PhysX_3.4/Samples/SampleFramework/renderer/include/windows/WindowsGLIncludes.h new file mode 100644 index 00000000..01fadfc0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/include/windows/WindowsGLIncludes.h @@ -0,0 +1,34 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef WINDOWS_GL_INCLUDES_H +#define WINDOWS_GL_INCLUDES_H + +#define GLEW_STATIC +#include <GL/glew.h> + +#endif
\ No newline at end of file |