Init
This commit is contained in:
44
physx/samples/sampleframework/renderer/include/GLIncludes.h
Normal file
44
physx/samples/sampleframework/renderer/include/GLIncludes.h
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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_MACOSX)
|
||||
#include <osx/OSXGLIncludes.h>
|
||||
#elif defined(RENDERER_LINUX)
|
||||
#include <linux/LinuxGLIncludes.h>
|
||||
#else
|
||||
#error Undefined platform.
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
381
physx/samples/sampleframework/renderer/include/Renderer.h
Normal file
381
physx/samples/sampleframework/renderer/include/Renderer.h
Normal file
@ -0,0 +1,381 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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.
|
||||
DRIVER_DIRECT3D9, // Supports Windows.
|
||||
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; }
|
||||
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
@ -0,0 +1,55 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,60 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
PxU8 b, g, r, a;
|
||||
|
||||
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
|
||||
207
physx/samples/sampleframework/renderer/include/RendererConfig.h
Normal file
207
physx/samples/sampleframework/renderer/include/RendererConfig.h
Normal file
@ -0,0 +1,207 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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(__GNUC__)
|
||||
#define RENDERER_GCC
|
||||
#else
|
||||
#error Unknown Compiler!
|
||||
|
||||
#endif
|
||||
|
||||
// Platform specific configuration...
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
#define RENDERER_WINDOWS
|
||||
#define RENDERER_ENABLE_DIRECT3D9
|
||||
#define RENDERER_ENABLE_DIRECT3D11
|
||||
#define RENDERER_ENABLE_NVPERFHUD
|
||||
#define RENDERER_ENABLE_TGA_SUPPORT
|
||||
#if !defined(RENDERER_PVD) && 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__)
|
||||
#define RENDERER_MACOSX
|
||||
#define RENDERER_ENABLE_OPENGL
|
||||
#define RENDERER_ENABLE_CG
|
||||
#if !PX_PPC
|
||||
#define RENDERER_ENABLE_TGA_SUPPORT
|
||||
#endif
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
#define RENDERER_LINUX
|
||||
#define RENDERER_ENABLE_OPENGL
|
||||
#define RENDERER_ENABLE_CG
|
||||
#define RENDERER_ENABLE_TGA_SUPPORT
|
||||
|
||||
#elif defined(__linux__)
|
||||
#define RENDERER_LINUX
|
||||
#define RENDERER_ENABLE_OPENGL
|
||||
#define RENDERER_ENABLE_CG
|
||||
#define RENDERER_ENABLE_TGA_SUPPORT
|
||||
|
||||
#else
|
||||
#error "Unknown Platform!"
|
||||
|
||||
#endif
|
||||
|
||||
#if PX_DEBUG
|
||||
#define RENDERER_DEBUG
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(RENDERER_DEBUG)
|
||||
#if defined(RENDERER_WINDOWS)
|
||||
#define RENDERER_ASSERT(_exp, _msg) \
|
||||
if(!(_exp)) \
|
||||
{ \
|
||||
MessageBoxA(0, _msg, "Renderer Assert", MB_OK); \
|
||||
__debugbreak(); \
|
||||
}
|
||||
#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 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
|
||||
|
||||
#define RENDERER_INSTANCING 1
|
||||
|
||||
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;
|
||||
}
|
||||
#define LOGI(...) LOG_INFO("LOGI: ", __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,60 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,54 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,49 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,57 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef RENDERER_FOUNDATION_H
|
||||
#define RENDERER_FOUNDATION_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "task/PxTask.h"
|
||||
#include "common/PxProfileZone.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
|
||||
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,89 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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;
|
||||
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
|
||||
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,130 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,58 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,77 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef RENDERER_INTEROPABLE_BUFFER_H
|
||||
#define RENDERER_INTEROPABLE_BUFFER_H
|
||||
|
||||
#include <RendererConfig.h>
|
||||
|
||||
typedef struct CUgraphicsResource_st *CUgraphicsResource;
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxCudaContextManager;
|
||||
}
|
||||
|
||||
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
|
||||
104
physx/samples/sampleframework/renderer/include/RendererLight.h
Normal file
104
physx/samples/sampleframework/renderer/include/RendererLight.h
Normal file
@ -0,0 +1,104 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,62 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,189 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef RENDERER_MATERIAL_H
|
||||
#define RENDERER_MATERIAL_H
|
||||
|
||||
#include <RendererConfig.h>
|
||||
#include <vector>
|
||||
|
||||
namespace SampleRenderer
|
||||
{
|
||||
class Renderer;
|
||||
class RendererMaterialDesc;
|
||||
class RendererMaterialInstance;
|
||||
|
||||
class RendererTexture;
|
||||
class RendererTextureDesc;
|
||||
|
||||
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
|
||||
@ -0,0 +1,68 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,65 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,39 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
117
physx/samples/sampleframework/renderer/include/RendererMesh.h
Normal file
117
physx/samples/sampleframework/renderer/include/RendererMesh.h
Normal file
@ -0,0 +1,117 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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;
|
||||
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
|
||||
@ -0,0 +1,85 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,66 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,56 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,60 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,65 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,70 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,58 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,50 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,52 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
131
physx/samples/sampleframework/renderer/include/RendererTexture.h
Normal file
131
physx/samples/sampleframework/renderer/include/RendererTexture.h
Normal file
@ -0,0 +1,131 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef RENDERER_TEXTURE_2D_H
|
||||
#define RENDERER_TEXTURE_2D_H
|
||||
|
||||
#include <RendererTexture.h>
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef RENDERER_TEXTURE_2D_DESC_H
|
||||
#define RENDERER_TEXTURE_2D_DESC_H
|
||||
|
||||
#include <RendererTextureDesc.h>
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,62 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,90 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,155 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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;
|
||||
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
|
||||
@ -0,0 +1,58 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,88 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 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
|
||||
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef LINUX_GL_INCLUDES_H
|
||||
#define LINUX_GL_INCLUDES_H
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef WINDOWS_GL_INCLUDES_H
|
||||
#define WINDOWS_GL_INCLUDES_H
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user