aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Samples/SampleFramework/platform/include
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Samples/SampleFramework/platform/include
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'PhysX_3.4/Samples/SampleFramework/platform/include')
-rw-r--r--PhysX_3.4/Samples/SampleFramework/platform/include/SamplePlatform.h152
-rw-r--r--PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInput.h229
-rw-r--r--PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInputIds.h58
-rw-r--r--PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSamplePlatform.h162
-rw-r--r--PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInput.h158
-rw-r--r--PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInputIds.h178
6 files changed, 937 insertions, 0 deletions
diff --git a/PhysX_3.4/Samples/SampleFramework/platform/include/SamplePlatform.h b/PhysX_3.4/Samples/SampleFramework/platform/include/SamplePlatform.h
new file mode 100644
index 00000000..2b88fdda
--- /dev/null
+++ b/PhysX_3.4/Samples/SampleFramework/platform/include/SamplePlatform.h
@@ -0,0 +1,152 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+
+#ifndef SAMPLE_PLATFORM_H
+#define SAMPLE_PLATFORM_H
+
+#include <RendererDesc.h>
+#include <RendererWindow.h>
+#include <RendererTexture2D.h>
+
+namespace SampleFramework
+{
+ class SampleApplication;
+ class SampleUserInput;
+
+ /* This class declares and partly implements platform-abstraction level.
+ Do not use platform-specific types and functions here.
+ */
+ class SamplePlatform
+ {
+ protected:
+ SampleRenderer::RendererWindow* m_app;
+ SampleApplication* m_sf_app;
+ static SamplePlatform* m_platform;
+
+ public:
+ // access
+ static SamplePlatform* platform();
+ static void setPlatform(SamplePlatform*);
+ SampleApplication* application();
+
+ // creation
+ explicit SamplePlatform(SampleRenderer::RendererWindow* _app);
+ virtual ~SamplePlatform() = 0;
+ // System
+ virtual void showCursor(bool);
+
+ virtual size_t getCWD(char* path, size_t len);
+ virtual void setCWDToEXE(void);
+ virtual void popPathSpec(char *path);
+ virtual bool preOpenWindow(void * ptr);
+ virtual bool openWindow(physx::PxU32& width,
+ physx::PxU32& height,
+ const char* title,
+ bool fullscreen);
+ virtual bool useWindow(physx::PxU64 hwnd);
+ virtual void update();
+ virtual bool closeWindow();
+ virtual bool updateWindow();
+ virtual bool hasFocus() const;
+ virtual void setFocus(bool b);
+ virtual bool isOpen();
+ virtual physx::PxU64 getWindowHandle();
+ virtual void setWindowSize(physx::PxU32 width,
+ physx::PxU32 height);
+ virtual void getWindowSize(physx::PxU32& width, physx::PxU32& height);
+ virtual void getTitle(char *title, physx::PxU32 maxLength) const;
+ virtual void setTitle(const char *title);
+
+ virtual void setMouseCursorRecentering(bool val) {}
+ virtual bool getMouseCursorRecentering() const { return false; }
+
+ virtual void showMessage(const char* title, const char* message);
+ virtual bool saveBitmap(const char* fileName,
+ physx::PxU32 width,
+ physx::PxU32 height,
+ physx::PxU32 sizeInBytes,
+ const void* data);
+ virtual void* compileProgram(void * context,
+ const char* assetDir,
+ const char *programPath,
+ physx::PxU64 profile,
+ const char* passString,
+ const char *entry,
+ const char **args);
+ virtual void* initializeD3D9();
+ virtual void* initializeD3D11();
+ virtual bool isD3D9ok();
+ virtual const char* getPathSeparator();
+ virtual bool isD3D11ok();
+ // Rendering
+ virtual void initializeCGRuntimeCompiler();
+ virtual void initializeOGLDisplay(const SampleRenderer::RendererDesc& desc,
+ physx::PxU32& width,
+ physx::PxU32& height);
+ virtual physx::PxU32 initializeD3D9Display(void * presentParameters,
+ char* m_deviceName,
+ physx::PxU32& width,
+ physx::PxU32& height,
+ void * m_d3dDevice_out);
+ virtual physx::PxU32 initializeD3D11Display(void *dxgiSwapChainDesc,
+ char *m_deviceName,
+ physx::PxU32& width,
+ physx::PxU32& height,
+ void *m_d3dDevice_out,
+ void *m_d3dDeviceContext_out,
+ void *m_dxgiSwap_out);
+ virtual physx::PxU32 D3D9Present();
+ virtual void D3D9BlockUntilNotBusy(void * resource);
+ virtual void D3D9DeviceBlockUntilIdle();
+ virtual physx::PxU64 getD3D9TextureFormat(SampleRenderer::RendererTexture2D::Format format);
+ virtual physx::PxU32 D3D11Present(bool vsync);
+ virtual physx::PxU64 getD3D11TextureFormat(SampleRenderer::RendererTexture2D::Format format);
+ virtual void postInitializeOGLDisplay();
+ virtual void setOGLVsync(bool on);
+ virtual bool makeContextCurrent();
+ virtual bool isContextValid();
+ virtual void freeDisplay();
+ virtual void swapBuffers();
+ virtual void postRendererRelease();
+ virtual void preRendererSetup();
+ virtual void postRendererSetup(SampleRenderer::Renderer* renderer);
+ virtual void setupRendererDescription(SampleRenderer::RendererDesc& renDesc);
+ // Input
+ virtual void doInput();
+
+ virtual const SampleUserInput* getSampleUserInput() const = 0;
+ virtual SampleUserInput* getSampleUserInput() = 0;
+
+ virtual const char* getPlatformName() const { return NULL; }
+ // File System
+ virtual bool makeSureDirectoryPathExists(const char* dirPath);
+ };
+
+ SamplePlatform* createPlatform(SampleRenderer::RendererWindow* _app);
+}
+
+#endif
diff --git a/PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInput.h b/PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInput.h
new file mode 100644
index 00000000..32c60242
--- /dev/null
+++ b/PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInput.h
@@ -0,0 +1,229 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+
+#ifndef SAMPLE_USER_INPUT_H
+#define SAMPLE_USER_INPUT_H
+
+#include <foundation/PxSimpleTypes.h>
+#include <vector>
+#include "PsString.h"
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable:4702)
+#include <map>
+#pragma warning(pop)
+#else
+#include <map>
+#endif
+
+namespace SampleRenderer
+{
+ class Renderer;
+}
+
+namespace SampleFramework
+{
+ class InputEventListener;
+
+ struct UserInput
+ {
+ physx::PxU16 m_Id;
+ char m_IdName[256]; // this name is used for mapping (enum name)
+ char m_Name[256]; // this name is used for help
+ };
+
+ struct InputEvent
+ {
+ InputEvent(physx::PxU16 id, bool analog = false, float sens = 1.0f)
+ :m_Id(id), m_Analog(analog), m_Sensitivity(sens)
+ {
+ }
+
+ InputEvent(const InputEvent& e)
+ :m_Id(e.m_Id), m_Analog(e.m_Analog), m_Sensitivity(e.m_Sensitivity)
+ {
+ }
+
+ InputEvent()
+ : m_Analog(false), m_Sensitivity(1.0f)
+ {
+ }
+
+ physx::PxU16 m_Id;
+ bool m_Analog;
+ float m_Sensitivity;
+ };
+
+ struct InputEventName
+ {
+ char m_Name[256];
+ };
+
+ struct SampleInputData
+ {
+ char m_InputEventName[256];
+ char m_UserInputName[256];
+ };
+
+ struct SampleInputMapping
+ {
+ physx::PxU16 m_InputEventId;
+ size_t m_InputEventIndex;
+ physx::PxU16 m_UserInputId;
+ size_t m_UserInputIndex;
+ };
+
+ typedef std::vector<SampleInputData> T_SampleInputData;
+
+ enum InputType
+ {
+ UNDEFINED_INPUT = 0,
+ KEYBOARD_INPUT = (1 << 0),
+ GAMEPAD_INPUT = (1 << 1),
+ TOUCH_BUTTON_INPUT = (1 << 2),
+ TOUCH_PAD_INPUT = (1 << 3),
+ MOUSE_INPUT = (1 << 4),
+ };
+
+ enum InputDataReadState
+ {
+ STATE_INPUT_EVENT_ID,
+ STATE_USER_INPUT_ID,
+ STATE_DIGITAL,
+ STATE_INPUT_EVENT_NAME,
+ };
+
+ class SampleUserInput
+ {
+ public:
+ // key codes for console and raw key info
+ enum KeyCode
+ {
+ KEY_UNKNOWN = 0,
+
+ KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
+ KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
+ KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
+ KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z,
+
+ KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
+ KEY_7, KEY_8, KEY_9,
+
+ KEY_SPACE, KEY_RETURN, KEY_SHIFT, KEY_CONTROL, KEY_ESCAPE, KEY_COMMA,
+ KEY_NUMPAD0, KEY_NUMPAD1, KEY_NUMPAD2, KEY_NUMPAD3, KEY_NUMPAD4, KEY_NUMPAD5, KEY_NUMPAD6, KEY_NUMPAD7, KEY_NUMPAD8, KEY_NUMPAD9,
+ KEY_MULTIPLY, KEY_ADD, KEY_SEPARATOR, KEY_SUBTRACT, KEY_DECIMAL, KEY_DIVIDE,
+
+ KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
+ KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
+
+ KEY_TAB, KEY_PRIOR, KEY_NEXT,
+ KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,
+
+ NUM_KEY_CODES,
+ };
+
+ SampleUserInput();
+
+ virtual ~SampleUserInput();
+
+ void registerUserInput(physx::PxU16 id, const char* idName, const char* name);
+ virtual const InputEvent* registerInputEvent(const InputEvent& inputEvent, physx::PxU16 userInputId, const char* name);
+ virtual const InputEvent* registerTouchInputEvent(const InputEvent& inputEvent, physx::PxU16 userInputId, const char* caption, const char* name)
+ {
+ PX_UNUSED(inputEvent);
+ PX_UNUSED(userInputId);
+ PX_UNUSED(caption);
+ return NULL;
+ }
+ virtual void unregisterInputEvent(physx::PxU16 inputEventId);
+ virtual void registerInputEvent(const SampleInputMapping& mapping);
+
+ virtual bool keyboardSupported() const { return false; }
+ virtual bool gamepadSupported() const { return false; }
+ virtual bool mouseSupported() const { return false; }
+
+ virtual InputType getInputType(const UserInput& ) const { return UNDEFINED_INPUT; }
+
+ void registerInputEventListerner(InputEventListener* listener) { mListener = listener; }
+ InputEventListener* getInputEventListener() const { return mListener; }
+
+ virtual void updateInput();
+ virtual void shutdown();
+
+ virtual void setRenderer(SampleRenderer::Renderer* ) {}
+
+ virtual bool getDigitalInputEventState(physx::PxU16 inputEventId ) const = 0;
+ virtual float getAnalogInputEventState(physx::PxU16 inputEventId ) const = 0;
+
+ const std::vector<size_t>* getUserInputs(physx::PxI32 inputEventId) const;
+ const std::vector<size_t>* getInputEvents(physx::PxU16 userInputId) const;
+
+ const std::vector<InputEvent>& getInputEventList() const { return mInputEvents; }
+ const std::vector<InputEventName>& getInputEventNameList() const { return mInputEventNames; }
+ const std::vector<UserInput>& getUserInputList() const { return mUserInputs; }
+ const std::map<physx::PxU16, std::vector<size_t> >& getInputEventUserInputMap() const { return mInputEventUserInputMap; }
+
+ physx::PxU16 getUserInputKeys(physx::PxU16 inputEventId, const char* names[], physx::PxU16 maxNames, physx::PxU32 inputTypeMask) const;
+
+ physx::PxI32 translateUserInputNameToId(const char* name, size_t& index) const;
+ physx::PxI32 translateInputEventNameToId(const char* name, size_t& index) const;
+ const char* translateInputEventIdToName(physx::PxI32 id) const;
+
+ const InputEvent* getInputEventSlow(physx::PxU16 inputEventId) const;
+
+ protected:
+ virtual void processGamepads();
+
+ std::vector<UserInput> mUserInputs;
+ std::vector<InputEvent> mInputEvents;
+ std::vector<InputEventName> mInputEventNames;
+
+ private:
+
+ InputEventListener* mListener;
+ std::map<physx::PxU16, std::vector<size_t> > mInputEventUserInputMap;
+ std::map<physx::PxU16, std::vector<size_t> > mUserInputInputEventMap;
+ };
+
+ class InputEventListener
+ {
+ public:
+ InputEventListener() {}
+
+ virtual ~InputEventListener() {}
+
+ // special case for text console
+ virtual void onKeyDownEx(SampleUserInput::KeyCode, physx::PxU32) {}
+
+ virtual void onPointerInputEvent(const InputEvent&, physx::PxU32, physx::PxU32, physx::PxReal, physx::PxReal, bool val) {}
+ virtual void onAnalogInputEvent(const InputEvent& , float val) = 0;
+ virtual void onDigitalInputEvent(const InputEvent& , bool val) = 0;
+ };
+}
+
+#endif
diff --git a/PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInputIds.h b/PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInputIds.h
new file mode 100644
index 00000000..6a2e2fb9
--- /dev/null
+++ b/PhysX_3.4/Samples/SampleFramework/platform/include/SampleUserInputIds.h
@@ -0,0 +1,58 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+
+#ifndef SAMPLE_USER_INPUT_IDS_H
+#define SAMPLE_USER_INPUT_IDS_H
+
+
+#if defined RENDERER_WINDOWS
+#if PX_XBOXONE
+ #include <xboxone/XboxOneSampleUserInputIds.h>
+#else
+ #include <windows/WindowsSampleUserInputIds.h>
+#endif
+#elif defined (RENDERER_XBOX360)
+ #include <xbox360/Xbox360SampleUserInputIds.h>
+#elif defined (RENDERER_PS3)
+ #include <ps3/PS3SampleUserInputIds.h>
+#elif defined (RENDERER_PS4)
+ #include <ps4/PS4SampleUserInputIds.h>
+#elif defined (RENDERER_LINUX)
+ #include <linux/LinuxSampleUserInputIds.h>
+#elif defined (RENDERER_ANDROID)
+ #include <android/AndroidSampleUserInputIds.h>
+#elif defined (RENDERER_MACOSX)
+ #include <osx/OSXSampleUserInputIds.h>
+#elif defined (RENDERER_IOS)
+ #include <ios/IosSampleUserInputIds.h>
+#elif defined (RENDERER_WIIU)
+ #include <wiiu/WiiUSampleUserInputIds.h>
+#else
+ #error Unknown platform!
+#endif
+
+#endif
diff --git a/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSamplePlatform.h b/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSamplePlatform.h
new file mode 100644
index 00000000..2d300712
--- /dev/null
+++ b/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSamplePlatform.h
@@ -0,0 +1,162 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+
+#ifndef WINDOWS_SAMPLE_PLATFORM_H
+#define WINDOWS_SAMPLE_PLATFORM_H
+
+#include <SamplePlatform.h>
+#include <windows/WindowsSampleUserInput.h>
+
+struct IDirect3D9;
+struct IDirect3DDevice9;
+
+struct ID3D11Device;
+struct ID3D11DeviceContext;
+struct IDXGIFactory1;
+struct IDXGISwapChain;
+
+namespace SampleFramework
+{
+ class WindowsPlatform : public SamplePlatform
+ {
+ public:
+ explicit WindowsPlatform(SampleRenderer::RendererWindow* _app);
+ virtual ~WindowsPlatform();
+ // System
+ virtual void showCursor(bool);
+ virtual void postRendererSetup(SampleRenderer::Renderer* renderer);
+ virtual size_t getCWD(char* path, size_t len);
+ virtual void setCWDToEXE(void);
+ virtual bool openWindow(physx::PxU32& width,
+ physx::PxU32& height,
+ const char* title,
+ bool fullscreen);
+ virtual bool useWindow(physx::PxU64 hwnd);
+ virtual void update();
+ virtual bool isOpen();
+ virtual bool closeWindow();
+ virtual bool hasFocus() const;
+ virtual void getTitle(char *title, physx::PxU32 maxLength) const;
+ virtual void setTitle(const char *title);
+ virtual void setFocus(bool b);
+ virtual physx::PxU64 getWindowHandle();
+ virtual void setWindowSize(physx::PxU32 width,
+ physx::PxU32 height);
+ virtual void getWindowSize(physx::PxU32& width, physx::PxU32& height);
+ virtual void showMessage(const char* title, const char* message);
+ virtual bool saveBitmap(const char* fileName,
+ physx::PxU32 width,
+ physx::PxU32 height,
+ physx::PxU32 sizeInBytes,
+ const void* data);
+ virtual void* compileProgram(void * context,
+ const char* assetDir,
+ const char *programPath,
+ physx::PxU64 profile,
+ const char* passString,
+ const char *entry,
+ const char **args);
+ virtual void* initializeD3D9();
+ virtual bool isD3D9ok();
+ virtual void* initializeD3D11();
+ virtual bool isD3D11ok();
+ // Rendering
+ virtual void initializeOGLDisplay(const SampleRenderer::RendererDesc& desc,
+ physx::PxU32& width,
+ physx::PxU32& height);
+ virtual void postInitializeOGLDisplay();
+ virtual void setOGLVsync(bool on);
+ virtual physx::PxU32 initializeD3D9Display(void * presentParameters,
+ char* m_deviceName,
+ physx::PxU32& width,
+ physx::PxU32& height,
+ void * m_d3dDevice_out);
+ virtual physx::PxU32 initializeD3D11Display(void *dxgiSwapChainDesc,
+ char *m_deviceName,
+ physx::PxU32& width,
+ physx::PxU32& height,
+ void *m_d3dDevice_out,
+ void *m_d3dDeviceContext_out,
+ void *m_dxgiSwap_out);
+
+ virtual physx::PxU32 D3D9Present();
+ virtual physx::PxU64 getD3D9TextureFormat(SampleRenderer::RendererTexture2D::Format format);
+ virtual physx::PxU32 D3D11Present(bool vsync);
+ virtual physx::PxU64 getD3D11TextureFormat(SampleRenderer::RendererTexture2D::Format format);
+ virtual bool makeContextCurrent();
+ virtual void freeDisplay();
+ virtual bool isContextValid();
+ virtual void swapBuffers();
+ virtual void setupRendererDescription(SampleRenderer::RendererDesc& renDesc);
+ // Input
+ virtual void doInput();
+ // File System
+ virtual bool makeSureDirectoryPathExists(const char* dirPath);
+
+ virtual const SampleUserInput* getSampleUserInput() const { return &m_windowsSampleUserInput; }
+ virtual SampleUserInput* getSampleUserInput() { return &m_windowsSampleUserInput; }
+
+ WindowsSampleUserInput& getWindowsSampleUserInput() { return m_windowsSampleUserInput; }
+ const WindowsSampleUserInput& getWindowsSampleUserInput() const { return m_windowsSampleUserInput; }
+
+ virtual const char* getPlatformName() const { return m_platformName; }
+
+ virtual void setMouseCursorRecentering(bool val);
+ virtual bool getMouseCursorRecentering() const;
+
+
+ physx::PxVec2 getMouseCursorPos() const { return m_mouseCursorPos; }
+ void setMouseCursorPos(const physx::PxVec2& pos) { m_mouseCursorPos = pos; }
+ void recenterMouseCursor(bool generateEvent);
+
+ protected:
+ IDirect3D9* m_d3d;
+ IDirect3DDevice9* m_d3dDevice;
+ IDXGIFactory1* m_dxgiFactory;
+ IDXGISwapChain* m_dxgiSwap;
+ ID3D11Device* m_d3d11Device;
+ ID3D11DeviceContext* m_d3d11DeviceContext;
+ HWND m_hwnd;
+ HDC m_hdc;
+ HGLRC m_hrc;
+ HMODULE m_library;
+ HMODULE m_dxgiLibrary;
+ HMODULE m_d3d11Library;
+ bool m_ownsWindow;
+ bool m_isHandlingMessages;
+ bool m_destroyWindow;
+ bool m_hasFocus;
+ bool m_showCursor;
+ char m_platformName[256];
+ WindowsSampleUserInput m_windowsSampleUserInput;
+ physx::PxVec2 m_mouseCursorPos;
+ bool m_recenterMouseCursor;
+ bool m_vsync;
+ };
+}
+
+#endif
diff --git a/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInput.h b/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInput.h
new file mode 100644
index 00000000..2e8245e8
--- /dev/null
+++ b/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInput.h
@@ -0,0 +1,158 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+
+#ifndef WINDOWS_SAMPLE_USER_INPUT_H
+#define WINDOWS_SAMPLE_USER_INPUT_H
+
+
+#include <SampleUserInput.h>
+#include <windows/WindowsSampleUserInputIds.h>
+#include <WTypes.h>
+#include <XInput.h>
+
+namespace SampleFramework
+{
+ class WindowsSampleUserInput: public SampleUserInput
+ {
+ public:
+ enum KeyEventFlag
+ {
+ KEY_EVENT_NONE = 0,
+ KEY_EVENT_UP,
+ KEY_EVENT_DOWN,
+ };
+
+ enum MouseButtons
+ {
+ LEFT_MOUSE_BUTTON,
+ RIGHT_MOUSE_BUTTON,
+ CENTER_MOUSE_BUTTON,
+ };
+
+ struct KeyEvent
+ {
+ WPARAM m_Param;
+ USHORT m_ScanCode;
+ KeyEventFlag m_Flags;
+ };
+
+ struct InputState
+ {
+ InputState()
+ {
+ };
+
+ InputState(bool val)
+ {
+ m_State = val;
+ };
+
+ InputState(float val)
+ {
+ m_Value = val;
+ };
+
+ union
+ {
+ bool m_State;
+ float m_Value;
+ };
+ };
+
+ WindowsSampleUserInput();
+ ~WindowsSampleUserInput();
+
+ bool keyCodeToASCII( WindowsSampleUserInputIds code, char& c )
+ {
+ if( code >= KEY_A && code <= KEY_Z )
+ {
+ c = (char)code + 'A' - 1;
+ }
+ else if( code >= KEY_0 && code <= KEY_9 )
+ {
+ c = (char)code + '0' - 1;
+ }
+ else if( code == KEY_SPACE )
+ {
+ c = ' ';
+ }
+ else
+ {
+ return false;
+ }
+ return true;
+ }
+
+ void doOnMouseMove(physx::PxU32 x, physx::PxU32 y, physx::PxReal dx, physx::PxReal dy, WindowsSampleUserInputIds button);
+ void doOnMouseButton(physx::PxU32 x, physx::PxU32 y, MouseButtons button, bool down);
+ void onKeyDownEx(WPARAM wParam);
+ void onKeyDown(WPARAM wParam, LPARAM lParam);
+ void onKeyUp(WPARAM wParam, LPARAM lParam);
+ void onKeyEvent(const KeyEvent& keyEvent);
+
+ void onGamepadButton(physx::PxU32 buttonIndex, bool buttonDown);
+ void onGamepadAnalogButton(physx::PxU32 buttonIndex,const BYTE oldValue,const BYTE newValue);
+ void onGamepadAxis(physx::PxU32 axis, physx::PxReal val);
+
+ virtual void updateInput();
+ virtual void processGamepads();
+
+ virtual void shutdown();
+
+ virtual bool keyboardSupported() const { return true; }
+ virtual bool gamepadSupported() const;
+ virtual bool mouseSupported() const { return true; }
+ virtual InputType getInputType(const UserInput&) const;
+
+ virtual bool getDigitalInputEventState(physx::PxU16 inputEventId ) const;
+ virtual float getAnalogInputEventState(physx::PxU16 inputEventId ) const;
+
+ protected:
+ WindowsSampleUserInputIds getKeyCode(WPARAM wParam) const;
+ SampleUserInput::KeyCode getSampleUserInputKeyCode(WPARAM wParam) const;
+
+ const UserInput* getUserInputFromId(WindowsSampleUserInputIds id) const;
+
+ bool hasXInput() const { return mpXInputGetState && mpXInputGetCapabilities; }
+
+ std::map<physx::PxU16, physx::PxU16> mScanCodesMap;
+ std::map<physx::PxU16,float> mAnalogStates;
+ std::map<physx::PxU16,bool> mDigitalStates;
+
+ bool mGamePadConnected;
+ physx::PxU32 mConnectedPad;
+
+ typedef DWORD (WINAPI *LPXINPUTGETSTATE)(DWORD, XINPUT_STATE*);
+ typedef DWORD (WINAPI *LPXINPUTGETCAPABILITIES)(DWORD,DWORD,XINPUT_CAPABILITIES*);
+
+ HMODULE mXInputLibrary;
+ LPXINPUTGETSTATE mpXInputGetState;
+ LPXINPUTGETCAPABILITIES mpXInputGetCapabilities;
+ };
+}
+
+#endif
diff --git a/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInputIds.h b/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInputIds.h
new file mode 100644
index 00000000..a2ec823f
--- /dev/null
+++ b/PhysX_3.4/Samples/SampleFramework/platform/include/windows/WindowsSampleUserInputIds.h
@@ -0,0 +1,178 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+
+#ifndef WINDOWS_SAMPLE_USER_INPUT_IDS_H
+#define WINDOWS_SAMPLE_USER_INPUT_IDS_H
+
+
+namespace SampleFramework
+{
+ enum WindowsSampleUserInputIds
+ {
+ WKEY_UNKNOWN = 0,
+
+ WKEY_DEFINITION_START,
+
+ WKEY_A,
+ WKEY_B,
+ WKEY_C,
+ WKEY_D,
+ WKEY_E,
+ WKEY_F,
+ WKEY_G,
+ WKEY_H,
+ WKEY_I,
+ WKEY_J,
+ WKEY_K,
+ WKEY_L,
+ WKEY_M,
+ WKEY_N,
+ WKEY_O,
+ WKEY_P,
+ WKEY_Q,
+ WKEY_R,
+ WKEY_S,
+ WKEY_T,
+ WKEY_U,
+ WKEY_V,
+ WKEY_W,
+ WKEY_X,
+ WKEY_Y,
+ WKEY_Z,
+
+ WKEY_0,
+ WKEY_1,
+ WKEY_2,
+ WKEY_3,
+ WKEY_4,
+ WKEY_5,
+ WKEY_6,
+ WKEY_7,
+ WKEY_8,
+ WKEY_9,
+
+ WKEY_SPACE,
+ WKEY_RETURN,
+ WKEY_SHIFT,
+ WKEY_CONTROL,
+ WKEY_ESCAPE,
+ WKEY_COMMA,
+ WKEY_NUMPAD0,
+ WKEY_NUMPAD1,
+ WKEY_NUMPAD2,
+ WKEY_NUMPAD3,
+ WKEY_NUMPAD4,
+ WKEY_NUMPAD5,
+ WKEY_NUMPAD6,
+ WKEY_NUMPAD7,
+ WKEY_NUMPAD8,
+ WKEY_NUMPAD9,
+ WKEY_MULTIPLY,
+ WKEY_ADD,
+ WKEY_SEPARATOR,
+ WKEY_SUBTRACT,
+ WKEY_DECIMAL,
+ WKEY_DIVIDE,
+
+ WKEY_F1,
+ WKEY_F2,
+ WKEY_F3,
+ WKEY_F4,
+ WKEY_F5,
+ WKEY_F6,
+ WKEY_F7,
+ WKEY_F8,
+ WKEY_F9,
+ WKEY_F10,
+ WKEY_F11,
+ WKEY_F12,
+
+ WKEY_TAB,
+ WKEY_BACKSPACE,
+ WKEY_PRIOR,
+ WKEY_NEXT,
+ WKEY_UP,
+ WKEY_DOWN,
+ WKEY_LEFT,
+ WKEY_RIGHT,
+
+ SCAN_CODE_UP ,
+ SCAN_CODE_DOWN ,
+ SCAN_CODE_LEFT,
+ SCAN_CODE_RIGHT,
+ SCAN_CODE_FORWARD,
+ SCAN_CODE_BACKWARD,
+ SCAN_CODE_LEFT_SHIFT,
+ SCAN_CODE_SPACE,
+ SCAN_CODE_L,
+ SCAN_CODE_9,
+ SCAN_CODE_0,
+
+ WKEY_DEFINITION_END,
+
+ MOUSE_DEFINITION_START,
+
+ MOUSE_BUTTON_LEFT,
+ MOUSE_BUTTON_RIGHT,
+ MOUSE_BUTTON_CENTER,
+
+ MOUSE_MOVE,
+
+ MOUSE_DEFINITION_END,
+
+ GAMEPAD_DEFINITION_START,
+
+ GAMEPAD_DIGI_UP,
+ GAMEPAD_DIGI_DOWN,
+ GAMEPAD_DIGI_LEFT,
+ GAMEPAD_DIGI_RIGHT,
+ GAMEPAD_START,
+ GAMEPAD_SELECT,
+ GAMEPAD_LEFT_STICK,
+ GAMEPAD_RIGHT_STICK,
+ GAMEPAD_NORTH,
+ GAMEPAD_SOUTH,
+ GAMEPAD_WEST,
+ GAMEPAD_EAST,
+ GAMEPAD_LEFT_SHOULDER_TOP,
+ GAMEPAD_RIGHT_SHOULDER_TOP,
+ GAMEPAD_LEFT_SHOULDER_BOT,
+ GAMEPAD_RIGHT_SHOULDER_BOT,
+
+ GAMEPAD_RIGHT_STICK_X,
+ GAMEPAD_RIGHT_STICK_Y,
+ GAMEPAD_LEFT_STICK_X ,
+ GAMEPAD_LEFT_STICK_Y ,
+
+ GAMEPAD_DEFINITION_END,
+
+ NUM_KEY_CODES,
+ };
+
+}
+
+#endif