From 0934b0a27af581ddc1ff375faa528e5520582020 Mon Sep 17 00:00:00 2001 From: xawotihs Date: Sun, 14 Dec 2014 22:04:31 +0100 Subject: [PATCH] Moved to VS2013 and latest SpriteBatch --- JGE/Dependencies/libjpeg/jconfig.h | 3 +- JGE/Dependencies/libjpeg/libjpeg.vcxproj | 62 +- JGE/Dependencies/libpng/libpng.vcxproj | 64 +- JGE/Dependencies/zlib/zlib.vcxproj | 62 +- JGE/JGE - win8.vcxproj | 283 ++++- JGE/include/JRenderer.h | 8 + JGE/include/JTypes.h | 54 +- JGE/src/DirectX/AlignedNew.h | 67 + JGE/src/DirectX/BasicLoader.cpp | 672 ---------- JGE/src/DirectX/BasicLoader.h | 155 --- JGE/src/DirectX/BasicMath.h | 531 -------- JGE/src/DirectX/BasicReaderWriter.cpp | 175 --- JGE/src/DirectX/BasicReaderWriter.h | 43 - JGE/src/DirectX/BasicShapes.h | 88 -- .../BasicSprites.GeometryShader.gs.hlsl | 95 -- .../BasicSprites.GeometryShader.vs.hlsl | 44 - .../DirectX/BasicSprites.Instancing.vs.hlsl | 51 - .../DirectX/BasicSprites.Replication.vs.hlsl | 32 - JGE/src/DirectX/BasicSprites.cpp | 988 --------------- JGE/src/DirectX/BasicSprites.h | 195 --- JGE/src/DirectX/BasicSprites.ps.hlsl | 24 - JGE/src/DirectX/CommonStates.cpp | 373 ++++++ JGE/src/DirectX/CommonStates.h | 70 ++ JGE/src/DirectX/ConstantBuffer.h | 85 ++ JGE/src/DirectX/DemandCreate.h | 51 + JGE/src/DirectX/DirectXHelpers.h | 120 ++ JGE/src/DirectX/JGfx.cpp | 346 ++++-- JGE/src/DirectX/PlatformHelpers.h | 110 ++ .../SpriteEffect_SpritePixelShader.inc | 137 +++ .../SpriteEffect_SpriteVertexShader.inc | 213 ++++ JGE/src/DirectX/SharedResourcePool.h | 108 ++ JGE/src/DirectX/SpriteBatch.cpp | 1086 +++++++++++++++++ JGE/src/DirectX/SpriteBatch.h | 110 ++ JGE/src/DirectX/VertexTypes.cpp | 166 +++ JGE/src/DirectX/VertexTypes.h | 331 +++++ JGE/src/JFileSystem.cpp | 5 +- JGE/src/WRLmain.cpp | 48 +- JGE/src/zipFS/fileio.h | 2 - projects/mtg/WRL/Assets/Logo.png | Bin 0 -> 801 bytes projects/mtg/WRL/Assets/Logo.scale-240.png | Bin 0 -> 2516 bytes projects/mtg/WRL/Assets/SmallLogo.png | Bin 0 -> 329 bytes .../mtg/WRL/Assets/SmallLogo.scale-100.png | Bin 0 -> 6819 bytes .../mtg/WRL/Assets/SmallLogo.scale-240.png | Bin 0 -> 753 bytes projects/mtg/WRL/Assets/SplashScreen.png | Bin 0 -> 2146 bytes .../mtg/WRL/Assets/SplashScreen.scale-240.png | Bin 0 -> 14715 bytes .../WRL/Assets/Square71x71Logo.scale-240.png | Bin 0 -> 1122 bytes projects/mtg/WRL/Assets/StoreLogo.png | Bin 0 -> 429 bytes .../mtg/WRL/Assets/StoreLogo.scale-240.png | Bin 0 -> 2200 bytes .../mtg/WRL/Assets/WideLogo.scale-240.png | Bin 0 -> 4530 bytes projects/mtg/WRL/Wagic.Shared.vcxitems | 38 + .../mtg/WRL/Wagic.Shared.vcxitems.filters | 11 + .../Wagic.WindowsDesktop.Package.appxmanifest | 35 + projects/mtg/WRL/Wagic.WindowsDesktop.vcxproj | 176 +++ .../Wagic.WindowsPhone.Package.appxmanifest | 43 + projects/mtg/WRL/Wagic.WindowsPhone.vcxproj | 138 +++ .../WRL/Wagic.WindowsPhone.vcxproj.filters | 36 + projects/mtg/WRL/Wagic.sln | 195 +++ projects/mtg/WRL/Wagic.vcxproj.filters | 249 ++++ projects/mtg/WRL/wagic.vcxproj | 787 ++++++++++++ projects/mtg/include/GameStateMenu.h | 1 - projects/mtg/include/MTGDeck.h | 2 +- projects/mtg/include/PrecompiledHeader.h | 52 +- projects/mtg/src/GameObserver.cpp | 2 +- projects/mtg/src/GameStateStory.cpp | 1 - projects/mtg/src/MTGPack.cpp | 2 - projects/mtg/src/OptionItem.cpp | 1 - projects/mtg/src/utils.cpp | 2 +- 67 files changed, 5541 insertions(+), 3287 deletions(-) create mode 100644 JGE/src/DirectX/AlignedNew.h delete mode 100644 JGE/src/DirectX/BasicLoader.cpp delete mode 100644 JGE/src/DirectX/BasicLoader.h delete mode 100644 JGE/src/DirectX/BasicMath.h delete mode 100644 JGE/src/DirectX/BasicReaderWriter.cpp delete mode 100644 JGE/src/DirectX/BasicReaderWriter.h delete mode 100644 JGE/src/DirectX/BasicShapes.h delete mode 100644 JGE/src/DirectX/BasicSprites.GeometryShader.gs.hlsl delete mode 100644 JGE/src/DirectX/BasicSprites.GeometryShader.vs.hlsl delete mode 100644 JGE/src/DirectX/BasicSprites.Instancing.vs.hlsl delete mode 100644 JGE/src/DirectX/BasicSprites.Replication.vs.hlsl delete mode 100644 JGE/src/DirectX/BasicSprites.cpp delete mode 100644 JGE/src/DirectX/BasicSprites.h delete mode 100644 JGE/src/DirectX/BasicSprites.ps.hlsl create mode 100644 JGE/src/DirectX/CommonStates.cpp create mode 100644 JGE/src/DirectX/CommonStates.h create mode 100644 JGE/src/DirectX/ConstantBuffer.h create mode 100644 JGE/src/DirectX/DemandCreate.h create mode 100644 JGE/src/DirectX/DirectXHelpers.h create mode 100644 JGE/src/DirectX/PlatformHelpers.h create mode 100644 JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpritePixelShader.inc create mode 100644 JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc create mode 100644 JGE/src/DirectX/SharedResourcePool.h create mode 100644 JGE/src/DirectX/SpriteBatch.cpp create mode 100644 JGE/src/DirectX/SpriteBatch.h create mode 100644 JGE/src/DirectX/VertexTypes.cpp create mode 100644 JGE/src/DirectX/VertexTypes.h create mode 100644 projects/mtg/WRL/Assets/Logo.png create mode 100644 projects/mtg/WRL/Assets/Logo.scale-240.png create mode 100644 projects/mtg/WRL/Assets/SmallLogo.png create mode 100644 projects/mtg/WRL/Assets/SmallLogo.scale-100.png create mode 100644 projects/mtg/WRL/Assets/SmallLogo.scale-240.png create mode 100644 projects/mtg/WRL/Assets/SplashScreen.png create mode 100644 projects/mtg/WRL/Assets/SplashScreen.scale-240.png create mode 100644 projects/mtg/WRL/Assets/Square71x71Logo.scale-240.png create mode 100644 projects/mtg/WRL/Assets/StoreLogo.png create mode 100644 projects/mtg/WRL/Assets/StoreLogo.scale-240.png create mode 100644 projects/mtg/WRL/Assets/WideLogo.scale-240.png create mode 100644 projects/mtg/WRL/Wagic.Shared.vcxitems create mode 100644 projects/mtg/WRL/Wagic.Shared.vcxitems.filters create mode 100644 projects/mtg/WRL/Wagic.WindowsDesktop.Package.appxmanifest create mode 100644 projects/mtg/WRL/Wagic.WindowsDesktop.vcxproj create mode 100644 projects/mtg/WRL/Wagic.WindowsPhone.Package.appxmanifest create mode 100644 projects/mtg/WRL/Wagic.WindowsPhone.vcxproj create mode 100644 projects/mtg/WRL/Wagic.WindowsPhone.vcxproj.filters create mode 100644 projects/mtg/WRL/Wagic.sln create mode 100644 projects/mtg/WRL/Wagic.vcxproj.filters create mode 100644 projects/mtg/WRL/wagic.vcxproj diff --git a/JGE/Dependencies/libjpeg/jconfig.h b/JGE/Dependencies/libjpeg/jconfig.h index e7f0c63ec..9f93d4ef3 100644 --- a/JGE/Dependencies/libjpeg/jconfig.h +++ b/JGE/Dependencies/libjpeg/jconfig.h @@ -77,10 +77,11 @@ #ifdef XP_MAC /* Macintosh */ #define ALIGN_TYPE long /* for sane memory alignment */ -#define NO_GETENV /* we do have the function, but it's dead */ #endif /* XP_MAC */ +#define NO_GETENV /* we don't care of that feature */ + #endif /* JPEG_INTERNALS */ diff --git a/JGE/Dependencies/libjpeg/libjpeg.vcxproj b/JGE/Dependencies/libjpeg/libjpeg.vcxproj index 7f6bb7a25..6d80604f9 100644 --- a/JGE/Dependencies/libjpeg/libjpeg.vcxproj +++ b/JGE/Dependencies/libjpeg/libjpeg.vcxproj @@ -1,10 +1,18 @@  - + + + Debug + ARM + Debug Win32 + + Release + ARM + Release Win32 @@ -19,13 +27,23 @@ StaticLibrary true - v110 Unicode + + StaticLibrary + true + Unicode + v110_wp80 + StaticLibrary false - v110 + true + Unicode + + + StaticLibrary + false true Unicode @@ -35,9 +53,15 @@ + + + + + + @@ -54,6 +78,20 @@ true + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS + true + + + Windows + true + + Level3 @@ -72,6 +110,24 @@ true + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS + true + + + Windows + true + true + true + + diff --git a/JGE/Dependencies/libpng/libpng.vcxproj b/JGE/Dependencies/libpng/libpng.vcxproj index c6ae47723..5f5de7ea2 100644 --- a/JGE/Dependencies/libpng/libpng.vcxproj +++ b/JGE/Dependencies/libpng/libpng.vcxproj @@ -1,10 +1,18 @@  - + + + Debug + ARM + Debug Win32 + + Release + ARM + Release Win32 @@ -19,13 +27,23 @@ StaticLibrary true - v110 Unicode + + StaticLibrary + true + Unicode + v110_wp80 + StaticLibrary false - v110 + true + Unicode + + + StaticLibrary + false true Unicode @@ -35,9 +53,15 @@ + + + + + + @@ -55,6 +79,21 @@ true + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS + true + ../zlib + + + Windows + true + + Level3 @@ -74,6 +113,25 @@ true + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS + true + ../zlib + + + Windows + true + true + true + + diff --git a/JGE/Dependencies/zlib/zlib.vcxproj b/JGE/Dependencies/zlib/zlib.vcxproj index 577e87994..d4a9a0c18 100644 --- a/JGE/Dependencies/zlib/zlib.vcxproj +++ b/JGE/Dependencies/zlib/zlib.vcxproj @@ -1,10 +1,18 @@  - + + + Debug + ARM + Debug Win32 + + Release + ARM + Release Win32 @@ -19,13 +27,23 @@ StaticLibrary true - v110 Unicode + + StaticLibrary + true + Unicode + v110_wp80 + StaticLibrary false - v110 + true + Unicode + + + StaticLibrary + false true Unicode @@ -35,9 +53,15 @@ + + + + + + @@ -54,6 +78,20 @@ true + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + + Level3 @@ -72,6 +110,24 @@ true + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + diff --git a/JGE/JGE - win8.vcxproj b/JGE/JGE - win8.vcxproj index 100c1a559..5be0ac6cc 100644 --- a/JGE/JGE - win8.vcxproj +++ b/JGE/JGE - win8.vcxproj @@ -1,14 +1,26 @@  - + + + Debug + ARM + Debug Win32 + + Profile + ARM + Profile Win32 + + Release + ARM + Release Win32 @@ -17,27 +29,50 @@ {89159C26-2282-404A-A194-103B0A49DF7B} JGE + 12.0 + Windows Store + 8.1 StaticLibrary false MultiByte - v110 + v120 + true + + + StaticLibrary + false + MultiByte + v120 true StaticLibrary false MultiByte - v110 + v120 + true + + + StaticLibrary + false + MultiByte true StaticLibrary false MultiByte - v110 + v120 + true + + + StaticLibrary + false + MultiByte + v120 true @@ -47,42 +82,76 @@ + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ + $(Platform)\$(Configuration)\JGE + $(SolutionDir)$(Platform)\$(Configuration)\JGE\ + $(Platform)\$(Configuration)\JGE $(SolutionDir)$(Configuration)\ - $(Configuration)\ + $(Platform)\$(Configuration)\JGE MinimumRecommendedRules.ruleset + MinimumRecommendedRules.ruleset + + AllRules.ruleset + AllRules.ruleset + + AllRules.ruleset + AllRules.ruleset + + JGE + + JGE + $(Platform)\$(Configuration)\JGE + JGE + + $(SolutionDir)$(Platform)\$(Configuration)\JGE\ + JGE + $(Platform)\$(Configuration)\JGE + JGE + + JGE + $(Platform)\$(Configuration)\JGE + MaxSpeed @@ -113,10 +182,40 @@ LIBCMT;%(IgnoreSpecificDefaultLibraries) + + + MaxSpeed + OnlyExplicitInline + src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + + .\Release/JGE.pch + .\Release/ + .\Release/ + .\Release/ + Level3 + true + Default + true + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c09 + + + true + LIBCMT;%(IgnoreSpecificDefaultLibraries) + + Disabled - src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) + src/DirectX;src/zipFS;Dependencies/SDL/include;Dependencies/include;../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) TIXML_USE_STL;WP8;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDLL @@ -141,6 +240,34 @@ true + + + Disabled + TIXML_USE_STL;WP8;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDLL + + + .\Debug/JGE.pch + .\Debug/ + .\Debug/ + .\Debug/ + Level3 + true + ProgramDatabase + Default + true + false + src/DirectX;src/zipFS;Dependencies/SDL/include;Dependencies/include;../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c09 + + + true + + Full @@ -172,83 +299,177 @@ LIBCMT;%(IgnoreSpecificDefaultLibraries) + + + Full + OnlyExplicitInline + src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + + .\Release/JGE.pch + .\Release/ + .\Release/ + .\Release/ + Level3 + true + ProgramDatabase + Default + true + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c09 + + + true + LIBCMT;%(IgnoreSpecificDefaultLibraries) + + + + + Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) - Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) false + false Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) @@ -260,28 +481,48 @@ Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) Disabled + Disabled %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) EnableFastChecks + EnableFastChecks MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) @@ -293,10 +534,6 @@ - - - - @@ -340,13 +577,17 @@ + + + + + + + + + - - - - - @@ -355,10 +596,6 @@ - - - - diff --git a/JGE/include/JRenderer.h b/JGE/include/JRenderer.h index d132e9718..f0d9d600f 100644 --- a/JGE/include/JRenderer.h +++ b/JGE/include/JRenderer.h @@ -58,6 +58,13 @@ typedef struct } ESMatrix; #endif // (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) +#ifdef WP8 +namespace DirectX { + class SpriteBatch; +}; + +#endif + ////////////////////////////////////////////////////////////////////////// /// A collection of core rendering functions. /// @@ -604,6 +611,7 @@ private: Microsoft::WRL::ComPtr m_Window; ID3D11Buffer* m_vertexBuffer; ID3D11Buffer* m_indexBuffer; + DirectX::SpriteBatch* m_spriteBatch; #elif (!defined PSP) && (!defined WP8) && (!defined CONSOLE_CONFIG) diff --git a/JGE/include/JTypes.h b/JGE/include/JTypes.h index c8f3f6b60..b7e2d609a 100644 --- a/JGE/include/JTypes.h +++ b/JGE/include/JTypes.h @@ -25,17 +25,57 @@ #include #include "JAudio.h" -#else - -#include +#elif defined WP8 +#if !defined(WIN32_LEAN_AND_MEAN) +#define WIN32_LEAN_AND_MEAN #endif -#ifdef WP8 -#define _XM_NO_INTRINSICS_ -#include +#if !defined(NOMINMAX) +#define NOMINMAX +#endif + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#define DCOMMON_H_INCLUDED +#define NO_D3D11_DEBUG_NAME +#else #include +#endif + #include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// VS 2010's stdint.h conflicts with intsafe.h +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + +#include + +namespace DirectX +{ +#if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) +#define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; +#endif +} +#else +#include #endif #ifndef __GNUC__ @@ -406,7 +446,7 @@ public: bool mInVideoRAM; PIXEL_TYPE* mBits; #elif defined (WP8) - ID3D11Texture2D* mTexId; + ID3D11ShaderResourceView* mTexId; u8* mBuffer; #else GLuint mTexId; diff --git a/JGE/src/DirectX/AlignedNew.h b/JGE/src/DirectX/AlignedNew.h new file mode 100644 index 000000000..4c33c3388 --- /dev/null +++ b/JGE/src/DirectX/AlignedNew.h @@ -0,0 +1,67 @@ +//-------------------------------------------------------------------------------------- +// File: AlignedNew.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include + + +namespace DirectX +{ + // Derive from this to customize operator new and delete for + // types that have special heap alignment requirements. + // + // Example usage: + // + // __declspec(align(16)) struct MyAlignedType : public AlignedNew + + template + struct AlignedNew + { + // Allocate aligned memory. + static void* operator new (size_t size) + { + const size_t alignment = __alignof(TDerived); + + static_assert(alignment > 8, "AlignedNew is only useful for types with > 8 byte alignment. Did you forget a __declspec(align) on TDerived?"); + + void* ptr = _aligned_malloc(size, alignment); + + if (!ptr) + throw std::bad_alloc(); + + return ptr; + } + + + // Free aligned memory. + static void operator delete (void* ptr) + { + _aligned_free(ptr); + } + + + // Array overloads. + static void* operator new[] (size_t size) + { + return operator new(size); + } + + + static void operator delete[] (void* ptr) + { + operator delete(ptr); + } + }; +} diff --git a/JGE/src/DirectX/BasicLoader.cpp b/JGE/src/DirectX/BasicLoader.cpp deleted file mode 100644 index 42a6297b7..000000000 --- a/JGE/src/DirectX/BasicLoader.cpp +++ /dev/null @@ -1,672 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -#include -#include -#include -#include -#include -#include -#include "BasicLoader.h" -#include "BasicShapes.h" -#include - -using namespace Microsoft::WRL; -using namespace Windows::Storage; -using namespace Windows::Storage::Streams; -using namespace Windows::Foundation; -using namespace Windows::ApplicationModel; -using namespace std; -using namespace concurrency; - -BasicLoader::BasicLoader( - _In_ ID3D11Device* d3dDevice -// , _In_opt_ IWICImagingFactory2* wicFactory - ) : - m_d3dDevice(d3dDevice)//, -// m_wicFactory(wicFactory) -{ - // Create a new BasicReaderWriter to do raw file I/O. - m_basicReaderWriter = ref new BasicReaderWriter(); -} - -template -inline void BasicLoader::SetDebugName( - _In_ DeviceChildType* object, - _In_ Platform::String^ name - ) -{ -#if defined(_DEBUG) - // Only assign debug names in debug builds. - - char nameString[1024]; - int nameStringLength = WideCharToMultiByte( - CP_ACP, - 0, - name->Data(), - -1, - nameString, - 1024, - nullptr, - nullptr - ); - - if (nameStringLength == 0) - { - char defaultNameString[] = "BasicLoaderObject"; - DX::ThrowIfFailed( - object->SetPrivateData( - WKPDID_D3DDebugObjectName, - sizeof(defaultNameString) - 1, - defaultNameString - ) - ); - } - else - { - DX::ThrowIfFailed( - object->SetPrivateData( - WKPDID_D3DDebugObjectName, - nameStringLength - 1, - nameString - ) - ); - } -#endif -} - -Platform::String^ BasicLoader::GetExtension( - _In_ Platform::String^ filename - ) -{ - int lastDotIndex = -1; - for (int i = filename->Length() - 1; i >= 0 && lastDotIndex == -1; i--) - { - if (*(filename->Data() + i) == '.') - { - lastDotIndex = i; - } - } - if (lastDotIndex != -1) - { - std::unique_ptr extension(new wchar_t[filename->Length() - lastDotIndex]); - for (unsigned int i = 0; i < filename->Length() - lastDotIndex; i++) - { - extension[i] = tolower(*(filename->Data() + lastDotIndex + 1 + i)); - } - return ref new Platform::String(extension.get()); - } - return ""; -} - - -void BasicLoader::CreateInputLayout( - _In_reads_bytes_(bytecodeSize) byte* bytecode, - _In_ uint32 bytecodeSize, - _In_reads_opt_(layoutDescNumElements) D3D11_INPUT_ELEMENT_DESC* layoutDesc, - _In_ uint32 layoutDescNumElements, - _Out_ ID3D11InputLayout** layout - ) -{ - if (layoutDesc == nullptr) - { - // If no input layout is specified, use the BasicVertex layout. - const D3D11_INPUT_ELEMENT_DESC basicVertexLayoutDesc[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - DX::ThrowIfFailed( - m_d3dDevice->CreateInputLayout( - basicVertexLayoutDesc, - ARRAYSIZE(basicVertexLayoutDesc), - bytecode, - bytecodeSize, - layout - ) - ); - } - else - { - DX::ThrowIfFailed( - m_d3dDevice->CreateInputLayout( - layoutDesc, - layoutDescNumElements, - bytecode, - bytecodeSize, - layout - ) - ); - } -} - -void BasicLoader::CreateMesh( - _In_ byte* meshData, - _Out_ ID3D11Buffer** vertexBuffer, - _Out_ ID3D11Buffer** indexBuffer, - _Out_opt_ uint32* vertexCount, - _Out_opt_ uint32* indexCount, - _In_opt_ Platform::String^ debugName - ) -{ - // The first 4 bytes of the BasicMesh format define the number of vertices in the mesh. - uint32 numVertices = *reinterpret_cast(meshData); - - // The following 4 bytes define the number of indices in the mesh. - uint32 numIndices = *reinterpret_cast(meshData + sizeof(uint32)); - - // The next segment of the BasicMesh format contains the vertices of the mesh. - BasicVertex* vertices = reinterpret_cast(meshData + sizeof(uint32) * 2); - - // The last segment of the BasicMesh format contains the indices of the mesh. - uint16* indices = reinterpret_cast(meshData + sizeof(uint32) * 2 + sizeof(BasicVertex) * numVertices); - - // Create the vertex and index buffers with the mesh data. - - D3D11_SUBRESOURCE_DATA vertexBufferData = {0}; - vertexBufferData.pSysMem = vertices; - vertexBufferData.SysMemPitch = 0; - vertexBufferData.SysMemSlicePitch = 0; - CD3D11_BUFFER_DESC vertexBufferDesc(numVertices * sizeof(BasicVertex), D3D11_BIND_VERTEX_BUFFER); - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &vertexBufferDesc, - &vertexBufferData, - vertexBuffer - ) - ); - - D3D11_SUBRESOURCE_DATA indexBufferData = {0}; - indexBufferData.pSysMem = indices; - indexBufferData.SysMemPitch = 0; - indexBufferData.SysMemSlicePitch = 0; - CD3D11_BUFFER_DESC indexBufferDesc(numIndices * sizeof(uint16), D3D11_BIND_INDEX_BUFFER); - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &indexBufferDesc, - &indexBufferData, - indexBuffer - ) - ); - - SetDebugName(*vertexBuffer, Platform::String::Concat(debugName, "_VertexBuffer")); - SetDebugName(*indexBuffer, Platform::String::Concat(debugName, "_IndexBuffer")); - - if (vertexCount != nullptr) - { - *vertexCount = numVertices; - } - if (indexCount != nullptr) - { - *indexCount = numIndices; - } -} - -void BasicLoader::LoadShader( - _In_ Platform::String^ filename, - _In_reads_opt_(layoutDescNumElements) D3D11_INPUT_ELEMENT_DESC layoutDesc[], - _In_ uint32 layoutDescNumElements, - _Out_ ID3D11VertexShader** shader, - _Out_opt_ ID3D11InputLayout** layout - ) -{ - Platform::Array^ bytecode = m_basicReaderWriter->ReadData(filename); - - DX::ThrowIfFailed( - m_d3dDevice->CreateVertexShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - - if (layout != nullptr) - { - CreateInputLayout( - bytecode->Data, - bytecode->Length, - layoutDesc, - layoutDescNumElements, - layout - ); - - SetDebugName(*layout, filename); - } -} - -task BasicLoader::LoadShaderAsync( - _In_ Platform::String^ filename, - _In_reads_opt_(layoutDescNumElements) D3D11_INPUT_ELEMENT_DESC layoutDesc[], - _In_ uint32 layoutDescNumElements, - _Out_ ID3D11VertexShader** shader, - _Out_opt_ ID3D11InputLayout** layout - ) -{ - // This method assumes that the lifetime of input arguments may be shorter - // than the duration of this task. In order to ensure accurate results, a - // copy of all arguments passed by pointer must be made. The method then - // ensures that the lifetime of the copied data exceeds that of the task. - - // Create copies of the layoutDesc array as well as the SemanticName strings, - // both of which are pointers to data whose lifetimes may be shorter than that - // of this method's task. - shared_ptr> layoutDescCopy; - shared_ptr> layoutDescSemanticNamesCopy; - if (layoutDesc != nullptr) - { - layoutDescCopy.reset( - new vector( - layoutDesc, - layoutDesc + layoutDescNumElements - ) - ); - - layoutDescSemanticNamesCopy.reset( - new vector(layoutDescNumElements) - ); - - for (uint32 i = 0; i < layoutDescNumElements; i++) - { - layoutDescSemanticNamesCopy->at(i).assign(layoutDesc[i].SemanticName); - } - } - - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ bytecode) - { - DX::ThrowIfFailed( - m_d3dDevice->CreateVertexShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - - if (layout != nullptr) - { - if (layoutDesc != nullptr) - { - // Reassign the SemanticName elements of the layoutDesc array copy to point - // to the corresponding copied strings. Performing the assignment inside the - // lambda body ensures that the lambda will take a reference to the shared_ptr - // that holds the data. This will guarantee that the data is still valid when - // CreateInputLayout is called. - for (uint32 i = 0; i < layoutDescNumElements; i++) - { - layoutDescCopy->at(i).SemanticName = layoutDescSemanticNamesCopy->at(i).c_str(); - } - } - - CreateInputLayout( - bytecode->Data, - bytecode->Length, - layoutDesc == nullptr ? nullptr : layoutDescCopy->data(), - layoutDescNumElements, - layout - ); - - SetDebugName(*layout, filename); - } - }); -} - -void BasicLoader::LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11PixelShader** shader - ) -{ - Platform::Array^ bytecode = m_basicReaderWriter->ReadData(filename); - - DX::ThrowIfFailed( - m_d3dDevice->CreatePixelShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); -} - -task BasicLoader::LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11PixelShader** shader - ) -{ - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ bytecode) - { - DX::ThrowIfFailed( - m_d3dDevice->CreatePixelShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - }); -} - -void BasicLoader::LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11ComputeShader** shader - ) -{ - Platform::Array^ bytecode = m_basicReaderWriter->ReadData(filename); - - DX::ThrowIfFailed( - m_d3dDevice->CreateComputeShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); -} - -task BasicLoader::LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11ComputeShader** shader - ) -{ - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ bytecode) - { - DX::ThrowIfFailed( - m_d3dDevice->CreateComputeShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - }); -} - -void BasicLoader::LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11GeometryShader** shader - ) -{ - Platform::Array^ bytecode = m_basicReaderWriter->ReadData(filename); - - DX::ThrowIfFailed( - m_d3dDevice->CreateGeometryShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); -} - -task BasicLoader::LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11GeometryShader** shader - ) -{ - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ bytecode) - { - DX::ThrowIfFailed( - m_d3dDevice->CreateGeometryShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - }); -} - -void BasicLoader::LoadShader( - _In_ Platform::String^ filename, - _In_reads_opt_(numEntries) const D3D11_SO_DECLARATION_ENTRY* streamOutDeclaration, - _In_ uint32 numEntries, - _In_reads_opt_(numStrides) const uint32* bufferStrides, - _In_ uint32 numStrides, - _In_ uint32 rasterizedStream, - _Out_ ID3D11GeometryShader** shader - ) -{ - Platform::Array^ bytecode = m_basicReaderWriter->ReadData(filename); - - DX::ThrowIfFailed( - m_d3dDevice->CreateGeometryShaderWithStreamOutput( - bytecode->Data, - bytecode->Length, - streamOutDeclaration, - numEntries, - bufferStrides, - numStrides, - rasterizedStream, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); -} - -task BasicLoader::LoadShaderAsync( - _In_ Platform::String^ filename, - _In_reads_opt_(numEntries) const D3D11_SO_DECLARATION_ENTRY* streamOutDeclaration, - _In_ uint32 numEntries, - _In_reads_opt_(numStrides) const uint32* bufferStrides, - _In_ uint32 numStrides, - _In_ uint32 rasterizedStream, - _Out_ ID3D11GeometryShader** shader - ) -{ - // This method assumes that the lifetime of input arguments may be shorter - // than the duration of this task. In order to ensure accurate results, a - // copy of all arguments passed by pointer must be made. The method then - // ensures that the lifetime of the copied data exceeds that of the task. - - // Create copies of the streamOutDeclaration array as well as the SemanticName - // strings, both of which are pointers to data whose lifetimes may be shorter - // than that of this method's task. - shared_ptr> streamOutDeclarationCopy; - shared_ptr> streamOutDeclarationSemanticNamesCopy; - if (streamOutDeclaration != nullptr) - { - streamOutDeclarationCopy.reset( - new vector( - streamOutDeclaration, - streamOutDeclaration + numEntries - ) - ); - - streamOutDeclarationSemanticNamesCopy.reset( - new vector(numEntries) - ); - - for (uint32 i = 0; i < numEntries; i++) - { - streamOutDeclarationSemanticNamesCopy->at(i).assign(streamOutDeclaration[i].SemanticName); - } - } - - // Create a copy of the bufferStrides array, which is a pointer to data - // whose lifetime may be shorter than that of this method's task. - shared_ptr> bufferStridesCopy; - if (bufferStrides != nullptr) - { - bufferStridesCopy.reset( - new vector( - bufferStrides, - bufferStrides + numStrides - ) - ); - } - - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ bytecode) - { - if (streamOutDeclaration != nullptr) - { - // Reassign the SemanticName elements of the streamOutDeclaration array copy to - // point to the corresponding copied strings. Performing the assignment inside the - // lambda body ensures that the lambda will take a reference to the shared_ptr - // that holds the data. This will guarantee that the data is still valid when - // CreateGeometryShaderWithStreamOutput is called. - for (uint32 i = 0; i < numEntries; i++) - { - streamOutDeclarationCopy->at(i).SemanticName = streamOutDeclarationSemanticNamesCopy->at(i).c_str(); - } - } - - DX::ThrowIfFailed( - m_d3dDevice->CreateGeometryShaderWithStreamOutput( - bytecode->Data, - bytecode->Length, - streamOutDeclaration == nullptr ? nullptr : streamOutDeclarationCopy->data(), - numEntries, - bufferStrides == nullptr ? nullptr : bufferStridesCopy->data(), - numStrides, - rasterizedStream, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - }); -} - -void BasicLoader::LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11HullShader** shader - ) -{ - Platform::Array^ bytecode = m_basicReaderWriter->ReadData(filename); - - DX::ThrowIfFailed( - m_d3dDevice->CreateHullShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); -} - -task BasicLoader::LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11HullShader** shader - ) -{ - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ bytecode) - { - DX::ThrowIfFailed( - m_d3dDevice->CreateHullShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - }); -} - -void BasicLoader::LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11DomainShader** shader - ) -{ - Platform::Array^ bytecode = m_basicReaderWriter->ReadData(filename); - - DX::ThrowIfFailed( - m_d3dDevice->CreateDomainShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); -} - -task BasicLoader::LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11DomainShader** shader - ) -{ - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ bytecode) - { - DX::ThrowIfFailed( - m_d3dDevice->CreateDomainShader( - bytecode->Data, - bytecode->Length, - nullptr, - shader - ) - ); - - SetDebugName(*shader, filename); - }); -} - -void BasicLoader::LoadMesh( - _In_ Platform::String^ filename, - _Out_ ID3D11Buffer** vertexBuffer, - _Out_ ID3D11Buffer** indexBuffer, - _Out_opt_ uint32* vertexCount, - _Out_opt_ uint32* indexCount - ) -{ - Platform::Array^ meshData = m_basicReaderWriter->ReadData(filename); - - CreateMesh( - meshData->Data, - vertexBuffer, - indexBuffer, - vertexCount, - indexCount, - filename - ); -} - -task BasicLoader::LoadMeshAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11Buffer** vertexBuffer, - _Out_ ID3D11Buffer** indexBuffer, - _Out_opt_ uint32* vertexCount, - _Out_opt_ uint32* indexCount - ) -{ - return m_basicReaderWriter->ReadDataAsync(filename).then([=](const Platform::Array^ meshData) - { - CreateMesh( - meshData->Data, - vertexBuffer, - indexBuffer, - vertexCount, - indexCount, - filename - ); - }); -} diff --git a/JGE/src/DirectX/BasicLoader.h b/JGE/src/DirectX/BasicLoader.h deleted file mode 100644 index 2eac19aee..000000000 --- a/JGE/src/DirectX/BasicLoader.h +++ /dev/null @@ -1,155 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -#pragma once - -#include "BasicReaderWriter.h" - -// A simple loader class that provides support for loading shaders, textures, -// and meshes from files on disk. Provides synchronous and asynchronous methods. -ref class BasicLoader -{ -internal: - BasicLoader( - _In_ ID3D11Device* d3dDevice -// ,_In_opt_ IWICImagingFactory2* wicFactory = nullptr - ); - - void LoadShader( - _In_ Platform::String^ filename, - _In_reads_opt_(layoutDescNumElements) D3D11_INPUT_ELEMENT_DESC layoutDesc[], - _In_ uint32 layoutDescNumElements, - _Out_ ID3D11VertexShader** shader, - _Out_opt_ ID3D11InputLayout** layout - ); - - concurrency::task LoadShaderAsync( - _In_ Platform::String^ filename, - _In_reads_opt_(layoutDescNumElements) D3D11_INPUT_ELEMENT_DESC layoutDesc[], - _In_ uint32 layoutDescNumElements, - _Out_ ID3D11VertexShader** shader, - _Out_opt_ ID3D11InputLayout** layout - ); - - void LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11PixelShader** shader - ); - - concurrency::task LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11PixelShader** shader - ); - - void LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11ComputeShader** shader - ); - - concurrency::task LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11ComputeShader** shader - ); - - void LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11GeometryShader** shader - ); - - concurrency::task LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11GeometryShader** shader - ); - - void LoadShader( - _In_ Platform::String^ filename, - _In_reads_opt_(numEntries) const D3D11_SO_DECLARATION_ENTRY* streamOutDeclaration, - _In_ uint32 numEntries, - _In_reads_opt_(numStrides) const uint32* bufferStrides, - _In_ uint32 numStrides, - _In_ uint32 rasterizedStream, - _Out_ ID3D11GeometryShader** shader - ); - - concurrency::task LoadShaderAsync( - _In_ Platform::String^ filename, - _In_reads_opt_(numEntries) const D3D11_SO_DECLARATION_ENTRY* streamOutDeclaration, - _In_ uint32 numEntries, - _In_reads_opt_(numStrides) const uint32* bufferStrides, - _In_ uint32 numStrides, - _In_ uint32 rasterizedStream, - _Out_ ID3D11GeometryShader** shader - ); - - void LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11HullShader** shader - ); - - concurrency::task LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11HullShader** shader - ); - - void LoadShader( - _In_ Platform::String^ filename, - _Out_ ID3D11DomainShader** shader - ); - - concurrency::task LoadShaderAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11DomainShader** shader - ); - - void LoadMesh( - _In_ Platform::String^ filename, - _Out_ ID3D11Buffer** vertexBuffer, - _Out_ ID3D11Buffer** indexBuffer, - _Out_opt_ uint32* vertexCount, - _Out_opt_ uint32* indexCount - ); - - concurrency::task LoadMeshAsync( - _In_ Platform::String^ filename, - _Out_ ID3D11Buffer** vertexBuffer, - _Out_ ID3D11Buffer** indexBuffer, - _Out_opt_ uint32* vertexCount, - _Out_opt_ uint32* indexCount - ); - -private: - Microsoft::WRL::ComPtr m_d3dDevice; -// Microsoft::WRL::ComPtr m_wicFactory; - BasicReaderWriter^ m_basicReaderWriter; - - template - inline void SetDebugName( - _In_ DeviceChildType* object, - _In_ Platform::String^ name - ); - - Platform::String^ GetExtension( - _In_ Platform::String^ filename - ); - - void CreateInputLayout( - _In_reads_bytes_(bytecodeSize) byte* bytecode, - _In_ uint32 bytecodeSize, - _In_reads_opt_(layoutDescNumElements) D3D11_INPUT_ELEMENT_DESC* layoutDesc, - _In_ uint32 layoutDescNumElements, - _Out_ ID3D11InputLayout** layout - ); - - void CreateMesh( - _In_ byte* meshData, - _Out_ ID3D11Buffer** vertexBuffer, - _Out_ ID3D11Buffer** indexBuffer, - _Out_opt_ uint32* vertexCount, - _Out_opt_ uint32* indexCount, - _In_opt_ Platform::String^ debugName - ); -}; diff --git a/JGE/src/DirectX/BasicMath.h b/JGE/src/DirectX/BasicMath.h deleted file mode 100644 index 8424c8622..000000000 --- a/JGE/src/DirectX/BasicMath.h +++ /dev/null @@ -1,531 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -#pragma once - -// This header defines helper utilities to make DirectX APIs work with exceptions. -namespace DX -{ - inline void ThrowIfFailed(HRESULT hr) - { - if (FAILED(hr)) - { - // Set a breakpoint on this line to catch DX API errors. - throw Platform::Exception::CreateException(hr); - } - } -} - -#define _USE_MATH_DEFINES -#include - -// This header defines math and matrix helper functions and structures used -// by DirectX SDK samples. - -// Common Constants - -#define PI_F 3.1415927f - -// Template Vector & Matrix Classes - -template struct Vector2 -{ - union - { - struct - { - T x; - T y; - }; - struct - { - T r; - T g; - }; - struct - { - T u; - T v; - }; - }; - - T& operator[](unsigned int index) - { - return static_cast(this)[index]; - } - - Vector2(T _x = 0, T _y = 0) : x(_x), y(_y) { } -}; - -template struct Vector3 -{ - union - { - struct - { - T x; - T y; - T z; - }; - struct - { - T r; - T g; - T b; - }; - struct - { - T u; - T v; - T w; - }; - }; - - T& operator[](unsigned int index) - { - return static_cast(this)[index]; - } - - Vector3(T _x = 0, T _y = 0, T _z = 0) : x(_x), y(_y), z(_z) { } -}; - -template struct Vector4 -{ - union - { - struct - { - T x; - T y; - T z; - T w; - }; - struct - { - T r; - T g; - T b; - T a; - }; - }; - - T& operator[](unsigned int index) - { - return static_cast(this)[index]; - } - - Vector4(T _x = 0, T _y = 0, T _z = 0, T _w = 0) : x(_x), y(_y), z(_z), w(_w) { } -}; - -template struct Matrix4x4 -{ - union - { - struct - { - T _11; T _12; T _13; T _14; - T _21; T _22; T _23; T _24; - T _31; T _32; T _33; T _34; - T _41; T _42; T _43; T _44; - }; - struct - { - T _m00; T _m01; T _m02; T _m03; - T _m10; T _m11; T _m12; T _m13; - T _m20; T _m21; T _m22; T _m23; - T _m30; T _m31; T _m32; T _m33; - }; - }; - - Matrix4x4(T value = 0) - { - _11 = _12 = _13 = _14 = value; - _21 = _22 = _23 = _24 = value; - _31 = _32 = _33 = _34 = value; - _41 = _42 = _43 = _44 = value; - } - - Matrix4x4( - T i11, T i12, T i13, T i14, - T i21, T i22, T i23, T i24, - T i31, T i32, T i33, T i34, - T i41, T i42, T i43, T i44 - ) - { - _11 = i11; _12 = i12; _13 = i13; _14 = i14; - _21 = i21; _22 = i22; _23 = i23; _24 = i24; - _31 = i31; _32 = i32; _33 = i33; _34 = i34; - _41 = i41; _42 = i42; _43 = i43; _44 = i44; - } - - T* operator[](unsigned int index) - { - return &(reinterpret_cast(this)[index*4]); - } -}; - -// Template Vector Operations - -template -T dot(Vector2 a, Vector2 b) -{ - return a.x * b.x + a.y * b.y; -} - -template -T dot(Vector3 a, Vector3 b) -{ - return a.x * b.x + a.y * b.y + a.z * b.z; -} - -template -T dot(Vector4 a, Vector4 b) -{ - return a.x * b.x + a.y * b.y + a.z * b.z + a.w + b.w; -} - -template -T length(Vector2 a) -{ - return sqrt(a.x * a.x + a.y * a.y); -} - -template -T length(Vector3 a) -{ - return sqrt(a.x * a.x + a.y * a.y + a.z * a.z); -} - -template -T length(Vector4 a) -{ - return sqrt(a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w); -} - -template -Vector3 cross(Vector3 a, Vector3 b) -{ - return Vector3((a.y*b.z)-(a.z*b.y), (a.z*b.x)-(a.x*b.z), (a.x*b.y)-(a.y*b.x)); -} - -template -Vector2 normalize(Vector2 a) -{ - T len = length(a); - return Vector2(a.x / len, a.y / len); -} - -template -Vector3 normalize(Vector3 a) -{ - T len = length(a); - return Vector3(a.x / len, a.y / len, a.z / len); -} - -template -Vector4 normalize(Vector4 a) -{ - T len = length(a); - return Vector4(a.x / len, a.y / len, a.z / len, a.w / len); -} - -// Template Vector Operators - -template -Vector2 operator-(Vector2 a, Vector2 b) -{ - return Vector2(a.x - b.x, a.y - b.y); -} - -template -Vector2 operator-(Vector2 a) -{ - return Vector2(-a.x, -a.y); -} - -template -Vector3 operator-(Vector3 a, Vector3 b) -{ - return Vector3(a.x - b.x, a.y - b.y, a.z - b.z); -} - -template -Vector3 operator-(Vector3 a) -{ - return Vector3(-a.x, -a.y, -a.z); -} - -template -Vector4 operator-(Vector4 a, Vector4 b) -{ - return Vector4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); -} - -template -Vector4 operator-(Vector4 a) -{ - return Vector4(-a.x, -a.y, -a.z, -a.w); -} - -template -Vector2 operator+(Vector2 a, Vector2 b) -{ - return Vector2(a.x + b.x, a.y + b.y); -} - -template -Vector3 operator+(Vector3 a, Vector3 b) -{ - return Vector3(a.x + b.x, a.y + b.y, a.z + b.z); -} - -template -Vector4 operator+(Vector4 a, Vector4 b) -{ - return Vector4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); -} - -template -Vector2 operator*(Vector2 a, T s) -{ - return Vector2(a.x * s, a.y * s); -} - -template -Vector2 operator*(T s, Vector2 a) -{ - return a * s; -} - -template -Vector2 operator*(Vector2 a, Vector2 b) -{ - return Vector2(a.x * b.x, a.y * b.y); -} - -template -Vector2 operator/(Vector2 a, T s) -{ - return Vector2(a.x / s, a.y / s); -} - -template -Vector3 operator*(Vector3 a, T s) -{ - return Vector3(a.x * s, a.y * s, a.z * s); -} - -template -Vector3 operator*(T s, Vector3 a) -{ - return a * s; -} - -template -Vector3 operator*(Vector3 a, Vector3 b) -{ - return Vector3(a.x * b.x, a.y * b.y, a.z * b.z); -} - -template -Vector3 operator/(Vector3 a, T s) -{ - return Vector3(a.x / s, a.y / s, a.z / s); -} - -template -Vector4 operator*(Vector4 a, T s) -{ - return Vector4(a.x * s, a.y * s, a.z * s, a.w * s); -} - -template -Vector4 operator*(T s, Vector4 a) -{ - return a * s; -} - -template -Vector4 operator*(Vector4 a, Vector4 b) -{ - return Vector4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); -} - -template -Vector4 operator/(Vector4 a, T s) -{ - return Vector4(a.x / s, a.y / s, a.z / s, a.w / s); -} - - - -// Template Matrix Operations - -template -Matrix4x4 transpose(Matrix4x4 m) -{ - return Matrix4x4( - m._11, m._21, m._31, m._41, - m_.12, m._22, m._32, m._42, - m._13, m._23, m._33, m._43, - m._14, m._24, m._34, m._44 - ); -} - -template -Matrix4x4 mul(Matrix4x4 m1, Matrix4x4 m2) -{ - Matrix4x4 mOut; - - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 4; j++) - { - for (int k = 0; k < 4; k++) - { - mOut[i][j] += m1[i][k] * m2[k][j]; - } - } - } - - return mOut; -} - -// Common HLSL-compatible vector typedefs - -typedef unsigned int uint; - -typedef Vector2 float2; -typedef Vector3 float3; -typedef Vector4 float4; - -typedef Matrix4x4 float4x4; - -// Standard Matrix Intializers - -inline float4x4 identity() -{ - float4x4 mOut; - - mOut._11 = 1.0f; mOut._12 = 0.0f; mOut._13 = 0.0f; mOut._14 = 0.0f; - mOut._21 = 0.0f; mOut._22 = 1.0f; mOut._23 = 0.0f; mOut._24 = 0.0f; - mOut._31 = 0.0f; mOut._32 = 0.0f; mOut._33 = 1.0f; mOut._34 = 0.0f; - mOut._41 = 0.0f; mOut._42 = 0.0f; mOut._43 = 0.0f; mOut._44 = 1.0f; - - return mOut; -} - -inline float4x4 translation(float x, float y, float z) -{ - float4x4 mOut; - - mOut._11 = 1.0f; mOut._12 = 0.0f; mOut._13 = 0.0f; mOut._14 = x; - mOut._21 = 0.0f; mOut._22 = 1.0f; mOut._23 = 0.0f; mOut._24 = y; - mOut._31 = 0.0f; mOut._32 = 0.0f; mOut._33 = 1.0f; mOut._34 = z; - mOut._41 = 0.0f; mOut._42 = 0.0f; mOut._43 = 0.0f; mOut._44 = 1.0f; - - return mOut; -} - -inline float4x4 scale(float x, float y, float z) -{ - float4x4 mOut; - - mOut._11 = x; mOut._12 = 0.0f; mOut._13 = 0.0f; mOut._14 = 0.0f; - mOut._21 = 0.0f; mOut._22 = y; mOut._23 = 0.0f; mOut._24 = 0.0f; - mOut._31 = 0.0f; mOut._32 = 0.0f; mOut._33 = z; mOut._34 = 0.0f; - mOut._41 = 0.0f; mOut._42 = 0.0f; mOut._43 = 0.0f; mOut._44 = 1.0f; - - return mOut; -} - -inline float4x4 rotationX(float degreeX) -{ - float angleInRadians = degreeX * (PI_F / 180.0f); - - float sinAngle = sinf(angleInRadians); - float cosAngle = cosf(angleInRadians); - - float4x4 mOut; - - mOut._11 = 1.0f; mOut._12 = 0.0f; mOut._13 = 0.0f; mOut._14 = 0.0f; - mOut._21 = 0.0f; mOut._22 = cosAngle; mOut._23 = -sinAngle; mOut._24 = 0.0f; - mOut._31 = 0.0f; mOut._32 = sinAngle; mOut._33 = cosAngle; mOut._34 = 0.0f; - mOut._41 = 0.0f; mOut._42 = 0.0f; mOut._43 = 0.0f; mOut._44 = 1.0f; - - return mOut; -} - -inline float4x4 rotationY(float degreeY) -{ - float angleInRadians = degreeY * (PI_F / 180.0f); - - float sinAngle = sinf(angleInRadians); - float cosAngle = cosf(angleInRadians); - - float4x4 mOut; - - mOut._11 = cosAngle; mOut._12 = 0.0f; mOut._13 = sinAngle; mOut._14 = 0.0f; - mOut._21 = 0.0f; mOut._22 = 1.0f; mOut._23 = 0.0f; mOut._24 = 0.0f; - mOut._31 = -sinAngle; mOut._32 = 0.0f; mOut._33 = cosAngle; mOut._34 = 0.0f; - mOut._41 = 0.0f; mOut._42 = 0.0f; mOut._43 = 0.0f; mOut._44 = 1.0f; - - return mOut; -} - -inline float4x4 rotationZ(float degreeZ) -{ - float angleInRadians = degreeZ * (PI_F / 180.0f); - - float sinAngle = sinf(angleInRadians); - float cosAngle = cosf(angleInRadians); - - float4x4 mOut; - - mOut._11 = cosAngle; mOut._12 = -sinAngle; mOut._13 = 0.0f; mOut._14 = 0.0f; - mOut._21 = sinAngle; mOut._22 = cosAngle; mOut._23 = 0.0f; mOut._24 = 0.0f; - mOut._31 = 0.0f; mOut._32 = 0.0f; mOut._33 = 1.0f; mOut._34 = 0.0f; - mOut._41 = 0.0f; mOut._42 = 0.0f; mOut._43 = 0.0f; mOut._44 = 1.0f; - - return mOut; -} - -// 3D Rotation matrix for an arbitrary axis specified by x, y and z -inline float4x4 rotationArbitrary(float3 axis, float degree) -{ - axis = normalize(axis); - - float angleInRadians = degree * (PI_F / 180.0f); - - float sinAngle = sinf(angleInRadians); - float cosAngle = cosf(angleInRadians); - float oneMinusCosAngle = 1 - cosAngle; - - float4x4 mOut; - - mOut._11 = 1.0f + oneMinusCosAngle * (axis.x * axis.x - 1.0f); - mOut._12 = axis.z * sinAngle + oneMinusCosAngle * axis.x * axis.y; - mOut._13 = -axis.y * sinAngle + oneMinusCosAngle * axis.x * axis.z; - mOut._41 = 0.0f; - - mOut._21 = -axis.z * sinAngle + oneMinusCosAngle * axis.y * axis.x; - mOut._22 = 1.0f + oneMinusCosAngle * (axis.y * axis.y - 1.0f); - mOut._23 = axis.x * sinAngle + oneMinusCosAngle * axis.y * axis.z; - mOut._24 = 0.0f; - - mOut._31 = axis.y * sinAngle + oneMinusCosAngle * axis.z * axis.x; - mOut._32 = -axis.x * sinAngle + oneMinusCosAngle * axis.z * axis.y; - mOut._33 = 1.0f + oneMinusCosAngle * (axis.z * axis.z - 1.0f); - mOut._34 = 0.0f; - - mOut._41 = 0.0f; - mOut._42 = 0.0f; - mOut._43 = 0.0f; - mOut._44 = 1.0f; - - return mOut; -} diff --git a/JGE/src/DirectX/BasicReaderWriter.cpp b/JGE/src/DirectX/BasicReaderWriter.cpp deleted file mode 100644 index a6f8cfbc2..000000000 --- a/JGE/src/DirectX/BasicReaderWriter.cpp +++ /dev/null @@ -1,175 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -#include -#include -#include -#include -#include -#include -#include -#include "BasicReaderWriter.h" - -using namespace Microsoft::WRL; -using namespace Windows::Storage; -using namespace Windows::Storage::FileProperties; -using namespace Windows::Storage::Streams; -using namespace Windows::Foundation; -using namespace Windows::ApplicationModel; -using namespace concurrency; - -BasicReaderWriter::BasicReaderWriter() -{ - m_location = Package::Current->InstalledLocation; - m_locationPath = Platform::String::Concat(m_location->Path, "\\"); -} - -BasicReaderWriter::BasicReaderWriter( - _In_ Windows::Storage::StorageFolder^ folder - ) -{ - m_location = folder; - Platform::String^ path = m_location->Path; - if (path->Length() == 0) - { - // Applications are not permitted to access certain - // folders, such as the Documents folder, using this - // code path. In such cases, the Path property for - // the folder will be an empty string. - throw ref new Platform::FailureException(); - } - m_locationPath = Platform::String::Concat(path, "\\"); -} - -Platform::Array^ BasicReaderWriter::ReadData( - _In_ Platform::String^ filename - ) -{ - CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0}; - extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); - extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN; - extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; - extendedParams.lpSecurityAttributes = nullptr; - extendedParams.hTemplateFile = nullptr; - - Wrappers::FileHandle file( - CreateFile2( - Platform::String::Concat(m_locationPath, filename)->Data(), - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, - &extendedParams - ) - ); - if (file.Get() == INVALID_HANDLE_VALUE) - { - throw ref new Platform::FailureException(); - } - - FILE_STANDARD_INFO fileInfo = {0}; - if (!GetFileInformationByHandleEx( - file.Get(), - FileStandardInfo, - &fileInfo, - sizeof(fileInfo) - )) - { - throw ref new Platform::FailureException(); - } - - if (fileInfo.EndOfFile.HighPart != 0) - { - throw ref new Platform::OutOfMemoryException(); - } - - Platform::Array^ fileData = ref new Platform::Array(fileInfo.EndOfFile.LowPart); - - if (!ReadFile( - file.Get(), - fileData->Data, - fileData->Length, - nullptr, - nullptr - )) - { - throw ref new Platform::FailureException(); - } - - return fileData; -} - -task^> BasicReaderWriter::ReadDataAsync( - _In_ Platform::String^ filename - ) -{ - return task(m_location->GetFileAsync(filename)).then([=](StorageFile^ file) - { - return FileIO::ReadBufferAsync(file); - }).then([=](IBuffer^ buffer) - { - auto fileData = ref new Platform::Array(buffer->Length); - DataReader::FromBuffer(buffer)->ReadBytes(fileData); - return fileData; - }); -} - -uint32 BasicReaderWriter::WriteData( - _In_ Platform::String^ filename, - _In_ const Platform::Array^ fileData - ) -{ - CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0}; - extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); - extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN; - extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; - extendedParams.lpSecurityAttributes = nullptr; - extendedParams.hTemplateFile = nullptr; - - Wrappers::FileHandle file( - CreateFile2( - Platform::String::Concat(m_locationPath, filename)->Data(), - GENERIC_WRITE, - 0, - CREATE_ALWAYS, - &extendedParams - ) - ); - if (file.Get() == INVALID_HANDLE_VALUE) - { - throw ref new Platform::FailureException(); - } - - DWORD numBytesWritten; - if ( - !WriteFile( - file.Get(), - fileData->Data, - fileData->Length, - &numBytesWritten, - nullptr - ) || - numBytesWritten != fileData->Length - ) - { - throw ref new Platform::FailureException(); - } - - return numBytesWritten; -} - -task BasicReaderWriter::WriteDataAsync( - _In_ Platform::String^ filename, - _In_ const Platform::Array^ fileData - ) -{ - return task(m_location->CreateFileAsync(filename, CreationCollisionOption::ReplaceExisting)).then([=](StorageFile^ file) - { - FileIO::WriteBytesAsync(file, fileData); - }); -} diff --git a/JGE/src/DirectX/BasicReaderWriter.h b/JGE/src/DirectX/BasicReaderWriter.h deleted file mode 100644 index 8cf54183f..000000000 --- a/JGE/src/DirectX/BasicReaderWriter.h +++ /dev/null @@ -1,43 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -#pragma once - -#include - -// A simple reader/writer class that provides support for reading and writing -// files on disk. Provides synchronous and asynchronous methods. -ref class BasicReaderWriter -{ -private: - Windows::Storage::StorageFolder^ m_location; - Platform::String^ m_locationPath; - -internal: - BasicReaderWriter(); - BasicReaderWriter( - _In_ Windows::Storage::StorageFolder^ folder - ); - - Platform::Array^ ReadData( - _In_ Platform::String^ filename - ); - - concurrency::task^> ReadDataAsync( - _In_ Platform::String^ filename - ); - - uint32 WriteData( - _In_ Platform::String^ filename, - _In_ const Platform::Array^ fileData - ); - - concurrency::task WriteDataAsync( - _In_ Platform::String^ filename, - _In_ const Platform::Array^ fileData - ); -}; diff --git a/JGE/src/DirectX/BasicShapes.h b/JGE/src/DirectX/BasicShapes.h deleted file mode 100644 index 3abeab18e..000000000 --- a/JGE/src/DirectX/BasicShapes.h +++ /dev/null @@ -1,88 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -#pragma once - -#include "BasicMath.h" - -// Defines the vertex format for the shapes generated in the functions below. -struct BasicVertex -{ - float3 pos; // position - float3 norm; // surface normal vector - float2 tex; // texture coordinate -}; - -// Defines the vertex format for all shapes generated in the functions below. -struct TangentVertex -{ - float3 pos; // position - float2 tex; // texture coordinate - float3 uTan; // texture coordinate u-tangent vector - float3 vTan; // texture coordinate v-tangent vector -}; - -// A helper class that provides convenient functions for creating common -// geometrical shapes used by DirectX SDK samples. -ref class BasicShapes -{ -internal: - BasicShapes(ID3D11Device *d3dDevice); - void CreateCube( - _Out_ ID3D11Buffer **vertexBuffer, - _Out_ ID3D11Buffer **indexBuffer, - _Out_opt_ unsigned int *vertexCount, - _Out_opt_ unsigned int *indexCount - ); - void CreateBox( - float3 radii, - _Out_ ID3D11Buffer **vertexBuffer, - _Out_ ID3D11Buffer **indexBuffer, - _Out_opt_ unsigned int *vertexCount, - _Out_opt_ unsigned int *indexCount - ); - void CreateSphere( - _Out_ ID3D11Buffer **vertexBuffer, - _Out_ ID3D11Buffer **indexBuffer, - _Out_opt_ unsigned int *vertexCount, - _Out_opt_ unsigned int *indexCount - ); - void CreateTangentSphere( - _Out_ ID3D11Buffer **vertexBuffer, - _Out_ ID3D11Buffer **indexBuffer, - _Out_opt_ unsigned int *vertexCount, - _Out_opt_ unsigned int *indexCount - ); - void CreateReferenceAxis( - _Out_ ID3D11Buffer **vertexBuffer, - _Out_ ID3D11Buffer **indexBuffer, - _Out_opt_ unsigned int *vertexCount, - _Out_opt_ unsigned int *indexCount - ); - -private: - Microsoft::WRL::ComPtr m_d3dDevice; - - void CreateVertexBuffer( - _In_ unsigned int numVertices, - _In_ BasicVertex *vertexData, - _Out_ ID3D11Buffer **vertexBuffer - ); - - void CreateIndexBuffer( - _In_ unsigned int numIndices, - _In_ unsigned short *indexData, - _Out_ ID3D11Buffer **indexBuffer - ); - - void CreateTangentVertexBuffer( - _In_ unsigned int numVertices, - _In_ TangentVertex *vertexData, - _Out_ ID3D11Buffer **vertexBuffer - ); - -}; diff --git a/JGE/src/DirectX/BasicSprites.GeometryShader.gs.hlsl b/JGE/src/DirectX/BasicSprites.GeometryShader.gs.hlsl deleted file mode 100644 index aeb36812a..000000000 --- a/JGE/src/DirectX/BasicSprites.GeometryShader.gs.hlsl +++ /dev/null @@ -1,95 +0,0 @@ -// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -// PARTICULAR PURPOSE. -// -// Copyright (c) Microsoft Corporation. All rights reserved -//---------------------------------------------------------------------- - -cbuffer RenderTargetInfoCB -{ - float2 renderTargetSize; -}; - -cbuffer MvpMatrixCB -{ - float4x4 mvpMatrix; -}; - -struct GeometryShaderInput -{ - float2 origin : TRANSFORM0; - float2 offset : TRANSFORM1; - float rotation : TRANSFORM2; - float4 textRect : TRANSFORM3; - vector colors : COLOR0; - float4 pt_x: TRANSFORM4; - float4 pt_y: TRANSFORM5; -}; - -struct PixelShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - - -void rotate(float4x4 matrixxx, float angle, float3 origin) -{ - -} - -// This shader generates two triangles that will be used to draw the sprite. -// The vertex properties are calculated based on the per-sprite instance data -// passed in from the vertex shader. - -[maxvertexcount(4)] -void main(point GeometryShaderInput input[1], inout TriangleStream spriteStream) -{ - float sinRotation; - float cosRotation; - sincos(input[0].rotation, sinRotation, cosRotation); - - float2 texCoord[4]; - - texCoord[0] = float2(input[0].textRect[0], input[0].textRect[2]); - texCoord[1] = float2(input[0].textRect[1], input[0].textRect[2]); - texCoord[2] = float2(input[0].textRect[0], input[0].textRect[3]); - texCoord[3] = float2(input[0].textRect[1], input[0].textRect[3]); - - float2 posDelta[4]; - - posDelta[0] = float2(0.0f, 0.0f); - posDelta[1] = float2( 2*input[0].offset.x, 0.0f); - posDelta[2] = float2(0.0f, -2*input[0].offset.y); - posDelta[3] = float2( 2*input[0].offset.x, -2*input[0].offset.y); - /* - posDelta[0] = float2(-input[0].offset.x, input[0].offset.y); - posDelta[1] = float2( input[0].offset.x, input[0].offset.y); - posDelta[2] = float2(-input[0].offset.x, -input[0].offset.y); - posDelta[3] = float2( input[0].offset.x, -input[0].offset.y); - */ - spriteStream.RestartStrip(); - [unroll] - for (int i = 0; i < 4; i++) - { - float4 colorFloat; - colorFloat[3] = (float)((input[0].colors[i] & 0xFF000000) >> 24) / (float)255; - colorFloat[0] = (float)((input[0].colors[i] & 0x00FF0000) >> 16) / (float)255; - colorFloat[1] = (float)((input[0].colors[i] & 0x0000FF00) >> 8) / (float)255; - colorFloat[2] = (float)((input[0].colors[i] & 0x000000FF) ) / (float)255; - - posDelta[i] = float2( - posDelta[i].x * cosRotation - posDelta[i].y * sinRotation, - posDelta[i].x * sinRotation + posDelta[i].y * cosRotation - ); - posDelta[i] /= renderTargetSize; - PixelShaderInput streamElement; - streamElement.pos = float4(input[0].origin + posDelta[i], 0.5f, 1.0f); - streamElement.tex = texCoord[i]; - streamElement.color = colorFloat; - spriteStream.Append(streamElement); - } - spriteStream.RestartStrip(); -} diff --git a/JGE/src/DirectX/BasicSprites.GeometryShader.vs.hlsl b/JGE/src/DirectX/BasicSprites.GeometryShader.vs.hlsl deleted file mode 100644 index d3ddb9f6a..000000000 --- a/JGE/src/DirectX/BasicSprites.GeometryShader.vs.hlsl +++ /dev/null @@ -1,44 +0,0 @@ -// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -// PARTICULAR PURPOSE. -// -// Copyright (c) Microsoft Corporation. All rights reserved -//---------------------------------------------------------------------- - -struct VertexShaderInput -{ - float2 origin : TRANSFORM0; - float2 offset : TRANSFORM1; - float rotation : TRANSFORM2; - float4 textRect : TRANSFORM3; - vector colors : COLOR0; - float4 pt_x: TRANSFORM4; - float4 pt_y: TRANSFORM5; -}; - -struct GeometryShaderInput -{ - float2 origin : TRANSFORM0; - float2 offset : TRANSFORM1; - float rotation : TRANSFORM2; - float4 textRect : TRANSFORM3; - vector colors : COLOR0; - float4 pt_x: TRANSFORM4; - float4 pt_y: TRANSFORM5; -}; - -// This shader simply passes per-sprite instance data to the geometry shader. - -GeometryShaderInput main(VertexShaderInput input) -{ - GeometryShaderInput ret; - ret.origin = input.origin; - ret.offset = input.offset; - ret.rotation = input.rotation; - ret.textRect = input.textRect; - ret.colors = input.colors; - ret.pt_x = input.pt_x; - ret.pt_y = input.pt_y; - return ret; -} diff --git a/JGE/src/DirectX/BasicSprites.Instancing.vs.hlsl b/JGE/src/DirectX/BasicSprites.Instancing.vs.hlsl deleted file mode 100644 index 690b9f357..000000000 --- a/JGE/src/DirectX/BasicSprites.Instancing.vs.hlsl +++ /dev/null @@ -1,51 +0,0 @@ -// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -// PARTICULAR PURPOSE. -// -// Copyright (c) Microsoft Corporation. All rights reserved -//---------------------------------------------------------------------- - -cbuffer RenderTargetInfoCB -{ - float2 renderTargetSize; -}; - -struct VertexShaderInput -{ - float2 pos : POSITION; - float2 tex : TEXCOORD0; - float2 origin : TRANSFORM0; - float2 offset : TRANSFORM1; - float rotation : TRANSFORM2; - float4 color : COLOR0; -}; - -struct PixelShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -// This shader takes a fixed-position vertex buffer, and using per-sprite -// instance data, transforms the vertices so that the sprite is rendered -// at the desired position, rotation, and scale. - -PixelShaderInput main(VertexShaderInput input) -{ - PixelShaderInput ret; - float sinRotation; - float cosRotation; - sincos(input.rotation, sinRotation, cosRotation); - float2 posDelta = input.pos * input.offset; - posDelta = float2( - posDelta.x * cosRotation - posDelta.y * sinRotation, - posDelta.x * sinRotation + posDelta.y * cosRotation - ); - posDelta /= renderTargetSize; - ret.pos = float4(input.origin + posDelta, 0.5f, 1.0f); - ret.tex = input.tex; - ret.color = input.color; - return ret; -} diff --git a/JGE/src/DirectX/BasicSprites.Replication.vs.hlsl b/JGE/src/DirectX/BasicSprites.Replication.vs.hlsl deleted file mode 100644 index 052f8d0ff..000000000 --- a/JGE/src/DirectX/BasicSprites.Replication.vs.hlsl +++ /dev/null @@ -1,32 +0,0 @@ -// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -// PARTICULAR PURPOSE. -// -// Copyright (c) Microsoft Corporation. All rights reserved -//---------------------------------------------------------------------- - -struct VertexShaderInput -{ - float2 pos : POSITIONT; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -struct PixelShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -// This shader simply passes pre-transformed vertex data to the pixel shader. - -PixelShaderInput main(VertexShaderInput input) -{ - PixelShaderInput ret; - ret.pos = float4(input.pos, 0.5f, 1.0f); - ret.tex = input.tex; - ret.color = input.color; - return ret; -} diff --git a/JGE/src/DirectX/BasicSprites.cpp b/JGE/src/DirectX/BasicSprites.cpp deleted file mode 100644 index 34f686fa8..000000000 --- a/JGE/src/DirectX/BasicSprites.cpp +++ /dev/null @@ -1,988 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -// Warning: SpriteBatch performance is significantly decreased in -// the Debug configuration. Release configuration is recommended -// for accurate performance assessment. - -#include -#include -#include -#include -#include -#include - -#include "BasicSprites.h" -#include "BasicLoader.h" - -using namespace Microsoft::WRL; -using namespace BasicSprites; - -SpriteBatch::SpriteBatch() : - m_capacity(0) -{ -} - -void SpriteBatch::Initialize( - _In_ ID3D11Device1* d3dDevice, - _In_ int capacity - ) -{ - m_d3dDevice = d3dDevice; - m_d3dDevice->GetImmediateContext1(&m_d3dContext); - m_capacity = capacity; - - // Determine the technique that will be used to render the sprites. - auto featureLevel = m_d3dDevice->GetFeatureLevel(); - - if (featureLevel >= D3D_FEATURE_LEVEL_10_0) - { - // On DirectX 10+ devices, the Geometry Shader allows the sprite vertices to be - // generated on the GPU, significantly reducing memory bandwidth requirements. - m_technique = RenderTechnique::GeometryShader; - } - else if (featureLevel >= D3D_FEATURE_LEVEL_9_3) - { - // On DirectX 9.3+ devices, instancing allows shared sprite geometry with unique - // per-sprite instance parameters, eliminating redundant data transfer. - m_technique = RenderTechnique::Instancing; - } - else - { - // On devices that do not support Instancing, sprite vertex data must be replicated - // in order to achieve the desired effect. - m_technique = RenderTechnique::Replication; - - if (capacity > static_cast(Parameters::MaximumCapacityCompatible)) - { - // The index buffer format for feature-level 9.1 devices may only be 16 bits. - // With 4 vertices per sprite, this allows a maximum of (1 << 16) / 4 sprites. - throw ref new Platform::InvalidArgumentException(); - } - } - - // Create the texture sampler. - - D3D11_SAMPLER_DESC samplerDesc; - ZeroMemory(&samplerDesc, sizeof(samplerDesc)); - samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; - samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; - samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; - samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; - samplerDesc.MipLODBias = 0.0f; - samplerDesc.MaxAnisotropy = 0; - samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER; - samplerDesc.BorderColor[0] = 0.0f; - samplerDesc.BorderColor[1] = 0.0f; - samplerDesc.BorderColor[2] = 0.0f; - samplerDesc.BorderColor[3] = 0.0f; - samplerDesc.MinLOD = 0.0f; - samplerDesc.MaxLOD = FLT_MAX; - - DX::ThrowIfFailed( - m_d3dDevice->CreateSamplerState( - &samplerDesc, - &m_linearSampler - ) - ); - - // Create the blend states. - - D3D11_BLEND_DESC1 blendDesc; - ZeroMemory(&blendDesc, sizeof(blendDesc)); - blendDesc.AlphaToCoverageEnable = false; - blendDesc.IndependentBlendEnable = false; - blendDesc.RenderTarget[0].BlendEnable = true; - blendDesc.RenderTarget[0].LogicOpEnable = false; - blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; - blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; - blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; - blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - - DX::ThrowIfFailed( - m_d3dDevice->CreateBlendState1( - &blendDesc, - &m_blendStateAlpha - ) - ); - - blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE; - - DX::ThrowIfFailed( - m_d3dDevice->CreateBlendState1( - &blendDesc, - &m_blendStateAdditive - ) - ); - - BasicLoader^ loader = ref new BasicLoader(m_d3dDevice.Get()); - - if (m_technique == RenderTechnique::GeometryShader) - { - D3D11_INPUT_ELEMENT_DESC layoutDesc[] = - { - { "TRANSFORM", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "TRANSFORM", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "TRANSFORM", 2, DXGI_FORMAT_R32_FLOAT, 0, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "TRANSFORM", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_UINT, 0, 36, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "TRANSFORM", 4, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 52, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "TRANSFORM", 5, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 68, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - }; - loader->LoadShader( - "BasicSprites.GeometryShader.vs.cso", - layoutDesc, - ARRAYSIZE(layoutDesc), - &m_vertexShader, - &m_inputLayout - ); - loader->LoadShader( - "BasicSprites.GeometryShader.gs.cso", - &m_geometryShader - ); - } - else if (m_technique == RenderTechnique::Instancing) - { - D3D11_INPUT_ELEMENT_DESC layoutDesc[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TRANSFORM", 0, DXGI_FORMAT_R32G32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "TRANSFORM", 1, DXGI_FORMAT_R32G32_FLOAT, 1, 8, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "TRANSFORM", 2, DXGI_FORMAT_R32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, - { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 20, D3D11_INPUT_PER_INSTANCE_DATA, 1 } - }; - loader->LoadShader( - "BasicSprites.Instancing.vs.cso", - layoutDesc, - ARRAYSIZE(layoutDesc), - &m_vertexShader, - &m_inputLayout - ); - } - else if (m_technique == RenderTechnique::Replication) - { - D3D11_INPUT_ELEMENT_DESC layoutDesc[] = - { - { "POSITIONT", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 } - }; - loader->LoadShader( - "BasicSprites.Replication.vs.cso", - layoutDesc, - ARRAYSIZE(layoutDesc), - &m_vertexShader, - &m_inputLayout - ); - } - - loader->LoadShader( - "BasicSprites.ps.cso", - &m_pixelShader - ); - - // Create buffers. - - if (m_technique == RenderTechnique::GeometryShader) - { - // Create the instance data buffer. - - CD3D11_BUFFER_DESC instanceDataBufferDesc( - m_capacity * sizeof(InstanceData), - D3D11_BIND_VERTEX_BUFFER, - D3D11_USAGE_DEFAULT, - 0 - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &instanceDataBufferDesc, - nullptr, - &m_instanceDataBuffer - ) - ); - - m_instanceData.reset(new InstanceData[m_capacity]); - } - else if (m_technique == RenderTechnique::Instancing) - { - // Create the vertex buffer. - - InstancingVertex vertexBufferData[] = - { - { float2(-1.0f, 1.0f), float2(0.0f, 0.0f) }, - { float2( 1.0f, 1.0f), float2(1.0f, 0.0f) }, - { float2(-1.0f, -1.0f), float2(0.0f, 1.0f) }, - { float2( 1.0f, -1.0f), float2(1.0f, 1.0f) } - }; - - D3D11_SUBRESOURCE_DATA vertexInitialData; - vertexInitialData.pSysMem = vertexBufferData; - vertexInitialData.SysMemPitch = 0; - vertexInitialData.SysMemSlicePitch = 0; - - CD3D11_BUFFER_DESC vertexBufferDesc( - sizeof(vertexBufferData), - D3D11_BIND_VERTEX_BUFFER, - D3D11_USAGE_DEFAULT, - 0 - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &vertexBufferDesc, - &vertexInitialData, - &m_vertexBuffer - ) - ); - - // Create the instance data buffer. - - CD3D11_BUFFER_DESC instanceDataBufferDesc( - m_capacity * sizeof(InstanceData), - D3D11_BIND_VERTEX_BUFFER, - D3D11_USAGE_DEFAULT, - 0 - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &instanceDataBufferDesc, - nullptr, - &m_instanceDataBuffer - ) - ); - - m_instanceData.reset(new InstanceData[m_capacity]); - - // Create the index buffer. - - unsigned int indexBufferData[] = - { - 0, 1, 2, - 1, 3, 2 - }; - - D3D11_SUBRESOURCE_DATA indexInitialData; - indexInitialData.pSysMem = indexBufferData; - indexInitialData.SysMemPitch = 0; - indexInitialData.SysMemSlicePitch = 0; - - CD3D11_BUFFER_DESC indexBufferDesc( - sizeof(indexBufferData), - D3D11_BIND_INDEX_BUFFER, - D3D11_USAGE_DEFAULT, - 0 - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &indexBufferDesc, - &indexInitialData, - &m_indexBuffer - ) - ); - } - else if (m_technique == RenderTechnique::Replication) - { - // Create the vertex buffer. - - CD3D11_BUFFER_DESC vertexBufferDesc( - m_capacity * 4 * sizeof(ReplicationVertex), - D3D11_BIND_VERTEX_BUFFER, - D3D11_USAGE_DEFAULT, - 0 - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &vertexBufferDesc, - nullptr, - &m_vertexBuffer - ) - ); - - m_vertexData.reset(new ReplicationVertex[m_capacity * 4]); - - // Create the index buffer. - - std::unique_ptr indexBufferData(new unsigned short[m_capacity * 6]); - - for (int i = 0; i < m_capacity; i++) - { - indexBufferData[i * 6 + 0] = i * 4 + 0; - indexBufferData[i * 6 + 1] = i * 4 + 1; - indexBufferData[i * 6 + 2] = i * 4 + 2; - indexBufferData[i * 6 + 3] = i * 4 + 1; - indexBufferData[i * 6 + 4] = i * 4 + 3; - indexBufferData[i * 6 + 5] = i * 4 + 2; - } - - D3D11_SUBRESOURCE_DATA initialData; - initialData.pSysMem = indexBufferData.get(); - initialData.SysMemPitch = 0; - initialData.SysMemSlicePitch = 0; - - CD3D11_BUFFER_DESC indexBufferDesc( - m_capacity * 6 * sizeof(unsigned short), - D3D11_BIND_INDEX_BUFFER, - D3D11_USAGE_DEFAULT, - 0 - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &indexBufferDesc, - &initialData, - &m_indexBuffer - ) - ); - } - - if (m_technique == RenderTechnique::GeometryShader || m_technique == RenderTechnique::Instancing) - { - // Both the Geometry Shader and Instancing techniques scale geometry in shader code. - // As a result, they require information about the render target size. - - CD3D11_BUFFER_DESC renderTargetInfoCbufferDesc( - 16, // Constant buffer sizes must be a multiple of 16 bytes. 16 is sufficient for the required float2 data. - D3D11_BIND_CONSTANT_BUFFER, - D3D11_USAGE_DYNAMIC, - D3D11_CPU_ACCESS_WRITE - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &renderTargetInfoCbufferDesc, - nullptr, - &m_renderTargetInfoCbuffer - ) - ); - - CD3D11_BUFFER_DESC mvpMatrixCbufferDesc( - 128, // Matrix4x4 float data. - D3D11_BIND_CONSTANT_BUFFER, - D3D11_USAGE_DYNAMIC, - D3D11_CPU_ACCESS_WRITE - ); - - DX::ThrowIfFailed( - m_d3dDevice->CreateBuffer( - &mvpMatrixCbufferDesc, - nullptr, - &m_mvpMatrixCbuffer - ) - ); - - } -} - -void SpriteBatch::AddTexture( - _In_ ID3D11Texture2D* texture - ) -{ - TextureMapElement mapElement; - CD3D11_SHADER_RESOURCE_VIEW_DESC mapElementSrvDesc( - texture, - D3D11_SRV_DIMENSION_TEXTURE2D - ); - DX::ThrowIfFailed( - m_d3dDevice->CreateShaderResourceView( - texture, - &mapElementSrvDesc, - &mapElement.srv - ) - ); - - D3D11_TEXTURE2D_DESC textureDesc; - texture->GetDesc(&textureDesc); - mapElement.size = float2( - static_cast(textureDesc.Width), - static_cast(textureDesc.Height) - ); - - m_textureMap[texture] = mapElement; -} - -void SpriteBatch::RemoveTexture( - _In_ ID3D11Texture2D* texture - ) -{ - m_textureMap.erase(texture); -} - -void SpriteBatch::Begin() -{ - // Reset internal sprite data. - - m_numSpritesDrawn = 0; - m_spritesInRun = 0; - m_spriteRuns.clear(); - - // Get the current render target dimensions and logical DPI. - - ComPtr renderTargetView; - m_d3dContext->OMGetRenderTargets( - 1, - &renderTargetView, - nullptr - ); - - ComPtr renderTarget; - renderTargetView->GetResource(&renderTarget); - - ComPtr renderTargetTexture; - renderTarget.As(&renderTargetTexture); - - D3D11_TEXTURE2D_DESC renderTargetTextureDesc; - renderTargetTexture->GetDesc(&renderTargetTextureDesc); - - m_renderTargetSize = float2( - static_cast(renderTargetTextureDesc.Width), - static_cast(renderTargetTextureDesc.Height) - ); - - m_mvpMatrix = identity(); - - m_dpi = Windows::Graphics::Display::DisplayProperties::LogicalDpi; -} - -void SpriteBatch::End() -{ - // If no sprites were drawn, do nothing. - if (m_numSpritesDrawn == 0) - { - return; - } - - // Save the final sprite run info. - - SpriteRunInfo runInfo; - runInfo.textureView = m_currentTextureView; - runInfo.blendState = m_currentBlendState; - runInfo.numSprites = m_spritesInRun; - m_spriteRuns.push_back(runInfo); - - // Update the buffer data. - - if (m_technique == RenderTechnique::GeometryShader || m_technique == RenderTechnique::Instancing) - { - CD3D11_BOX instanceDataBox( - 0, - 0, - 0, - sizeof(InstanceData) * m_numSpritesDrawn, - 1, - 1 - ); - - m_d3dContext->UpdateSubresource( - m_instanceDataBuffer.Get(), - 0, - &instanceDataBox, - m_instanceData.get(), - 0, - 0 - ); - } - else if (m_technique == RenderTechnique::Replication) - { - CD3D11_BOX vertexDataBox( - 0, - 0, - 0, - sizeof(ReplicationVertex) * m_numSpritesDrawn * 4, - 1, - 1 - ); - - m_d3dContext->UpdateSubresource( - m_vertexBuffer.Get(), - 0, - &vertexDataBox, - m_vertexData.get(), - 0, - 0 - ); - } - - if (m_technique == RenderTechnique::GeometryShader || m_technique == RenderTechnique::Instancing) - { - D3D11_MAPPED_SUBRESOURCE mappedSubresource; - m_d3dContext->Map( - m_renderTargetInfoCbuffer.Get(), - 0, - D3D11_MAP_WRITE_DISCARD, - 0, - &mappedSubresource - ); - *static_cast(mappedSubresource.pData) = m_renderTargetSize; - m_d3dContext->Unmap( - m_renderTargetInfoCbuffer.Get(), - 0 - ); - - m_d3dContext->Map( - m_mvpMatrixCbuffer.Get(), - 0, - D3D11_MAP_WRITE_DISCARD, - 0, - &mappedSubresource - ); - *static_cast(mappedSubresource.pData) = m_mvpMatrix; - m_d3dContext->Unmap( - m_mvpMatrixCbuffer.Get(), - 0 - ); - } - - // Set the pipeline state - - if (m_technique == RenderTechnique::Instancing) - { - m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - m_d3dContext->IASetIndexBuffer( - m_indexBuffer.Get(), - DXGI_FORMAT_R32_UINT, - 0 - ); - } - else if (m_technique == RenderTechnique::Replication) - { - m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - m_d3dContext->IASetIndexBuffer( - m_indexBuffer.Get(), - DXGI_FORMAT_R16_UINT, - 0 - ); - } - else if (m_technique == RenderTechnique::GeometryShader) - { - m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - m_d3dContext->GSSetShader( - m_geometryShader.Get(), - nullptr, - 0 - ); - } - - m_d3dContext->IASetInputLayout(m_inputLayout.Get()); - - m_d3dContext->VSSetShader( - m_vertexShader.Get(), - nullptr, - 0 - ); - - if (m_technique == RenderTechnique::GeometryShader) - { - m_d3dContext->GSSetConstantBuffers( - 0, - 1, - m_renderTargetInfoCbuffer.GetAddressOf() - ); - - m_d3dContext->GSSetConstantBuffers( - 1, - 1, - m_mvpMatrixCbuffer.GetAddressOf() - ); - } - else if (m_technique == RenderTechnique::Instancing) - { - m_d3dContext->VSSetConstantBuffers( - 0, - 1, - m_renderTargetInfoCbuffer.GetAddressOf() - ); - } - - m_d3dContext->PSSetShader( - m_pixelShader.Get(), - nullptr, - 0 - ); - - m_d3dContext->PSSetSamplers( - 0, - 1, - m_linearSampler.GetAddressOf() - ); - - if (m_technique == RenderTechnique::GeometryShader) - { - unsigned int stride = sizeof(InstanceData); - unsigned int offset = 0; - m_d3dContext->IASetVertexBuffers( - 0, - 1, - m_instanceDataBuffer.GetAddressOf(), - &stride, - &offset - ); - } - else if (m_technique == RenderTechnique::Instancing) - { - unsigned int stride = sizeof(InstancingVertex); - unsigned int offset = 0; - m_d3dContext->IASetVertexBuffers( - 0, - 1, - m_vertexBuffer.GetAddressOf(), - &stride, - &offset - ); - } - else if (m_technique == RenderTechnique::Replication) - { - unsigned int stride = sizeof(ReplicationVertex); - unsigned int offset = 0; - m_d3dContext->IASetVertexBuffers( - 0, - 1, - m_vertexBuffer.GetAddressOf(), - &stride, - &offset - ); - } - - // Draw each sprite run - - unsigned int indexBase = 0; - for (auto runIterator = m_spriteRuns.begin(); runIterator != m_spriteRuns.end(); runIterator++) - { - m_d3dContext->PSSetShaderResources( - 0, - 1, - &runIterator->textureView - ); - - const FLOAT blendFactor[] = {0.0f, 0.0f, 0.0f, 0.0f}; - - m_d3dContext->OMSetBlendState( - runIterator->blendState, - nullptr, - 0xFFFFFFFF - ); - - if (m_technique == RenderTechnique::GeometryShader) - { - unsigned int instancesToDraw = runIterator->numSprites; - m_d3dContext->DrawInstanced( - 1, - instancesToDraw, - 0, - indexBase - ); - indexBase += instancesToDraw; - } - else if (m_technique == RenderTechnique::Instancing) - { - unsigned int instancesToDraw = runIterator->numSprites; - unsigned int stride = sizeof(InstanceData); - unsigned int offset = indexBase * stride; - // Instance data offset must be zero for the draw call on feature level 9.3 and below. - // Instead, set the offset in the input assembler. - m_d3dContext->IASetVertexBuffers( - 1, - 1, - m_instanceDataBuffer.GetAddressOf(), - &stride, - &offset - ); - m_d3dContext->DrawIndexedInstanced( - 6, - instancesToDraw, - 0, - 0, - 0 - ); - indexBase += instancesToDraw; - } - else if (m_technique == RenderTechnique::Replication) - { - unsigned int indicesToDraw = runIterator->numSprites * 6; - m_d3dContext->DrawIndexed(indicesToDraw, indexBase, 0); - indexBase += indicesToDraw; - } - } -} - -unsigned int SpriteBatch::MakeUnorm(float4 color) -{ - unsigned int r = max(0, min(255, static_cast(color.r * 255.0f))); - unsigned int g = max(0, min(255, static_cast(color.g * 255.0f))); - unsigned int b = max(0, min(255, static_cast(color.b * 255.0f))); - unsigned int a = max(0, min(255, static_cast(color.a * 255.0f))); - return - (a << 24) | - (b << 16) | - (g << 8) | - r; -} - -float2 SpriteBatch::StandardOrigin(float2 position, PositionUnits positionUnits, float2 renderTargetSize, float dpi) -{ - float2 origin; - if (positionUnits == PositionUnits::Pixels) - { - origin.x = (position.x / renderTargetSize.x) * 2.0f - 1.0f; - origin.y = 1.0f - (position.y / renderTargetSize.y) * 2.0f; - } - else if (positionUnits == PositionUnits::DIPs) - { - origin.x = ((position.x * dpi / 96.0f) / renderTargetSize.x) * 2.0f - 1.0f; - origin.y = 1.0f - ((position.y * dpi / 96.0f) / renderTargetSize.y) * 2.0f; - } - else if (positionUnits == PositionUnits::Normalized) - { - origin.x = position.x * 2.0f - 1.0f; - origin.y = 1.0f - position.y * 2.0f; - } - else if (positionUnits == PositionUnits::UniformWidth) - { - origin.x = position.x * 2.0f - 1.0f; - origin.y = 1.0f - position.y * (renderTargetSize.x / renderTargetSize.y) * 2.0f; - } - else if (positionUnits == PositionUnits::UniformHeight) - { - origin.x = position.x * (renderTargetSize.y / renderTargetSize.x) * 2.0f - 1.0f; - origin.y = 1.0f - position.y * 2.0f; - } - return origin; -} - -float2 SpriteBatch::StandardOffset(float2 size, SizeUnits sizeUnits, float2 spriteSize, float dpi) -{ - float2 offset; - if (sizeUnits == SizeUnits::Pixels) - { - offset = size; - } - else if (sizeUnits == SizeUnits::DIPs) - { - offset = size * dpi / 96.0f; - } - else if (sizeUnits == SizeUnits::Normalized) - { - offset = spriteSize * size; - } - return offset; -} - -void SpriteBatch::Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits = PositionUnits::DIPs - ) -{ - Draw( - texture, - position, - positionUnits, - float2(1.0f, 1.0f), - SizeUnits::Normalized - ); -} - -void SpriteBatch::Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits - ) -{ - Draw( - texture, - position, - positionUnits, - size, - sizeUnits, - float4(1.0f, 1.0f, 1.0f, 1.0f) - ); -} - -void SpriteBatch::Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color - ) -{ - Draw( - texture, - position, - positionUnits, - size, - sizeUnits, - color, - 0.0f - ); -} - -void SpriteBatch::Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color, - _In_ float rotation - ) -{ - Draw( - texture, - position, - positionUnits, - size, - sizeUnits, - color, - rotation, - BlendMode::Alpha - ); -} - -void SpriteBatch::Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color, - _In_ float rotation, - _In_ BlendMode blendMode - ) -{ - Draw( - texture, - position, - positionUnits, - size, - sizeUnits, - color, - rotation, - blendMode, - float4(0.0f, 1.0f, 0.0f, 1.0f), - Vector4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF) - ); -} - - -void SpriteBatch::Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color, - _In_ float rotation, - _In_ BlendMode blendMode, - _In_ float4 textRect, - _In_ Vector4 colors - ) -{ - // Fail if drawing this sprite would exceed the capacity of the sprite batch. - if (m_numSpritesDrawn >= m_capacity) - { - throw ref new Platform::OutOfBoundsException(); - } - - // Retrieve information about the sprite. - TextureMapElement element = m_textureMap[texture]; - ID3D11ShaderResourceView* textureView = element.srv.Get(); - float2 textureSize = element.size; - ID3D11BlendState1* blendState = blendMode == BlendMode::Additive ? m_blendStateAdditive.Get() : m_blendStateAlpha.Get(); - - // Fail if the texture has not previously been added to the sprite batch. - if (textureView == nullptr) - { - throw ref new Platform::NullReferenceException(); - } - - // Unless this is the first sprite run, save out the previous run info if a new run is required. - if ( - m_numSpritesDrawn > 0 && ( - textureView != m_currentTextureView || - blendState != m_currentBlendState - ) - ) - { - SpriteRunInfo runInfo; - runInfo.textureView = m_currentTextureView; - runInfo.blendState = m_currentBlendState; - runInfo.numSprites = m_spritesInRun; - m_spriteRuns.push_back(runInfo); - m_spritesInRun = 0; // Reset for the next sprite run. - } - m_currentTextureView = textureView; - m_currentBlendState = blendState; - - // Add the sprite to the buffer. - - float2 origin = StandardOrigin(position, positionUnits, m_renderTargetSize, m_dpi); - float2 offset = StandardOffset(size, sizeUnits, textureSize, m_dpi); - - if (m_technique == RenderTechnique::GeometryShader || m_technique == RenderTechnique::Instancing) - { - m_instanceData[m_numSpritesDrawn].origin = origin; - m_instanceData[m_numSpritesDrawn].offset = offset; - m_instanceData[m_numSpritesDrawn].rotation = rotation; - m_instanceData[m_numSpritesDrawn].color = MakeUnorm(color); - m_instanceData[m_numSpritesDrawn].textRect = textRect; - m_instanceData[m_numSpritesDrawn].colors = colors; - } - else if (m_technique == RenderTechnique::Replication) - { - float2 offsets[4] = - { - float2(-offset.x, offset.y), - float2( offset.x, offset.y), - float2(-offset.x, -offset.y), - float2( offset.x, -offset.y) - }; - - float sinRotation = sinf(rotation); - float cosRotation = cosf(rotation); - - for (int i = 0; i < 4; i++) - { - offsets[i] = float2( - offsets[i].x * cosRotation - offsets[i].y * sinRotation, - offsets[i].x * sinRotation + offsets[i].y * cosRotation - ); - offsets[i].x /= m_renderTargetSize.x; - offsets[i].y /= m_renderTargetSize.y; - } - - // Write vertex buffer data. - - ReplicationVertex* singleSpriteVertices = &m_vertexData[m_numSpritesDrawn * 4]; - unsigned int colorUnorm = MakeUnorm(color); - singleSpriteVertices[0].pos = origin + offsets[0]; - singleSpriteVertices[1].pos = origin + offsets[1]; - singleSpriteVertices[2].pos = origin + offsets[2]; - singleSpriteVertices[3].pos = origin + offsets[3]; - singleSpriteVertices[0].color = colorUnorm; - singleSpriteVertices[1].color = colorUnorm; - singleSpriteVertices[2].color = colorUnorm; - singleSpriteVertices[3].color = colorUnorm; - singleSpriteVertices[0].tex = float2(0.0f, 0.0f); - singleSpriteVertices[1].tex = float2(1.0f, 0.0f); - singleSpriteVertices[2].tex = float2(0.0f, 1.0f); - singleSpriteVertices[3].tex = float2(1.0f, 1.0f); - } - - m_spritesInRun++; - m_numSpritesDrawn++; -} diff --git a/JGE/src/DirectX/BasicSprites.h b/JGE/src/DirectX/BasicSprites.h deleted file mode 100644 index 817c5bdf1..000000000 --- a/JGE/src/DirectX/BasicSprites.h +++ /dev/null @@ -1,195 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved - -#pragma once - -#include "BasicMath.h" -#include -#include -#include - -namespace BasicSprites -{ - namespace Parameters - { - // The index buffer format for feature-level 9.1 devices may only be 16 bits. - // With 4 vertices per sprite, this allows a maximum of (1 << 16) / 4 sprites. - static unsigned int MaximumCapacityCompatible = (1 << 16) / 4; - } - - enum class PositionUnits - { - DIPs, // Interpret position as device-independent pixel values. - Pixels, // Interpret position as pixel values. - Normalized, // Interpret position as a fraction of the render target dimensions. - UniformWidth, // Interpret position as a fraction of the render target width. - UniformHeight // Interpret position as a fraction of the render target height. - }; - - enum class SizeUnits - { - DIPs, // Interpret size as device-independent pixel values. - Pixels, // Interpret size as pixel values. - Normalized // Interpret size as a multiplier of the pixel size of the sprite. - }; - - enum class BlendMode - { - Alpha, // Use alpha blending (out = old * (1 - new.a) + new * new.a). - Additive // Use additive blending (out = old + new * new.a). - }; - - enum class RenderTechnique - { - Replication, - Instancing, - GeometryShader - }; - - struct ReplicationVertex - { - float2 pos; - float2 tex; - unsigned int color; - }; - - struct InstancingVertex - { - float2 pos; - float2 tex; - }; - - struct InstanceData - { - float2 origin; - float2 offset; - float rotation; - float4 textRect; - Vector4 colors; - float4 pt_x; - float4 pt_y; - unsigned int color; - }; - - struct TextureMapElement - { - Microsoft::WRL::ComPtr srv; - float2 size; - }; - - struct SpriteRunInfo - { - ID3D11ShaderResourceView* textureView; - ID3D11BlendState1* blendState; - unsigned int numSprites; - }; - - ref class SpriteBatch - { - internal: - SpriteBatch(); - void Initialize( - _In_ ID3D11Device1* d3dDevice, - _In_ int capacity = 1024 - ); - void AddTexture( - _In_ ID3D11Texture2D* texture - ); - void RemoveTexture( - _In_ ID3D11Texture2D* texture - ); - void Begin(); - void End(); - void Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits - ); - void Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits - ); - void Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color - ); - void Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color, - _In_ float rotation - ); - void Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color, - _In_ float rotation, - _In_ BlendMode blendMode - ); - void Draw( - _In_ ID3D11Texture2D* texture, - _In_ float2 position, - _In_ PositionUnits positionUnits, - _In_ float2 size, - _In_ SizeUnits sizeUnits, - _In_ float4 color, - _In_ float rotation, - _In_ BlendMode blendMode, - _In_ float4 textRect, - _In_ Vector4 colors - ); - - private: - unsigned int MakeUnorm(float4 color); - float2 StandardOrigin(float2 position, PositionUnits positionUnits, float2 renderTargetSize, float dpi); - float2 StandardOffset(float2 size, SizeUnits sizeUnits, float2 spriteSize, float dpi); - - Microsoft::WRL::ComPtr m_d3dDevice; - Microsoft::WRL::ComPtr m_d3dContext; - Microsoft::WRL::ComPtr m_vertexBuffer; - Microsoft::WRL::ComPtr m_instanceDataBuffer; - Microsoft::WRL::ComPtr m_indexBuffer; - Microsoft::WRL::ComPtr m_blendStateAlpha; - Microsoft::WRL::ComPtr m_blendStateAdditive; - Microsoft::WRL::ComPtr m_inputLayout; - Microsoft::WRL::ComPtr m_vertexShader; - Microsoft::WRL::ComPtr m_geometryShader; - Microsoft::WRL::ComPtr m_pixelShader; - Microsoft::WRL::ComPtr m_linearSampler; - Microsoft::WRL::ComPtr m_renderTargetInfoCbuffer; - Microsoft::WRL::ComPtr m_mvpMatrixCbuffer; - - std::unique_ptr m_vertexData; - std::unique_ptr m_instanceData; - std::map m_textureMap; - std::vector m_spriteRuns; - - RenderTechnique m_technique; - ID3D11ShaderResourceView* m_currentTextureView; - ID3D11BlendState1* m_currentBlendState; - float2 m_renderTargetSize; - float4x4 m_mvpMatrix; - - int m_capacity; - int m_spritesInRun; - int m_numSpritesDrawn; - float m_dpi; - }; -} diff --git a/JGE/src/DirectX/BasicSprites.ps.hlsl b/JGE/src/DirectX/BasicSprites.ps.hlsl deleted file mode 100644 index e7da5dd03..000000000 --- a/JGE/src/DirectX/BasicSprites.ps.hlsl +++ /dev/null @@ -1,24 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -// PARTICULAR PURPOSE. -// -// Copyright (c) Microsoft Corporation. All rights reserved -//---------------------------------------------------------------------- - -Texture2D spriteTexture : register(t0); -SamplerState linearSampler : register(s0); - -struct PixelShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -// This general-purpose pixel shader draws a bound texture with optionally modified color channels. - -float4 main(PixelShaderInput input) : SV_TARGET -{ - return input.color * spriteTexture.Sample(linearSampler, input.tex); -} diff --git a/JGE/src/DirectX/CommonStates.cpp b/JGE/src/DirectX/CommonStates.cpp new file mode 100644 index 000000000..8186b1d9d --- /dev/null +++ b/JGE/src/DirectX/CommonStates.cpp @@ -0,0 +1,373 @@ +//-------------------------------------------------------------------------------------- +// File: CommonStates.cpp +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +//#include "pch.h" +#include +#include +using namespace Microsoft::WRL; + +#include "CommonStates.h" +#include "DemandCreate.h" +#include "DirectXHelpers.h" +#include "SharedResourcePool.h" + +using namespace DirectX; +using namespace Microsoft::WRL; + + +// Internal state object implementation class. Only one of these helpers is allocated +// per D3D device, even if there are multiple public facing CommonStates instances. +class CommonStates::Impl +{ +public: + Impl(_In_ ID3D11Device* device) + : device(device) + { } + + HRESULT CreateBlendState(D3D11_BLEND srcBlend, D3D11_BLEND destBlend, _Out_ ID3D11BlendState** pResult); + HRESULT CreateDepthStencilState(bool enable, bool writeEnable, _Out_ ID3D11DepthStencilState** pResult); + HRESULT CreateRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode, _Out_ ID3D11RasterizerState** pResult); + HRESULT CreateSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode, _Out_ ID3D11SamplerState** pResult); + + ComPtr device; + + ComPtr opaque; + ComPtr alphaBlend; + ComPtr additive; + ComPtr nonPremultiplied; + + ComPtr depthNone; + ComPtr depthDefault; + ComPtr depthRead; + + ComPtr cullNone; + ComPtr cullClockwise; + ComPtr cullCounterClockwise; + ComPtr wireframe; + + ComPtr pointWrap; + ComPtr pointClamp; + ComPtr linearWrap; + ComPtr linearClamp; + ComPtr anisotropicWrap; + ComPtr anisotropicClamp; + + std::mutex mutex; + + static SharedResourcePool instancePool; +}; + + +// Global instance pool. +SharedResourcePool CommonStates::Impl::instancePool; + + +// Helper for creating blend state objects. +HRESULT CommonStates::Impl::CreateBlendState(D3D11_BLEND srcBlend, D3D11_BLEND destBlend, _Out_ ID3D11BlendState** pResult) +{ + D3D11_BLEND_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.RenderTarget[0].BlendEnable = (srcBlend != D3D11_BLEND_ONE) || + (destBlend != D3D11_BLEND_ZERO); + + desc.RenderTarget[0].SrcBlend = desc.RenderTarget[0].SrcBlendAlpha = srcBlend; + desc.RenderTarget[0].DestBlend = desc.RenderTarget[0].DestBlendAlpha = destBlend; + desc.RenderTarget[0].BlendOp = desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + + desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + HRESULT hr = device->CreateBlendState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +// Helper for creating depth stencil state objects. +HRESULT CommonStates::Impl::CreateDepthStencilState(bool enable, bool writeEnable, _Out_ ID3D11DepthStencilState** pResult) +{ + D3D11_DEPTH_STENCIL_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.DepthEnable = enable; + desc.DepthWriteMask = writeEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; + desc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + + desc.StencilEnable = false; + desc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; + desc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; + + desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; + desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + + desc.BackFace = desc.FrontFace; + + HRESULT hr = device->CreateDepthStencilState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +// Helper for creating rasterizer state objects. +HRESULT CommonStates::Impl::CreateRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode, _Out_ ID3D11RasterizerState** pResult) +{ + D3D11_RASTERIZER_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.CullMode = cullMode; + desc.FillMode = fillMode; + desc.DepthClipEnable = true; + desc.MultisampleEnable = true; + + HRESULT hr = device->CreateRasterizerState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +// Helper for creating sampler state objects. +HRESULT CommonStates::Impl::CreateSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode, _Out_ ID3D11SamplerState** pResult) +{ + D3D11_SAMPLER_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.Filter = filter; + + desc.AddressU = addressMode; + desc.AddressV = addressMode; + desc.AddressW = addressMode; + + desc.MaxAnisotropy = (device->GetFeatureLevel() > D3D_FEATURE_LEVEL_9_1) ? 16 : 2; + + desc.MaxLOD = FLT_MAX; + desc.ComparisonFunc = D3D11_COMPARISON_NEVER; + + HRESULT hr = device->CreateSamplerState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +//-------------------------------------------------------------------------------------- +// CommonStates +//-------------------------------------------------------------------------------------- + +// Public constructor. +CommonStates::CommonStates(_In_ ID3D11Device* device) + : pImpl(Impl::instancePool.DemandCreate(device)) +{ +} + + +// Move constructor. +CommonStates::CommonStates(CommonStates&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +CommonStates& CommonStates::operator= (CommonStates&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +CommonStates::~CommonStates() +{ +} + + +//-------------------------------------------------------------------------------------- +// Blend states +//-------------------------------------------------------------------------------------- + +ID3D11BlendState* CommonStates::Opaque() const +{ + return DemandCreate(pImpl->opaque, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_ONE, D3D11_BLEND_ZERO, pResult); + }); +} + + +ID3D11BlendState* CommonStates::AlphaBlend() const +{ + return DemandCreate(pImpl->alphaBlend, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, pResult); + }); +} + + +ID3D11BlendState* CommonStates::Additive() const +{ + return DemandCreate(pImpl->additive, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_ONE, pResult); + }); +} + + +ID3D11BlendState* CommonStates::NonPremultiplied() const +{ + return DemandCreate(pImpl->nonPremultiplied, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA, pResult); + }); +} + + +//-------------------------------------------------------------------------------------- +// Depth stencil states +//-------------------------------------------------------------------------------------- + +ID3D11DepthStencilState* CommonStates::DepthNone() const +{ + return DemandCreate(pImpl->depthNone, pImpl->mutex, [&](ID3D11DepthStencilState** pResult) + { + return pImpl->CreateDepthStencilState(false, false, pResult); + }); +} + + +ID3D11DepthStencilState* CommonStates::DepthDefault() const +{ + return DemandCreate(pImpl->depthDefault, pImpl->mutex, [&](ID3D11DepthStencilState** pResult) + { + return pImpl->CreateDepthStencilState(true, true, pResult); + }); +} + + +ID3D11DepthStencilState* CommonStates::DepthRead() const +{ + return DemandCreate(pImpl->depthRead, pImpl->mutex, [&](ID3D11DepthStencilState** pResult) + { + return pImpl->CreateDepthStencilState(true, false, pResult); + }); +} + + +//-------------------------------------------------------------------------------------- +// Rasterizer states +//-------------------------------------------------------------------------------------- + +ID3D11RasterizerState* CommonStates::CullNone() const +{ + return DemandCreate(pImpl->cullNone, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_NONE, D3D11_FILL_SOLID, pResult); + }); +} + + +ID3D11RasterizerState* CommonStates::CullClockwise() const +{ + return DemandCreate(pImpl->cullClockwise, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_FRONT, D3D11_FILL_SOLID, pResult); + }); +} + + +ID3D11RasterizerState* CommonStates::CullCounterClockwise() const +{ + return DemandCreate(pImpl->cullCounterClockwise, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_BACK, D3D11_FILL_SOLID, pResult); + }); +} + + +ID3D11RasterizerState* CommonStates::Wireframe() const +{ + return DemandCreate(pImpl->wireframe, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_BACK, D3D11_FILL_WIREFRAME, pResult); + }); +} + + +//-------------------------------------------------------------------------------------- +// Sampler states +//-------------------------------------------------------------------------------------- + +ID3D11SamplerState* CommonStates::PointWrap() const +{ + return DemandCreate(pImpl->pointWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_WRAP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::PointClamp() const +{ + return DemandCreate(pImpl->pointClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::LinearWrap() const +{ + return DemandCreate(pImpl->linearWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_WRAP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::LinearClamp() const +{ + return DemandCreate(pImpl->linearClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::AnisotropicWrap() const +{ + return DemandCreate(pImpl->anisotropicWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_ANISOTROPIC, D3D11_TEXTURE_ADDRESS_WRAP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::AnisotropicClamp() const +{ + return DemandCreate(pImpl->anisotropicClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_ANISOTROPIC, D3D11_TEXTURE_ADDRESS_CLAMP, pResult); + }); +} diff --git a/JGE/src/DirectX/CommonStates.h b/JGE/src/DirectX/CommonStates.h new file mode 100644 index 000000000..61b14c532 --- /dev/null +++ b/JGE/src/DirectX/CommonStates.h @@ -0,0 +1,70 @@ +//-------------------------------------------------------------------------------------- +// File: CommonStates.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include + + +namespace DirectX +{ + class CommonStates + { + public: + explicit CommonStates(_In_ ID3D11Device* device); + CommonStates(CommonStates&& moveFrom); + CommonStates& operator= (CommonStates&& moveFrom); + virtual ~CommonStates(); + + // Blend states. + ID3D11BlendState* __cdecl Opaque() const; + ID3D11BlendState* __cdecl AlphaBlend() const; + ID3D11BlendState* __cdecl Additive() const; + ID3D11BlendState* __cdecl NonPremultiplied() const; + + // Depth stencil states. + ID3D11DepthStencilState* __cdecl DepthNone() const; + ID3D11DepthStencilState* __cdecl DepthDefault() const; + ID3D11DepthStencilState* __cdecl DepthRead() const; + + // Rasterizer states. + ID3D11RasterizerState* __cdecl CullNone() const; + ID3D11RasterizerState* __cdecl CullClockwise() const; + ID3D11RasterizerState* __cdecl CullCounterClockwise() const; + ID3D11RasterizerState* __cdecl Wireframe() const; + + // Sampler states. + ID3D11SamplerState* __cdecl PointWrap() const; + ID3D11SamplerState* __cdecl PointClamp() const; + ID3D11SamplerState* __cdecl LinearWrap() const; + ID3D11SamplerState* __cdecl LinearClamp() const; + ID3D11SamplerState* __cdecl AnisotropicWrap() const; + ID3D11SamplerState* __cdecl AnisotropicClamp() const; + + private: + // Private implementation. + class Impl; + + std::shared_ptr pImpl; + + // Prevent copying. + CommonStates(CommonStates const&); + CommonStates& operator= (CommonStates const&); + }; +} diff --git a/JGE/src/DirectX/ConstantBuffer.h b/JGE/src/DirectX/ConstantBuffer.h new file mode 100644 index 000000000..9dae01f6e --- /dev/null +++ b/JGE/src/DirectX/ConstantBuffer.h @@ -0,0 +1,85 @@ +//-------------------------------------------------------------------------------------- +// File: ConstantBuffer.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "DirectXHelpers.h" +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Strongly typed wrapper around a D3D constant buffer. + template + class ConstantBuffer + { + public: + // Constructor. + ConstantBuffer() {} + explicit ConstantBuffer(_In_ ID3D11Device* device) + { + Create( device ); + } + + + void Create(_In_ ID3D11Device* device) + { + D3D11_BUFFER_DESC desc = { 0 }; + + desc.ByteWidth = sizeof(T); + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + ThrowIfFailed( + device->CreateBuffer(&desc, nullptr, mConstantBuffer.ReleaseAndGetAddressOf() ) + ); + + SetDebugObjectName(mConstantBuffer.Get(), "DirectXTK"); + } + + + // Writes new data into the constant buffer. + void SetData(_In_ ID3D11DeviceContext* deviceContext, T const& value) + { + assert( mConstantBuffer.Get() != 0 ); + + D3D11_MAPPED_SUBRESOURCE mappedResource; + + ThrowIfFailed( + deviceContext->Map(mConstantBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource) + ); + + *(T*)mappedResource.pData = value; + + deviceContext->Unmap(mConstantBuffer.Get(), 0); + } + + + // Looks up the underlying D3D constant buffer. + ID3D11Buffer* GetBuffer() + { + return mConstantBuffer.Get(); + } + + + private: + // The underlying D3D object. + Microsoft::WRL::ComPtr mConstantBuffer; + + + // Prevent copying. + ConstantBuffer(ConstantBuffer const&); + ConstantBuffer& operator= (ConstantBuffer const&); + }; +} diff --git a/JGE/src/DirectX/DemandCreate.h b/JGE/src/DirectX/DemandCreate.h new file mode 100644 index 000000000..968c41940 --- /dev/null +++ b/JGE/src/DirectX/DemandCreate.h @@ -0,0 +1,51 @@ +//-------------------------------------------------------------------------------------- +// File: DemandCreate.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Helper for lazily creating a D3D resource. + template + static T* DemandCreate(Microsoft::WRL::ComPtr& comPtr, std::mutex& mutex, TCreateFunc createFunc) + { + T* result = comPtr.Get(); + + // Double-checked lock pattern. + MemoryBarrier(); + + if (!result) + { + std::lock_guard lock(mutex); + + result = comPtr.Get(); + + if (!result) + { + // Create the new object. + ThrowIfFailed( + createFunc(&result) + ); + + MemoryBarrier(); + + comPtr.Attach(result); + } + } + + return result; + } +} diff --git a/JGE/src/DirectX/DirectXHelpers.h b/JGE/src/DirectX/DirectXHelpers.h new file mode 100644 index 000000000..37f1c2974 --- /dev/null +++ b/JGE/src/DirectX/DirectXHelpers.h @@ -0,0 +1,120 @@ +//-------------------------------------------------------------------------------------- +// File: DirectXHelpers.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#define NO_D3D11_DEBUG_NAME +#else +#include +#endif + +#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) +#pragma comment(lib,"dxguid.lib") +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +// +// The core Direct3D headers provide the following helper C++ classes +// CD3D11_RECT +// CD3D11_BOX +// CD3D11_DEPTH_STENCIL_DESC +// CD3D11_BLEND_DESC, CD3D11_BLEND_DESC1 +// CD3D11_RASTERIZER_DESC, CD3D11_RASTERIZER_DESC1 +// CD3D11_BUFFER_DESC +// CD3D11_TEXTURE1D_DESC +// CD3D11_TEXTURE2D_DESC +// CD3D11_TEXTURE3D_DESC +// CD3D11_SHADER_RESOURCE_VIEW_DESC +// CD3D11_RENDER_TARGET_VIEW_DESC +// CD3D11_VIEWPORT +// CD3D11_DEPTH_STENCIL_VIEW_DESC +// CD3D11_UNORDERED_ACCESS_VIEW_DESC +// CD3D11_SAMPLER_DESC +// CD3D11_QUERY_DESC +// CD3D11_COUNTER_DESC +// + + +namespace DirectX +{ + // simliar to std::lock_guard for exception-safe Direct3D 11 resource locking + class MapGuard : public D3D11_MAPPED_SUBRESOURCE + { + public: + MapGuard( _In_ ID3D11DeviceContext* context, + _In_ ID3D11Resource *resource, + _In_ UINT subresource, + _In_ D3D11_MAP mapType, + _In_ UINT mapFlags ) + : mContext(context), mResource(resource), mSubresource(subresource) + { + HRESULT hr = mContext->Map( resource, subresource, mapType, mapFlags, this ); + if (FAILED(hr)) + { + throw std::exception(); + } + } + + ~MapGuard() + { + mContext->Unmap( mResource, mSubresource ); + } + + uint8_t* get() const + { + return reinterpret_cast( pData ); + } + uint8_t* get(size_t slice) const + { + return reinterpret_cast( pData ) + ( slice * DepthPitch ); + } + + uint8_t* scanline(size_t row) const + { + return reinterpret_cast( pData ) + ( row * RowPitch ); + } + uint8_t* scanline(size_t slice, size_t row) const + { + return reinterpret_cast( pData ) + ( slice * DepthPitch ) + ( row * RowPitch ); + } + + private: + ID3D11DeviceContext* mContext; + ID3D11Resource* mResource; + UINT mSubresource; + + MapGuard(MapGuard const&); + MapGuard& operator= (MapGuard const&); + }; + + + // Helper sets a D3D resource name string (used by PIX and debug layer leak reporting). + template + inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const char (&name)[TNameLength]) + { + #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); + #else + UNREFERENCED_PARAMETER(resource); + UNREFERENCED_PARAMETER(name); + #endif + } +} \ No newline at end of file diff --git a/JGE/src/DirectX/JGfx.cpp b/JGE/src/DirectX/JGfx.cpp index 8d34293fc..da2bf2d2a 100644 --- a/JGE/src/DirectX/JGfx.cpp +++ b/JGE/src/DirectX/JGfx.cpp @@ -7,6 +7,10 @@ // Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) // //------------------------------------------------------------------------------------- + +#include "PrecompiledHeader.h" +#undef DebugTrace + #if (!defined IOS) && (!defined QT_CONFIG) #if (defined WIN32) && (!defined WP8) #pragma warning(disable : 4786) @@ -21,14 +25,17 @@ #include #include #include -#include "BasicSprites.h" #include -using namespace BasicSprites; +//using namespace BasicSprites; using namespace Microsoft::WRL; using namespace DirectX; using namespace Windows::UI::Core; using namespace Windows::Foundation; using namespace Windows::Graphics::Display; +#include "SpriteBatch.h" +#include "CommonStates.h" +#include "PlatformHelpers.h" +using namespace DirectX; #endif #include @@ -57,42 +64,45 @@ extern "C" { #endif #endif -typedef float4x4 ESMatrix; +//typedef float4x4 ESMatrix; typedef float GLfloat; +typedef struct { + GLfloat m[4][4]; +} ESMatrix; void esMatrixLoadIdentity(ESMatrix *result) { memset(result, 0x0, sizeof(ESMatrix)); - (*result)[0][0] = 1.0f; - (*result)[1][1] = 1.0f; - (*result)[2][2] = 1.0f; - (*result)[3][3] = 1.0f; + result->m[0][0] = 1.0f; + result->m[1][1] = 1.0f; + result->m[2][2] = 1.0f; + result->m[3][3] = 1.0f; } void esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz) { - (*result)[0][0] *= sx; - (*result)[0][1] *= sx; - (*result)[0][2] *= sx; - (*result)[0][3] *= sx; + result->m[0][0] *= sx; + result->m[0][1] *= sx; + result->m[0][2] *= sx; + result->m[0][3] *= sx; - (*result)[1][0] *= sy; - (*result)[1][1] *= sy; - (*result)[1][2] *= sy; - (*result)[1][3] *= sy; + result->m[1][0] *= sy; + result->m[1][1] *= sy; + result->m[1][2] *= sy; + result->m[1][3] *= sy; - (*result)[2][0] *= sz; - (*result)[2][1] *= sz; - (*result)[2][2] *= sz; - (*result)[2][3] *= sz; + result->m[2][0] *= sz; + result->m[2][1] *= sz; + result->m[2][2] *= sz; + result->m[2][3] *= sz; } void esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz) { - (*result)[3][0] += ((*result)[0][0] * tx + (*result)[1][0] * ty + (*result)[2][0] * tz); - (*result)[3][1] += ((*result)[0][1] * tx + (*result)[1][1] * ty + (*result)[2][1] * tz); - (*result)[3][2] += ((*result)[0][2] * tx + (*result)[1][2] * ty + (*result)[2][2] * tz); - (*result)[3][3] += ((*result)[0][3] * tx + (*result)[1][3] * ty + (*result)[2][3] * tz); + result->m[3][0] += (result->m[0][0] * tx + result->m[1][0] * ty + result->m[2][0] * tz); + result->m[3][1] += (result->m[0][1] * tx + result->m[1][1] * ty + result->m[2][1] * tz); + result->m[3][2] += (result->m[0][2] * tx + result->m[1][2] * ty + result->m[2][2] * tz); + result->m[3][3] += (result->m[0][3] * tx + result->m[1][3] * ty + result->m[2][3] * tz); } void esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB) @@ -102,25 +112,25 @@ void esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB) for (i=0; i<4; i++) { - tmp[i][0] = ((*srcA)[i][0] * (*srcB)[0][0]) + - ((*srcA)[i][1] * (*srcB)[1][0]) + - ((*srcA)[i][2] * (*srcB)[2][0]) + - ((*srcA)[i][3] * (*srcB)[3][0]) ; + tmp.m[i][0] = (srcA->m[i][0] * srcB->m[0][0]) + + (srcA->m[i][1] * srcB->m[1][0]) + + (srcA->m[i][2] * srcB->m[2][0]) + + (srcA->m[i][3] * srcB->m[3][0]) ; - tmp[i][1] = ((*srcA)[i][0] * (*srcB)[0][1]) + - ((*srcA)[i][1] * (*srcB)[1][1]) + - ((*srcA)[i][2] * (*srcB)[2][1]) + - ((*srcA)[i][3] * (*srcB)[3][1]) ; + tmp.m[i][1] = (srcA->m[i][0] * srcB->m[0][1]) + + (srcA->m[i][1] * srcB->m[1][1]) + + (srcA->m[i][2] * srcB->m[2][1]) + + (srcA->m[i][3] * srcB->m[3][1]) ; - tmp[i][2] = ((*srcA)[i][0] * (*srcB)[0][2]) + - ((*srcA)[i][1] * (*srcB)[1][2]) + - ((*srcA)[i][2] * (*srcB)[2][2]) + - ((*srcA)[i][3] * (*srcB)[3][2]) ; + tmp.m[i][2] = (srcA->m[i][0] * srcB->m[0][2]) + + (srcA->m[i][1] * srcB->m[1][2]) + + (srcA->m[i][2] * srcB->m[2][2]) + + (srcA->m[i][3] * srcB->m[3][2]) ; - tmp[i][3] = ((*srcA)[i][0] * (*srcB)[0][3]) + - ((*srcA)[i][1] * (*srcB)[1][3]) + - ((*srcA)[i][2] * (*srcB)[2][3]) + - ((*srcA)[i][3] * (*srcB)[3][3]) ; + tmp.m[i][3] = (srcA->m[i][0] * srcB->m[0][3]) + + (srcA->m[i][1] * srcB->m[1][3]) + + (srcA->m[i][2] * srcB->m[2][3]) + + (srcA->m[i][3] * srcB->m[3][3]) ; } /* * Actually, srcA and srcB are column-major order matrixes, while they @@ -183,25 +193,25 @@ void esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) // Note: matrixes in OpenGL ES are stored in column-major order! - rotMat[0][0] = (oneMinusCos * xx) + cosAngle; - rotMat[1][0] = (oneMinusCos * xy) - zs; - rotMat[2][0] = (oneMinusCos * zx) + ys; - rotMat[3][0] = 0.0F; + rotMat.m[0][0] = (oneMinusCos * xx) + cosAngle; + rotMat.m[1][0] = (oneMinusCos * xy) - zs; + rotMat.m[2][0] = (oneMinusCos * zx) + ys; + rotMat.m[3][0] = 0.0F; - rotMat[0][1] = (oneMinusCos * xy) + zs; - rotMat[1][1] = (oneMinusCos * yy) + cosAngle; - rotMat[2][1] = (oneMinusCos * yz) - xs; - rotMat[3][1] = 0.0F; + rotMat.m[0][1] = (oneMinusCos * xy) + zs; + rotMat.m[1][1] = (oneMinusCos * yy) + cosAngle; + rotMat.m[2][1] = (oneMinusCos * yz) - xs; + rotMat.m[3][1] = 0.0F; - rotMat[0][2] = (oneMinusCos * zx) - ys; - rotMat[1][2] = (oneMinusCos * yz) + xs; - rotMat[2][2] = (oneMinusCos * zz) + cosAngle; - rotMat[3][2] = 0.0F; + rotMat.m[0][2] = (oneMinusCos * zx) - ys; + rotMat.m[1][2] = (oneMinusCos * yz) + xs; + rotMat.m[2][2] = (oneMinusCos * zz) + cosAngle; + rotMat.m[3][2] = 0.0F; - rotMat[0][3] = 0.0F; - rotMat[1][3] = 0.0F; - rotMat[2][3] = 0.0F; - rotMat[3][3] = 1.0F; + rotMat.m[0][3] = 0.0F; + rotMat.m[1][3] = 0.0F; + rotMat.m[2][3] = 0.0F; + rotMat.m[3][3] = 1.0F; esMatrixMultiply( result, &rotMat, result ); } @@ -218,12 +228,12 @@ void esOrtho(ESMatrix *result, float left, float right, float bottom, float top, return; esMatrixLoadIdentity(&ortho); - ortho[0][0] = 2.0f / deltaX; - ortho[3][0] = -(right + left) / deltaX; - ortho[1][1] = 2.0f / deltaY; - ortho[3][1] = -(top + bottom) / deltaY; - ortho[2][2] = -2.0f / deltaZ; - ortho[3][2] = -(nearZ + farZ) / deltaZ; + ortho.m[0][0] = 2.0f / deltaX; + ortho.m[3][0] = -(right + left) / deltaX; + ortho.m[1][1] = 2.0f / deltaY; + ortho.m[3][1] = -(top + bottom) / deltaY; + ortho.m[2][2] = -2.0f / deltaZ; + ortho.m[3][2] = -(nearZ + farZ) / deltaZ; esMatrixMultiply(result, &ortho, result); } @@ -282,25 +292,24 @@ void JQuad::SetHotSpot(float x, float y) } JRenderer* JRenderer::mInstance = NULL; -BasicSprites::SpriteBatch^ mspriteBatchInstance; bool JRenderer::m3DEnabled = false; ////////////////////////////////////////////////////////////////////////// JTexture::JTexture() : mBuffer(NULL) { - mTexId = (ID3D11Texture2D*)-1; + mTexId = (ID3D11ShaderResourceView*)0; } JTexture::~JTexture() { if (mBuffer) { + if(mTexId) + mTexId->Release(); delete [] mBuffer; mBuffer = NULL; } - - mspriteBatchInstance->RemoveTexture(mTexId); } @@ -318,8 +327,6 @@ JRenderer* JRenderer::GetInstance() if (mInstance == NULL) { mInstance = new JRenderer(); - mspriteBatchInstance = ref new SpriteBatch(); - JASSERT(mInstance != NULL); mInstance->InitRenderer(); @@ -336,7 +343,6 @@ void JRenderer::Destroy() mInstance->DestroyRenderer(); delete mInstance; mInstance = NULL; - mspriteBatchInstance = nullptr; } } @@ -387,7 +393,7 @@ void JRenderer::InitRenderer() // Create the Direct3D 11 API device object and a corresponding context. ComPtr device; ComPtr context; - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( D3D11CreateDevice( nullptr, // Specify nullptr to use the default adapter. D3D_DRIVER_TYPE_HARDWARE, @@ -403,17 +409,15 @@ void JRenderer::InitRenderer() ); // Get the Direct3D 11.1 API device and context interfaces. - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( device.As(&m_d3dDevice) ); - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( context.As(&m_d3dContext) ); - mspriteBatchInstance->Initialize( - m_d3dDevice.Get(), 10024 - ); + m_spriteBatch = new SpriteBatch(m_d3dContext.Get()); } void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight) @@ -434,7 +438,7 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight if(m_swapChain != nullptr) { // If the swap chain already exists, resize it. - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( m_swapChain->ResizeBuffers( 2, // Double-buffered swap chain. static_cast(mWindowWidth), @@ -461,17 +465,17 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight swapChainDesc.Flags = 0; ComPtr dxgiDevice; - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( m_d3dDevice.As(&dxgiDevice) ); ComPtr dxgiAdapter; - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( dxgiDevice->GetAdapter(&dxgiAdapter) ); ComPtr dxgiFactory; - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( dxgiAdapter->GetParent( __uuidof(IDXGIFactory2), &dxgiFactory @@ -479,7 +483,7 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight ); // Windows::UI::Core::CoreWindow* window = (Windows::UI::Core::CoreWindow*)window.Get(); - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( dxgiFactory->CreateSwapChainForCoreWindow( m_d3dDevice.Get(), m_Window.Get(), @@ -491,14 +495,14 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight // Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and // ensures that the application will only render after each VSync, minimizing power consumption. - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( dxgiDevice->SetMaximumFrameLatency(1) ); } // Create a render target view of the swap chain back buffer. ComPtr backBuffer; - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( m_swapChain->GetBuffer( 0, __uuidof(ID3D11Texture2D), @@ -506,7 +510,7 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight ) ); - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( m_d3dDevice->CreateRenderTargetView( backBuffer.Get(), nullptr, @@ -529,7 +533,7 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight ); ComPtr depthStencil; - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( m_d3dDevice->CreateTexture2D( &depthStencilDesc, nullptr, @@ -538,7 +542,7 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight ); CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D); - DX::ThrowIfFailed( + DirectX::ThrowIfFailed( m_d3dDevice->CreateDepthStencilView( depthStencil.Get(), &depthStencilViewDesc, @@ -561,6 +565,9 @@ void JRenderer::OnWindowsSizeChanged(void* window, float inWidth, float inHeight void JRenderer::DestroyRenderer() { + if(m_spriteBatch) + delete m_spriteBatch; + m_spriteBatch = NULL; } void JRenderer::BeginScene() @@ -576,14 +583,15 @@ void JRenderer::BeginScene() reinterpret_cast(&D2D1::ColorF(D2D1::ColorF::MidnightBlue)) ); - mspriteBatchInstance->Begin(); + CommonStates states(m_d3dDevice.Get()); + m_spriteBatch->Begin(SpriteSortMode_Deferred, states.NonPremultiplied()); } void JRenderer::EndScene() { - mspriteBatchInstance->End(); + m_spriteBatch->End(); // The application may optionally specify "dirty" or "scroll" // rects to improve efficiency in certain scenarios. @@ -623,7 +631,7 @@ void JRenderer::EndScene() } else { - DX::ThrowIfFailed(hr); + DirectX::ThrowIfFailed(hr); } } @@ -654,66 +662,127 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x float x = -quad->mHotSpotX; float y = quad->mHotSpotY; - mspriteBatchInstance->Draw( - quad->mTex->mTexId, - float2( -// ((xo+((width*xScale)/2))*GetActualWidth())/SCREEN_WIDTH_F, -// ((yo+((height*yScale)/2))*GetActualHeight())/SCREEN_HEIGHT_F), - ((xo)*GetActualWidth())/SCREEN_WIDTH_F, - ((yo)*GetActualHeight())/SCREEN_HEIGHT_F), - PositionUnits::Pixels, - float2( - (width*xScale*GetActualWidth())/SCREEN_WIDTH_F, - (height*yScale*GetActualHeight())/SCREEN_HEIGHT_F - ), - SizeUnits::Pixels, - float4( - quad->mColor[0].r/255.0f, - quad->mColor[0].g/255.0f, - quad->mColor[0].b/255.0f, - quad->mColor[0].a/255.0f), - -angle, - BlendMode::Alpha, - float4(quad->mTX0, quad->mTX1, quad->mTY0, quad->mTY1), - Vector4(quad->mColor[0].color, quad->mColor[1].color, quad->mColor[2].color, quad->mColor[3].color) + XMVECTORF32 position = { + ((xo)*GetActualWidth())/SCREEN_WIDTH_F, ((yo)*GetActualHeight())/SCREEN_HEIGHT_F, 0, 0 + }; + + XMVECTORF32 origin = { + -x, y, 0, 0 + }; + + XMVECTORF32 color = { + quad->mColor[0].r/255.0f, quad->mColor[0].g/255.0f, quad->mColor[0].b/255.0f, quad->mColor[0].a/255.0f + }; + + RECT rect; + rect.bottom = quad->mY + height; + rect.top = quad->mY; + rect.left = quad->mX;; + rect.right = quad->mX + width; + + XMVECTOR scale = {xScale*GetActualWidth()/SCREEN_WIDTH_F, yScale*GetActualHeight()/SCREEN_HEIGHT_F}; + + m_spriteBatch->Draw( + quad->mTex->mTexId, + // position + position, + // sourceRectangle + &rect, + // color + color, + // rotation + angle, + // origin + origin, + //scale + scale ); } void JRenderer::RenderQuad(JQuad* quad, VertexColor* pt) -{ +{/* float width = quad->mWidth; float height = quad->mHeight; float x = -quad->mHotSpotX; float y = quad->mHotSpotY; - mspriteBatchInstance->Draw( - quad->mTex->mTexId, - float2( - ((pt[0].x)*GetActualWidth())/SCREEN_WIDTH_F, - ((pt[0].y)*GetActualHeight())/SCREEN_HEIGHT_F), - PositionUnits::Pixels, - float2( - (width*GetActualWidth())/SCREEN_WIDTH_F, - (height*GetActualHeight())/SCREEN_HEIGHT_F - ), - SizeUnits::Pixels, - float4( - quad->mColor[0].r/255.0f, - quad->mColor[0].g/255.0f, - quad->mColor[0].b/255.0f, - quad->mColor[0].a/255.0f), + FXMVECTOR position = { 0, 0 }; + + FXMVECTOR origin = { + -x, y, 0, 0 + }; + + FXMVECTOR color = { + pt[0].color, pt[1].color, pt[2].color, pt[3].color + }; + + RECT rect; + rect.bottom = quad->mY + height; + rect.top = quad->mY; + rect.left = quad->mX; + rect.right = quad->mX + width; + + XMVECTOR scale = {1*GetActualWidth()/SCREEN_WIDTH_F, 1*GetActualHeight()/SCREEN_HEIGHT_F}; + + m_spriteBatch->Draw( + quad->mTex->mTexId, + // position + position, + // sourceRectangle + &rect, + // color + color, + // rotation 0, - BlendMode::Alpha, - float4(quad->mTX0, quad->mTX1, quad->mTY0, quad->mTY1), - Vector4(pt[0].color, pt[1].color, pt[2].color, pt[3].color) - ); + // origin + origin, + //scale + scale + );*/ } void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE color) -{ +{/* + FXMVECTOR position = { + ((x)*GetActualWidth())/SCREEN_WIDTH_F, ((y)*GetActualHeight())/SCREEN_HEIGHT_F, 0, 0 + }; + FXMVECTOR origin = { + 0, 0, 0, 0 + }; + + JColor col; + col.color = color; + + FXMVECTOR colorVector = { + col.r/255.0f, col.g/255.0f, col.b/255.0f, col.a/255.0f + }; + + RECT rect; + rect.bottom = height; + rect.top = 0; + rect.left = 0; + rect.right = width; + + XMVECTOR scale = {GetActualWidth()/SCREEN_WIDTH_F, GetActualHeight()/SCREEN_HEIGHT_F}; + + m_spriteBatch->Draw( + NULL,//quad->mTex->mTexId, + // position + position, + // sourceRectangle + &rect, + // color + colorVector, + // rotation + 0, + // origin + origin, + //scale + scale + );*/ } @@ -1128,12 +1197,19 @@ void JRenderer::TransferTextureToGLContext(JTexture& inTexture) initData.SysMemSlicePitch = inTexture.mTexHeight*inTexture.mTexWidth*4; ID3D11Texture2D* tex2D = nullptr; - hr = m_d3dDevice->CreateTexture2D( &desc, &initData, &inTexture.mTexId); - if( S_OK != hr) + hr = m_d3dDevice->CreateTexture2D( &desc, &initData, &tex2D); + if( FAILED(hr) || tex2D == 0) return; - mspriteBatchInstance->AddTexture(inTexture.mTexId); - + D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; + memset( &SRVDesc, 0, sizeof( SRVDesc ) ); + SRVDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + SRVDesc.Texture2D.MipLevels = 1; + + hr = m_d3dDevice->CreateShaderResourceView( tex2D, &SRVDesc, &inTexture.mTexId ); + tex2D->Release(); + delete [] inTexture.mBuffer; inTexture.mBuffer = NULL; } diff --git a/JGE/src/DirectX/PlatformHelpers.h b/JGE/src/DirectX/PlatformHelpers.h new file mode 100644 index 000000000..8f3290e89 --- /dev/null +++ b/JGE/src/DirectX/PlatformHelpers.h @@ -0,0 +1,110 @@ +//-------------------------------------------------------------------------------------- +// File: PlatformHelpers.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#pragma warning(disable : 4324 4481) + +#include + + +namespace DirectX +{ + // Helper utility converts D3D API failures into exceptions. + inline void ThrowIfFailed(HRESULT hr) + { + if (FAILED(hr)) + { + throw std::exception(); + } + } + + + // Helper for output debug tracing + inline void DebugTrace( _In_z_ _Printf_format_string_ const char* format, ... ) + { +#ifdef _DEBUG + va_list args; + va_start( args, format ); + + char buff[1024]={0}; + vsprintf_s( buff, format, args ); + OutputDebugStringA( buff ); +#else + UNREFERENCED_PARAMETER( format ); +#endif + } + + + // Helper smart-pointers + struct handle_closer { void operator()(HANDLE h) { if (h) CloseHandle(h); } }; + + typedef public std::unique_ptr ScopedHandle; + + inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; } +} + + +#if (defined(_MSC_VER) && (_MSC_VER < 1610)) || defined(DIRECTX_EMULATE_MUTEX) + +// Emulate the C++0x mutex and lock_guard types when building with Visual Studio versions < 2012. +namespace std +{ + class mutex + { + public: + mutex() { InitializeCriticalSection(&mCriticalSection); } + ~mutex() { DeleteCriticalSection(&mCriticalSection); } + + void lock() { EnterCriticalSection(&mCriticalSection); } + void unlock() { LeaveCriticalSection(&mCriticalSection); } + bool try_lock() { return TryEnterCriticalSection(&mCriticalSection) != 0; } + + private: + CRITICAL_SECTION mCriticalSection; + + mutex(mutex const&); + mutex& operator= (mutex const&); + }; + + + template + class lock_guard + { + public: + typedef Mutex mutex_type; + + explicit lock_guard(mutex_type& mutex) + : mMutex(mutex) + { + mMutex.lock(); + } + + ~lock_guard() + { + mMutex.unlock(); + } + + private: + mutex_type& mMutex; + + lock_guard(lock_guard const&); + lock_guard& operator= (lock_guard const&); + }; +} + +#else // _MSC_VER < 1610 + +#include + +#endif diff --git a/JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpritePixelShader.inc b/JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpritePixelShader.inc new file mode 100644 index 000000000..fc3706533 --- /dev/null +++ b/JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpritePixelShader.inc @@ -0,0 +1,137 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1.xy + dcl_2d s0 + texld r0, t1, s0 + mul r0, r0, t0 + mov oC0, r0 + +// approximately 3 instruction slots used (1 texture, 2 arithmetic) +ps_4_0 +dcl_constantbuffer cb0[1], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +dcl_temps 1 +sample r0.xyzw, v1.xyxx, t0.xyzw, s0 +mul o0.xyzw, r0.xyzw, v0.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SpriteEffect_SpritePixelShader[] = +{ + 68, 88, 66, 67, 62, 231, + 156, 88, 145, 159, 172, 51, + 164, 207, 207, 254, 124, 230, + 155, 106, 1, 0, 0, 0, + 232, 1, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 184, 0, 0, 0, 100, 1, + 0, 0, 180, 1, 0, 0, + 65, 111, 110, 57, 128, 0, + 0, 0, 128, 0, 0, 0, + 0, 2, 255, 255, 88, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 0, 0, 40, 0, + 1, 0, 36, 0, 0, 0, + 40, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 164, 0, 0, 0, + 64, 0, 0, 0, 41, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 72, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 62, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc b/JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc new file mode 100644 index 000000000..10b5b8ce2 --- /dev/null +++ b/JGE/src/DirectX/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc @@ -0,0 +1,213 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + mul r0, v2.y, c2 + mad r0, v2.x, c1, r0 + mad r0, v2.z, c3, r0 + mad r0, v2.w, c4, r0 + mad oPos.xy, r0.w, c0, r0 + mov oPos.zw, r0 + mov oT0, v0 + mov oT1.xy, v1 + +// approximately 8 instruction slots used +vs_4_0 +dcl_constantbuffer cb0[4], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output_siv o2.xyzw, position +dcl_temps 1 +mov o0.xyzw, v0.xyzw +mov o1.xy, v1.xyxx +mul r0.xyzw, v2.yyyy, cb0[1].xyzw +mad r0.xyzw, v2.xxxx, cb0[0].xyzw, r0.xyzw +mad r0.xyzw, v2.zzzz, cb0[2].xyzw, r0.xyzw +mad o2.xyzw, v2.wwww, cb0[3].xyzw, r0.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SpriteEffect_SpriteVertexShader[] = +{ + 68, 88, 66, 67, 53, 15, + 108, 68, 10, 30, 79, 231, + 153, 9, 61, 10, 198, 154, + 8, 125, 1, 0, 0, 0, + 60, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 28, 1, 0, 0, 84, 2, + 0, 0, 200, 2, 0, 0, + 65, 111, 110, 57, 228, 0, + 0, 0, 228, 0, 0, 0, + 0, 2, 254, 255, 176, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 85, 144, 2, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 15, 128, 2, 0, + 0, 144, 1, 0, 228, 160, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 15, 128, + 2, 0, 170, 144, 3, 0, + 228, 160, 0, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 15, 128, 2, 0, 255, 144, + 4, 0, 228, 160, 0, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 255, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 12, 192, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 0, 0, 228, 144, 1, 0, + 0, 2, 1, 0, 3, 224, + 1, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 48, 1, 0, 0, 64, 0, + 1, 0, 76, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 1, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 0, 0, + 0, 0, 86, 21, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 166, 26, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 242, 32, + 16, 0, 2, 0, 0, 0, + 246, 31, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 95, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171, 79, 83, + 71, 78, 108, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 86, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 12, + 0, 0, 95, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/JGE/src/DirectX/SharedResourcePool.h b/JGE/src/DirectX/SharedResourcePool.h new file mode 100644 index 000000000..2722717af --- /dev/null +++ b/JGE/src/DirectX/SharedResourcePool.h @@ -0,0 +1,108 @@ +//-------------------------------------------------------------------------------------- +// File: SharedResourcePool.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include + +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Pool manager ensures that only a single TData instance is created for each unique TKey. + // This is used to avoid duplicate resource creation, so that for instance a caller can + // create any number of SpriteBatch instances, but these can internally share shaders and + // vertex buffer if more than one SpriteBatch uses the same underlying D3D device. + template + class SharedResourcePool + { + public: + SharedResourcePool() + : mResourceMap(std::make_shared()) + { } + + + // Allocates or looks up the shared TData instance for the specified key. + std::shared_ptr DemandCreate(TKey key) + { + std::lock_guard lock(mResourceMap->mutex); + + // Return an existing instance? + auto pos = mResourceMap->find(key); + + if (pos != mResourceMap->end()) + { + auto existingValue = pos->second.lock(); + + if (existingValue) + return existingValue; + else + mResourceMap->erase(pos); + } + + // Allocate a new instance. + auto newValue = std::make_shared(key, mResourceMap); + + mResourceMap->insert(std::make_pair(key, newValue)); + + return newValue; + } + + + private: + // Keep track of all allocated TData instances. + struct ResourceMap : public std::map> + { + std::mutex mutex; + }; + + std::shared_ptr mResourceMap; + + + // Wrap TData with our own subclass, so we can hook the destructor + // to remove instances from our pool before they are freed. + struct WrappedData : public TData + { + WrappedData(TKey key, std::shared_ptr const& resourceMap) + : mKey(key), + mResourceMap(resourceMap), + TData(key) + { } + + ~WrappedData() + { + std::lock_guard lock(mResourceMap->mutex); + + auto pos = mResourceMap->find(mKey); + + // Check for weak reference expiry before erasing, in case DemandCreate runs on + // a different thread at the same time as a previous instance is being destroyed. + // We mustn't erase replacement objects that have just been added! + if (pos != mResourceMap->end() && pos->second.expired()) + { + mResourceMap->erase(pos); + } + } + + TKey mKey; + std::shared_ptr mResourceMap; + }; + + + // Prevent copying. + SharedResourcePool(SharedResourcePool const&); + SharedResourcePool& operator= (SharedResourcePool const&); + }; +} diff --git a/JGE/src/DirectX/SpriteBatch.cpp b/JGE/src/DirectX/SpriteBatch.cpp new file mode 100644 index 000000000..f1aed1566 --- /dev/null +++ b/JGE/src/DirectX/SpriteBatch.cpp @@ -0,0 +1,1086 @@ +//-------------------------------------------------------------------------------------- +// File: SpriteBatch.cpp +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#if !defined(WIN32_LEAN_AND_MEAN) +#define WIN32_LEAN_AND_MEAN +#endif + +#if !defined(NOMINMAX) +#define NOMINMAX +#endif + +// Needed for limit defines, like INTMAX_MAX, which is used by the std C++ library +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif + +// VS 2010's stdint.h conflicts with intsafe.h +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + +#include +#include +using namespace Microsoft::WRL; + +#include +#include + +#include "SpriteBatch.h" +#include "ConstantBuffer.h" +#include "CommonStates.h" +#include "VertexTypes.h" +#include "SharedResourcePool.h" +#include "AlignedNew.h" + +using namespace DirectX; +using namespace Microsoft::WRL; + + +// Internal SpriteBatch implementation class. +__declspec(align(16)) class SpriteBatch::Impl : public AlignedNew +{ +public: + Impl(_In_ ID3D11DeviceContext* deviceContext); + + void XM_CALLCONV Begin(SpriteSortMode sortMode, _In_opt_ ID3D11BlendState* blendState, _In_opt_ ID3D11SamplerState* samplerState, _In_opt_ ID3D11DepthStencilState* depthStencilState, _In_opt_ ID3D11RasterizerState* rasterizerState, _In_opt_ std::function setCustomShaders, FXMMATRIX transformMatrix); + void End(); + + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR destination, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, FXMVECTOR originRotationDepth, int flags); + + + // Info about a single sprite that is waiting to be drawn. + __declspec(align(16)) struct SpriteInfo : public AlignedNew + { + XMFLOAT4A source; + XMFLOAT4A destination; + XMFLOAT4A color; + XMFLOAT4A originRotationDepth; + ID3D11ShaderResourceView* texture; + int flags; + + + // Combine values from the public SpriteEffects enum with these internal-only flags. + static const int SourceInTexels = 4; + static const int DestSizeInPixels = 8; + + static_assert((SpriteEffects_FlipBoth & (SourceInTexels | DestSizeInPixels)) == 0, "Flag bits must not overlap"); + }; + + DXGI_MODE_ROTATION mRotation; + + bool mSetViewport; + D3D11_VIEWPORT mViewPort; + +private: + // Implementation helper methods. + void GrowSpriteQueue(); + void PrepareForRendering(); + void FlushBatch(); + void SortSprites(); + void GrowSortedSprites(); + + void RenderBatch(_In_ ID3D11ShaderResourceView* texture, _In_reads_(count) SpriteInfo const* const* sprites, size_t count); + + static void XM_CALLCONV RenderSprite(_In_ SpriteInfo const* sprite, _Out_cap_c_(VerticesPerSprite) VertexPositionColorTexture* vertices, FXMVECTOR textureSize, FXMVECTOR inverseTextureSize); + + static XMVECTOR GetTextureSize(_In_ ID3D11ShaderResourceView* texture); + XMMATRIX GetViewportTransform(_In_ ID3D11DeviceContext* deviceContext, DXGI_MODE_ROTATION rotation ); + + + // Constants. + static const size_t MaxBatchSize = 2048; + static const size_t MinBatchSize = 128; + static const size_t InitialQueueSize = 64; + static const size_t VerticesPerSprite = 4; + static const size_t IndicesPerSprite = 6; + + + // Queue of sprites waiting to be drawn. + std::unique_ptr mSpriteQueue; + + size_t mSpriteQueueCount; + size_t mSpriteQueueArraySize; + + + // To avoid needlessly copying around bulky SpriteInfo structures, we leave that + // actual data alone and just sort this array of pointers instead. But we want contiguous + // memory for cache efficiency, so these pointers are just shortcuts into the single + // mSpriteQueue array, and we take care to keep them in order when sorting is disabled. + std::vector mSortedSprites; + + + // If each SpriteInfo instance held a refcount on its texture, could end up with + // many redundant AddRef/Release calls on the same object, so instead we use + // this separate list to hold just a single refcount each time we change texture. + std::vector> mSpriteTextureReferences; + + + // Mode settings from the last Begin call. + bool mInBeginEndPair; + + SpriteSortMode mSortMode; + ComPtr mBlendState; + ComPtr mSamplerState; + ComPtr mDepthStencilState; + ComPtr mRasterizerState; + std::function mSetCustomShaders; + XMMATRIX mTransformMatrix; + + + // Only one of these helpers is allocated per D3D device, even if there are multiple SpriteBatch instances. + struct DeviceResources + { + DeviceResources(_In_ ID3D11Device* device); + + ComPtr vertexShader; + ComPtr pixelShader; + ComPtr inputLayout; + ComPtr indexBuffer; + + CommonStates stateObjects; + + private: + void CreateShaders(_In_ ID3D11Device* device); + void CreateIndexBuffer(_In_ ID3D11Device* device); + + static std::vector CreateIndexValues(); + }; + + + // Only one of these helpers is allocated per D3D device context, even if there are multiple SpriteBatch instances. + struct ContextResources + { + ContextResources(_In_ ID3D11DeviceContext* deviceContext); + + ComPtr deviceContext; + ComPtr vertexBuffer; + + ConstantBuffer constantBuffer; + + size_t vertexBufferPosition; + + bool inImmediateMode; + + private: + void CreateVertexBuffer(); + }; + + + // Per-device and per-context data. + std::shared_ptr mDeviceResources; + std::shared_ptr mContextResources; + + static SharedResourcePool deviceResourcesPool; + static SharedResourcePool contextResourcesPool; +}; + + +// Global pools of per-device and per-context SpriteBatch resources. +SharedResourcePool SpriteBatch::Impl::deviceResourcesPool; +SharedResourcePool SpriteBatch::Impl::contextResourcesPool; + + +// Constants. +const XMMATRIX SpriteBatch::MatrixIdentity = XMMatrixIdentity(); +const XMFLOAT2 SpriteBatch::Float2Zero(0, 0); + + +namespace +{ + // Include the precompiled shader code. +#if defined(_XBOX_ONE) && defined(_TITLE) + #include "Shaders/Compiled/XboxOneSpriteEffect_SpriteVertexShader.inc" + #include "Shaders/Compiled/XboxOneSpriteEffect_SpritePixelShader.inc" +#else + #include "Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc" + #include "Shaders/Compiled/SpriteEffect_SpritePixelShader.inc" +#endif + + + // Helper looks up the D3D device corresponding to a context interface. + inline ComPtr GetDevice(_In_ ID3D11DeviceContext* deviceContext) + { + ComPtr device; + + deviceContext->GetDevice(&device); + + return device; + } + + + // Helper converts a RECT to XMVECTOR. + inline XMVECTOR LoadRect(_In_ RECT const* rect) + { + XMVECTOR v = XMLoadInt4(reinterpret_cast(rect)); + + v = XMConvertVectorIntToFloat(v, 0); + + // Convert right/bottom to width/height. + v -= XMVectorPermute<0, 1, 4, 5>(XMVectorZero(), v); + + return v; + } +} + + +// Per-device constructor. +SpriteBatch::Impl::DeviceResources::DeviceResources(_In_ ID3D11Device* device) + : stateObjects(device) +{ + CreateShaders(device); + CreateIndexBuffer(device); +} + + +// Creates the SpriteBatch shaders and input layout. +void SpriteBatch::Impl::DeviceResources::CreateShaders(_In_ ID3D11Device* device) +{ + ThrowIfFailed( + device->CreateVertexShader(SpriteEffect_SpriteVertexShader, + sizeof(SpriteEffect_SpriteVertexShader), + nullptr, + &vertexShader) + ); + + ThrowIfFailed( + device->CreatePixelShader(SpriteEffect_SpritePixelShader, + sizeof(SpriteEffect_SpritePixelShader), + nullptr, + &pixelShader) + ); + + ThrowIfFailed( + device->CreateInputLayout(VertexPositionColorTexture::InputElements, + VertexPositionColorTexture::InputElementCount, + SpriteEffect_SpriteVertexShader, + sizeof(SpriteEffect_SpriteVertexShader), + &inputLayout) + ); + + SetDebugObjectName(vertexShader.Get(), "DirectXTK:SpriteBatch"); + SetDebugObjectName(pixelShader.Get(), "DirectXTK:SpriteBatch"); + SetDebugObjectName(inputLayout.Get(), "DirectXTK:SpriteBatch"); +} + + +// Creates the SpriteBatch index buffer. +void SpriteBatch::Impl::DeviceResources::CreateIndexBuffer(_In_ ID3D11Device* device) +{ + D3D11_BUFFER_DESC indexBufferDesc = { 0 }; + + static_assert( ( MaxBatchSize * VerticesPerSprite ) < USHRT_MAX, "MaxBatchSize too large for 16-bit indices" ); + + indexBufferDesc.ByteWidth = sizeof(short) * MaxBatchSize * IndicesPerSprite; + indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; + indexBufferDesc.Usage = D3D11_USAGE_DEFAULT; + + auto indexValues = CreateIndexValues(); + + D3D11_SUBRESOURCE_DATA indexDataDesc = { 0 }; + + indexDataDesc.pSysMem = &indexValues.front(); + + ThrowIfFailed( + device->CreateBuffer(&indexBufferDesc, &indexDataDesc, &indexBuffer) + ); + + SetDebugObjectName(indexBuffer.Get(), "DirectXTK:SpriteBatch"); +} + + +// Helper for populating the SpriteBatch index buffer. +std::vector SpriteBatch::Impl::DeviceResources::CreateIndexValues() +{ + std::vector indices; + + indices.reserve(MaxBatchSize * IndicesPerSprite); + + for (short i = 0; i < MaxBatchSize * VerticesPerSprite; i += VerticesPerSprite) + { + indices.push_back(i); + indices.push_back(i + 1); + indices.push_back(i + 2); + + indices.push_back(i + 1); + indices.push_back(i + 3); + indices.push_back(i + 2); + } + + return indices; +} + + +// Per-context constructor. +SpriteBatch::Impl::ContextResources::ContextResources(_In_ ID3D11DeviceContext* deviceContext) + : deviceContext(deviceContext), + constantBuffer(GetDevice(deviceContext).Get()), + vertexBufferPosition(0), + inImmediateMode(false) +{ + CreateVertexBuffer(); +} + + +// Creates the SpriteBatch vertex buffer. +void SpriteBatch::Impl::ContextResources::CreateVertexBuffer() +{ + D3D11_BUFFER_DESC vertexBufferDesc = { 0 }; + + vertexBufferDesc.ByteWidth = sizeof(VertexPositionColorTexture) * MaxBatchSize * VerticesPerSprite; + vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; + vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + ThrowIfFailed( + GetDevice(deviceContext.Get())->CreateBuffer(&vertexBufferDesc, nullptr, &vertexBuffer) + ); + + SetDebugObjectName(vertexBuffer.Get(), "DirectXTK:SpriteBatch"); +} + + +// Per-SpriteBatch constructor. +SpriteBatch::Impl::Impl(_In_ ID3D11DeviceContext* deviceContext) + : mRotation( DXGI_MODE_ROTATION_IDENTITY ), + mSetViewport(false), + mSpriteQueueCount(0), + mSpriteQueueArraySize(0), + mInBeginEndPair(false), + mSortMode(SpriteSortMode_Deferred), + mTransformMatrix(MatrixIdentity), + mDeviceResources(deviceResourcesPool.DemandCreate(GetDevice(deviceContext).Get())), + mContextResources(contextResourcesPool.DemandCreate(deviceContext)) +{ +} + + +// Begins a batch of sprite drawing operations. +void XM_CALLCONV SpriteBatch::Impl::Begin(SpriteSortMode sortMode, _In_opt_ ID3D11BlendState* blendState, _In_opt_ ID3D11SamplerState* samplerState, _In_opt_ ID3D11DepthStencilState* depthStencilState, _In_opt_ ID3D11RasterizerState* rasterizerState, _In_opt_ std::function setCustomShaders, FXMMATRIX transformMatrix) +{ + if (mInBeginEndPair) + throw std::exception("Cannot nest Begin calls on a single SpriteBatch"); + + mSortMode = sortMode; + mBlendState = blendState; + mSamplerState = samplerState; + mDepthStencilState = depthStencilState; + mRasterizerState = rasterizerState; + mSetCustomShaders = setCustomShaders; + mTransformMatrix = transformMatrix; + + if (sortMode == SpriteSortMode_Immediate) + { + // If we are in immediate mode, set device state ready for drawing. + if (mContextResources->inImmediateMode) + throw std::exception("Only one SpriteBatch at a time can use SpriteSortMode_Immediate"); + + PrepareForRendering(); + + mContextResources->inImmediateMode = true; + } + + mInBeginEndPair = true; +} + + +// Ends a batch of sprite drawing operations. +void SpriteBatch::Impl::End() +{ + if (!mInBeginEndPair) + throw std::exception("Begin must be called before End"); + + if (mSortMode == SpriteSortMode_Immediate) + { + // If we are in immediate mode, sprites have already been drawn. + mContextResources->inImmediateMode = false; + } + else + { + // Draw the queued sprites now. + if (mContextResources->inImmediateMode) + throw std::exception("Cannot end one SpriteBatch while another is using SpriteSortMode_Immediate"); + + PrepareForRendering(); + FlushBatch(); + } + + // Break circular reference chains, in case the state lambda closed + // over an object that holds a reference to this SpriteBatch. + mSetCustomShaders = nullptr; + + mInBeginEndPair = false; +} + + +// Adds a single sprite to the queue. +void XM_CALLCONV SpriteBatch::Impl::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR destination, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, FXMVECTOR originRotationDepth, int flags) +{ + if (!texture) + throw std::exception("Texture cannot be null"); + + if (!mInBeginEndPair) + throw std::exception("Begin must be called before Draw"); + + // Get a pointer to the output sprite. + if (mSpriteQueueCount >= mSpriteQueueArraySize) + { + GrowSpriteQueue(); + } + + SpriteInfo* sprite = &mSpriteQueue[mSpriteQueueCount]; + + XMVECTOR dest = destination; + + if (sourceRectangle) + { + // User specified an explicit source region. + XMVECTOR source = LoadRect(sourceRectangle); + + XMStoreFloat4A(&sprite->source, source); + + // If the destination size is relative to the source region, convert it to pixels. + if (!(flags & SpriteInfo::DestSizeInPixels)) + { + dest = XMVectorPermute<0, 1, 6, 7>(dest, dest * source); // dest.zw *= source.zw + } + + flags |= SpriteInfo::SourceInTexels | SpriteInfo::DestSizeInPixels; + } + else + { + // No explicit source region, so use the entire texture. + static const XMVECTORF32 wholeTexture = { 0, 0, 1, 1 }; + + XMStoreFloat4A(&sprite->source, wholeTexture); + } + + // Store sprite parameters. + XMStoreFloat4A(&sprite->destination, dest); + XMStoreFloat4A(&sprite->color, color); + XMStoreFloat4A(&sprite->originRotationDepth, originRotationDepth); + + sprite->texture = texture; + sprite->flags = flags; + + if (mSortMode == SpriteSortMode_Immediate) + { + // If we are in immediate mode, draw this sprite straight away. + RenderBatch(texture, &sprite, 1); + } + else + { + // Queue this sprite for later sorting and batched rendering. + mSpriteQueueCount++; + + // Make sure we hold a refcount on this texture until the sprite has been drawn. Only checking the + // back of the vector means we will add duplicate references if the caller switches back and forth + // between multiple repeated textures, but calling AddRef more times than strictly necessary hurts + // nothing, and is faster than scanning the whole list or using a map to detect all duplicates. + if (mSpriteTextureReferences.empty() || texture != mSpriteTextureReferences.back().Get()) + { + mSpriteTextureReferences.emplace_back(texture); + } + } +} + + +// Dynamically expands the array used to store pending sprite information. +void SpriteBatch::Impl::GrowSpriteQueue() +{ + // Grow by a factor of 2. + size_t newSize = std::max(InitialQueueSize, mSpriteQueueArraySize * 2); + + // Allocate the new array. + std::unique_ptr newArray(new SpriteInfo[newSize]); + + // Copy over any existing sprites. + for (size_t i = 0; i < mSpriteQueueCount; i++) + { + newArray[i] = mSpriteQueue[i]; + } + + // Replace the previous array with the new one. + mSpriteQueue = std::move(newArray); + mSpriteQueueArraySize = newSize; + + // Clear any dangling SpriteInfo pointers left over from previous rendering. + mSortedSprites.clear(); +} + + +// Sets up D3D device state ready for drawing sprites. +void SpriteBatch::Impl::PrepareForRendering() +{ + auto deviceContext = mContextResources->deviceContext.Get(); + + // Set state objects. + auto blendState = mBlendState ? mBlendState.Get() : mDeviceResources->stateObjects.AlphaBlend(); + auto depthStencilState = mDepthStencilState ? mDepthStencilState.Get() : mDeviceResources->stateObjects.DepthNone(); + auto rasterizerState = mRasterizerState ? mRasterizerState.Get() : mDeviceResources->stateObjects.CullCounterClockwise(); + auto samplerState = mSamplerState ? mSamplerState.Get() : mDeviceResources->stateObjects.LinearClamp(); + + deviceContext->OMSetBlendState(blendState, nullptr, 0xFFFFFFFF); + deviceContext->OMSetDepthStencilState(depthStencilState, 0); + deviceContext->RSSetState(rasterizerState); + deviceContext->PSSetSamplers(0, 1, &samplerState); + + // Set shaders. + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + deviceContext->IASetInputLayout(mDeviceResources->inputLayout.Get()); + deviceContext->VSSetShader(mDeviceResources->vertexShader.Get(), nullptr, 0); + deviceContext->PSSetShader(mDeviceResources->pixelShader.Get(), nullptr, 0); + + // Set the vertex and index buffer. + auto vertexBuffer = mContextResources->vertexBuffer.Get(); + UINT vertexStride = sizeof(VertexPositionColorTexture); + UINT vertexOffset = 0; + + deviceContext->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset); + + deviceContext->IASetIndexBuffer(mDeviceResources->indexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0); + + // Set the transform matrix. + XMMATRIX transformMatrix = (mRotation == DXGI_MODE_ROTATION_UNSPECIFIED) + ? mTransformMatrix + : ( mTransformMatrix * GetViewportTransform(deviceContext, mRotation) ); + + mContextResources->constantBuffer.SetData(deviceContext, transformMatrix); + + ID3D11Buffer* constantBuffer = mContextResources->constantBuffer.GetBuffer(); + + deviceContext->VSSetConstantBuffers(0, 1, &constantBuffer); + + // If this is a deferred D3D context, reset position so the first Map call will use D3D11_MAP_WRITE_DISCARD. + if (deviceContext->GetType() == D3D11_DEVICE_CONTEXT_DEFERRED) + { + mContextResources->vertexBufferPosition = 0; + } + + // Hook lets the caller replace our settings with their own custom shaders. + if (mSetCustomShaders) + { + mSetCustomShaders(); + } +} + + +// Sends queued sprites to the graphics device. +void SpriteBatch::Impl::FlushBatch() +{ + if (!mSpriteQueueCount) + return; + + SortSprites(); + + // Walk through the sorted sprite list, looking for adjacent entries that share a texture. + ID3D11ShaderResourceView* batchTexture = nullptr; + size_t batchStart = 0; + + for (size_t pos = 0; pos < mSpriteQueueCount; pos++) + { + ID3D11ShaderResourceView* texture = mSortedSprites[pos]->texture; + + _Analysis_assume_(texture != nullptr); + + // Flush whenever the texture changes. + if (texture != batchTexture) + { + if (pos > batchStart) + { + RenderBatch(batchTexture, &mSortedSprites[batchStart], pos - batchStart); + } + + batchTexture = texture; + batchStart = pos; + } + } + + // Flush the final batch. + RenderBatch(batchTexture, &mSortedSprites[batchStart], mSpriteQueueCount - batchStart); + + // Reset the queue. + mSpriteQueueCount = 0; + mSpriteTextureReferences.clear(); + + // When sorting is disabled, we persist mSortedSprites data from one batch to the next, to avoid + // uneccessary work in GrowSortedSprites. But we never reuse these when sorting, because re-sorting + // previously sorted items gives unstable ordering if some sprites have identical sort keys. + if (mSortMode != SpriteSortMode_Deferred) + { + mSortedSprites.clear(); + } +} + + +// Sorts the array of queued sprites. +void SpriteBatch::Impl::SortSprites() +{ + // Fill the mSortedSprites vector. + if (mSortedSprites.size() < mSpriteQueueCount) + { + GrowSortedSprites(); + } + + switch (mSortMode) + { + case SpriteSortMode_Texture: + // Sort by texture. + std::sort(mSortedSprites.begin(), mSortedSprites.begin() + mSpriteQueueCount, [](SpriteInfo const* x, SpriteInfo const* y) -> bool + { + return x->texture < y->texture; + }); + break; + + case SpriteSortMode_BackToFront: + // Sort back to front. + std::sort(mSortedSprites.begin(), mSortedSprites.begin() + mSpriteQueueCount, [](SpriteInfo const* x, SpriteInfo const* y) -> bool + { + return x->originRotationDepth.w > y->originRotationDepth.w; + }); + break; + + case SpriteSortMode_FrontToBack: + // Sort front to back. + std::sort(mSortedSprites.begin(), mSortedSprites.begin() + mSpriteQueueCount, [](SpriteInfo const* x, SpriteInfo const* y) -> bool + { + return x->originRotationDepth.w < y->originRotationDepth.w; + }); + break; + } +} + + +// Populates the mSortedSprites vector with pointers to individual elements of the mSpriteQueue array. +void SpriteBatch::Impl::GrowSortedSprites() +{ + size_t previousSize = mSortedSprites.size(); + + mSortedSprites.resize(mSpriteQueueCount); + + for (size_t i = previousSize; i < mSpriteQueueCount; i++) + { + mSortedSprites[i] = &mSpriteQueue[i]; + } +} + + +// Submits a batch of sprites to the GPU. +void SpriteBatch::Impl::RenderBatch(_In_ ID3D11ShaderResourceView* texture, _In_reads_(count) SpriteInfo const* const* sprites, size_t count) +{ + auto deviceContext = mContextResources->deviceContext.Get(); + + // Draw using the specified texture. + deviceContext->PSSetShaderResources(0, 1, &texture); + + XMVECTOR textureSize = GetTextureSize(texture); + XMVECTOR inverseTextureSize = XMVectorReciprocal(textureSize); + + while (count > 0) + { + // How many sprites do we want to draw? + size_t batchSize = count; + + // How many sprites does the D3D vertex buffer have room for? + size_t remainingSpace = MaxBatchSize - mContextResources->vertexBufferPosition; + + if (batchSize > remainingSpace) + { + if (remainingSpace < MinBatchSize) + { + // If we are out of room, or about to submit an excessively small batch, wrap back to the start of the vertex buffer. + mContextResources->vertexBufferPosition = 0; + + batchSize = std::min(count, MaxBatchSize); + } + else + { + // Take however many sprites fit in what's left of the vertex buffer. + batchSize = remainingSpace; + } + } + + // Lock the vertex buffer. + D3D11_MAP mapType = (mContextResources->vertexBufferPosition == 0) ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE; + + D3D11_MAPPED_SUBRESOURCE mappedBuffer; + + ThrowIfFailed( + deviceContext->Map(mContextResources->vertexBuffer.Get(), 0, mapType, 0, &mappedBuffer) + ); + + VertexPositionColorTexture* vertices = (VertexPositionColorTexture*)mappedBuffer.pData + mContextResources->vertexBufferPosition * VerticesPerSprite; + + // Generate sprite vertex data. + for (size_t i = 0; i < batchSize; i++) + { + assert(i < count); + _Analysis_assume_(i < count); + RenderSprite(sprites[i], vertices, textureSize, inverseTextureSize); + + vertices += VerticesPerSprite; + } + + deviceContext->Unmap(mContextResources->vertexBuffer.Get(), 0); + + // Ok lads, the time has come for us draw ourselves some sprites! + UINT startIndex = (UINT)mContextResources->vertexBufferPosition * IndicesPerSprite; + UINT indexCount = (UINT)batchSize * IndicesPerSprite; + + deviceContext->DrawIndexed(indexCount, startIndex, 0); + + // Advance the buffer position. + mContextResources->vertexBufferPosition += batchSize; + + sprites += batchSize; + count -= batchSize; + } +} + + +// Generates vertex data for drawing a single sprite. +void XM_CALLCONV SpriteBatch::Impl::RenderSprite(_In_ SpriteInfo const* sprite, _Out_cap_c_(VerticesPerSprite) VertexPositionColorTexture* vertices, FXMVECTOR textureSize, FXMVECTOR inverseTextureSize) +{ + // Load sprite parameters into SIMD registers. + XMVECTOR source = XMLoadFloat4A(&sprite->source); + XMVECTOR destination = XMLoadFloat4A(&sprite->destination); + XMVECTOR color = XMLoadFloat4A(&sprite->color); + XMVECTOR originRotationDepth = XMLoadFloat4A(&sprite->originRotationDepth); + + float rotation = sprite->originRotationDepth.z; + int flags = sprite->flags; + + // Extract the source and destination sizes into separate vectors. + XMVECTOR sourceSize = XMVectorSwizzle<2, 3, 2, 3>(source); + XMVECTOR destinationSize = XMVectorSwizzle<2, 3, 2, 3>(destination); + + // Scale the origin offset by source size, taking care to avoid overflow if the source region is zero. + XMVECTOR isZeroMask = XMVectorEqual(sourceSize, XMVectorZero()); + XMVECTOR nonZeroSourceSize = XMVectorSelect(sourceSize, g_XMEpsilon, isZeroMask); + + XMVECTOR origin = XMVectorDivide(originRotationDepth, nonZeroSourceSize); + + // Convert the source region from texels to mod-1 texture coordinate format. + if (flags & SpriteInfo::SourceInTexels) + { + source *= inverseTextureSize; + sourceSize *= inverseTextureSize; + } + else + { + origin *= inverseTextureSize; + } + + // If the destination size is relative to the source region, convert it to pixels. + if (!(flags & SpriteInfo::DestSizeInPixels)) + { + destinationSize *= textureSize; + } + + // Compute a 2x2 rotation matrix. + XMVECTOR rotationMatrix1; + XMVECTOR rotationMatrix2; + + if (rotation != 0) + { + float sin, cos; + + XMScalarSinCos(&sin, &cos, rotation); + + XMVECTOR sinV = XMLoadFloat(&sin); + XMVECTOR cosV = XMLoadFloat(&cos); + + rotationMatrix1 = XMVectorMergeXY(cosV, sinV); + rotationMatrix2 = XMVectorMergeXY(-sinV, cosV); + } + else + { + rotationMatrix1 = g_XMIdentityR0; + rotationMatrix2 = g_XMIdentityR1; + } + + // The four corner vertices are computed by transforming these unit-square positions. + static XMVECTORF32 cornerOffsets[VerticesPerSprite] = + { + { 0, 0 }, + { 1, 0 }, + { 0, 1 }, + { 1, 1 }, + }; + + // Tricksy alert! Texture coordinates are computed from the same cornerOffsets + // table as vertex positions, but if the sprite is mirrored, this table + // must be indexed in a different order. This is done as follows: + // + // position = cornerOffsets[i] + // texcoord = cornerOffsets[i ^ SpriteEffects] + + static_assert(SpriteEffects_FlipHorizontally == 1 && + SpriteEffects_FlipVertically == 2, "If you change these enum values, the mirroring implementation must be updated to match"); + + int mirrorBits = flags & 3; + + // Generate the four output vertices. + for (int i = 0; i < VerticesPerSprite; i++) + { + // Calculate position. + XMVECTOR cornerOffset = (cornerOffsets[i] - origin) * destinationSize; + + // Apply 2x2 rotation matrix. + XMVECTOR position1 = XMVectorMultiplyAdd(XMVectorSplatX(cornerOffset), rotationMatrix1, destination); + XMVECTOR position2 = XMVectorMultiplyAdd(XMVectorSplatY(cornerOffset), rotationMatrix2, position1); + + // Set z = depth. + XMVECTOR position = XMVectorPermute<0, 1, 7, 6>(position2, originRotationDepth); + + // Write position as a Float4, even though VertexPositionColor::position is an XMFLOAT3. + // This is faster, and harmless as we are just clobbering the first element of the + // following color field, which will immediately be overwritten with its correct value. + XMStoreFloat4(reinterpret_cast(&vertices[i].position), position); + + // Write the color. + XMStoreFloat4(&vertices[i].color, color); + + // Compute and write the texture coordinate. + XMVECTOR textureCoordinate = XMVectorMultiplyAdd(cornerOffsets[i ^ mirrorBits], sourceSize, source); + + XMStoreFloat2(&vertices[i].textureCoordinate, textureCoordinate); + } +} + + +// Helper looks up the size of the specified texture. +XMVECTOR SpriteBatch::Impl::GetTextureSize(_In_ ID3D11ShaderResourceView* texture) +{ + // Convert resource view to underlying resource. + ComPtr resource; + + texture->GetResource(&resource); + + // Cast to texture. + ComPtr texture2D; + + if (FAILED(resource.As(&texture2D))) + { + throw std::exception("SpriteBatch can only draw Texture2D resources"); + } + + // Query the texture size. + D3D11_TEXTURE2D_DESC desc; + + texture2D->GetDesc(&desc); + + // Convert to vector format. + XMVECTOR size = XMVectorMergeXY(XMLoadInt(&desc.Width), + XMLoadInt(&desc.Height)); + + return XMConvertVectorUIntToFloat(size, 0); +} + + +// Generates a viewport transform matrix for rendering sprites using x-right y-down screen pixel coordinates. +XMMATRIX SpriteBatch::Impl::GetViewportTransform(_In_ ID3D11DeviceContext* deviceContext, DXGI_MODE_ROTATION rotation ) +{ + // Look up the current viewport. + if ( !mSetViewport ) + { + UINT viewportCount = 1; + + deviceContext->RSGetViewports(&viewportCount, &mViewPort); + + if (viewportCount != 1) + throw std::exception("No viewport is set"); + } + + // Compute the matrix. + float xScale = (mViewPort.Width > 0) ? 2.0f / mViewPort.Width : 0.0f; + float yScale = (mViewPort.Height > 0) ? 2.0f / mViewPort.Height : 0.0f; + + switch( rotation ) + { + case DXGI_MODE_ROTATION_ROTATE90: + return XMMATRIX + ( + 0, -yScale, 0, 0, + -xScale, 0, 0, 0, + 0, 0, 1, 0, + 1, 1, 0, 1 + ); + + case DXGI_MODE_ROTATION_ROTATE270: + return XMMATRIX + ( + 0, yScale, 0, 0, + xScale, 0, 0, 0, + 0, 0, 1, 0, + -1, -1, 0, 1 + ); + + case DXGI_MODE_ROTATION_ROTATE180: + return XMMATRIX + ( + -xScale, 0, 0, 0, + 0, yScale, 0, 0, + 0, 0, 1, 0, + 1, -1, 0, 1 + ); + + default: + return XMMATRIX + ( + xScale, 0, 0, 0, + 0, -yScale, 0, 0, + 0, 0, 1, 0, + -1, 1, 0, 1 + ); + } +} + + +// Public constructor. +SpriteBatch::SpriteBatch(_In_ ID3D11DeviceContext* deviceContext) + : pImpl(new Impl(deviceContext)) +{ +} + + +// Move constructor. +SpriteBatch::SpriteBatch(SpriteBatch&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +SpriteBatch& SpriteBatch::operator= (SpriteBatch&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +SpriteBatch::~SpriteBatch() +{ +} + + +void XM_CALLCONV SpriteBatch::Begin(SpriteSortMode sortMode, _In_opt_ ID3D11BlendState* blendState, _In_opt_ ID3D11SamplerState* samplerState, _In_opt_ ID3D11DepthStencilState* depthStencilState, _In_opt_ ID3D11RasterizerState* rasterizerState, _In_opt_ std::function setCustomShaders, FXMMATRIX transformMatrix) +{ + pImpl->Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, setCustomShaders, transformMatrix); +} + + +void SpriteBatch::End() +{ + pImpl->End(); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, FXMVECTOR color) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(XMLoadFloat2(&position), g_XMOne); // x, y, 1, 1 + + pImpl->Draw(texture, destination, nullptr, color, g_XMZero, 0); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, float scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 4>(XMLoadFloat2(&position), XMLoadFloat(&scale)); // x, y, scale, scale + + XMVECTOR originRotationDepth = XMVectorSet(origin.x, origin.y, rotation, layerDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(XMLoadFloat2(&position), XMLoadFloat2(&scale)); // x, y, scale.x, scale.y + + XMVECTOR originRotationDepth = XMVectorSet(origin.x, origin.y, rotation, layerDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, FXMVECTOR color) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(position, g_XMOne); // x, y, 1, 1 + + pImpl->Draw(texture, destination, nullptr, color, g_XMZero, 0); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, FXMVECTOR origin, float scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 4>(position, XMLoadFloat(&scale)); // x, y, scale, scale + + XMVECTOR rotationDepth = XMVectorMergeXY(XMVectorReplicate(rotation), XMVectorReplicate(layerDepth)); + + XMVECTOR originRotationDepth = XMVectorPermute<0, 1, 4, 5>(origin, rotationDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(position, scale); // x, y, scale.x, scale.y + + XMVECTOR rotationDepth = XMVectorMergeXY(XMVectorReplicate(rotation), XMVectorReplicate(layerDepth)); + + XMVECTOR originRotationDepth = XMVectorPermute<0, 1, 4, 5>(origin, rotationDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, FXMVECTOR color) +{ + XMVECTOR destination = LoadRect(&destinationRectangle); // x, y, w, h + + pImpl->Draw(texture, destination, nullptr, color, g_XMZero, Impl::SpriteInfo::DestSizeInPixels); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = LoadRect(&destinationRectangle); // x, y, w, h + + XMVECTOR originRotationDepth = XMVectorSet(origin.x, origin.y, rotation, layerDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects | Impl::SpriteInfo::DestSizeInPixels); +} + + +void SpriteBatch::SetRotation( DXGI_MODE_ROTATION mode ) +{ + pImpl->mRotation = mode; +} + + +DXGI_MODE_ROTATION SpriteBatch::GetRotation() const +{ + return pImpl->mRotation; +} + + +void SpriteBatch::SetViewport( const D3D11_VIEWPORT& viewPort ) +{ + pImpl->mSetViewport = true; + pImpl->mViewPort = viewPort; +} diff --git a/JGE/src/DirectX/SpriteBatch.h b/JGE/src/DirectX/SpriteBatch.h new file mode 100644 index 000000000..8a3831e07 --- /dev/null +++ b/JGE/src/DirectX/SpriteBatch.h @@ -0,0 +1,110 @@ +//-------------------------------------------------------------------------------------- +// File: SpriteBatch.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include +#include +#include +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + enum SpriteSortMode + { + SpriteSortMode_Deferred, + SpriteSortMode_Immediate, + SpriteSortMode_Texture, + SpriteSortMode_BackToFront, + SpriteSortMode_FrontToBack, + }; + + + enum SpriteEffects + { + SpriteEffects_None = 0, + SpriteEffects_FlipHorizontally = 1, + SpriteEffects_FlipVertically = 2, + SpriteEffects_FlipBoth = SpriteEffects_FlipHorizontally | SpriteEffects_FlipVertically, + }; + + + class SpriteBatch + { + public: + explicit SpriteBatch(_In_ ID3D11DeviceContext* deviceContext); + SpriteBatch(SpriteBatch&& moveFrom); + SpriteBatch& operator= (SpriteBatch&& moveFrom); + virtual ~SpriteBatch(); + + // Begin/End a batch of sprite drawing operations. + void XM_CALLCONV Begin(SpriteSortMode sortMode = SpriteSortMode_Deferred, _In_opt_ ID3D11BlendState* blendState = nullptr, _In_opt_ ID3D11SamplerState* samplerState = nullptr, _In_opt_ ID3D11DepthStencilState* depthStencilState = nullptr, _In_opt_ ID3D11RasterizerState* rasterizerState = nullptr, + _In_opt_ std::function setCustomShaders = nullptr, FXMMATRIX transformMatrix = MatrixIdentity); + void __cdecl End(); + + // Draw overloads specifying position, origin and scale as XMFLOAT2. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Draw overloads specifying position, origin and scale via the first two components of an XMVECTOR. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, FXMVECTOR origin = g_XMZero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Draw overloads specifying position as a RECT. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Rotation mode to be applied to the sprite transformation + void __cdecl SetRotation( DXGI_MODE_ROTATION mode ); + DXGI_MODE_ROTATION __cdecl GetRotation() const; + + // Set viewport for sprite transformation + void __cdecl SetViewport( const D3D11_VIEWPORT& viewPort ); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + static const XMMATRIX MatrixIdentity; + static const XMFLOAT2 Float2Zero; + + // Prevent copying. + SpriteBatch(SpriteBatch const&); + SpriteBatch& operator= (SpriteBatch const&); + }; +} diff --git a/JGE/src/DirectX/VertexTypes.cpp b/JGE/src/DirectX/VertexTypes.cpp new file mode 100644 index 000000000..964b66309 --- /dev/null +++ b/JGE/src/DirectX/VertexTypes.cpp @@ -0,0 +1,166 @@ +//-------------------------------------------------------------------------------------- +// File: VertexTypes.cpp +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +//#include "pch.h" +#if !defined(WIN32_LEAN_AND_MEAN) +#define WIN32_LEAN_AND_MEAN +#endif + +#if !defined(NOMINMAX) +#define NOMINMAX +#endif + +#include +#include +using namespace Microsoft::WRL; +#include "VertexTypes.h" + +#include + +using namespace DirectX; +using namespace DirectX::PackedVector; + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position and color information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionColor::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionColor) == 28, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionTexture) == 20, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position and normal vector. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormal::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormal) == 24, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, color, and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionColorTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionColorTexture) == 36, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, normal vector, and color information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColor::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalColor) == 40, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, normal vector, and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalTexture) == 32, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, normal vector, color, and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColorTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalColorTexture) == 48, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, +// tangent, color (RGBA), and texture mapping information +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTangentColorTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TANGENT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalTangentColorTexture) == 52, "Vertex struct/layout mismatch" ); + +void XM_CALLCONV VertexPositionNormalTangentColorTexture::SetColor( FXMVECTOR icolor ) +{ + XMUBYTEN4 rgba; + XMStoreUByteN4( &rgba, icolor ); + this->color = rgba.v; +} + + +//-------------------------------------------------------------------------------------- +// Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, +// tangent, color (RGBA), texture mapping information, and skinning weights +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTangentColorTextureSkinning::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TANGENT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BLENDINDICES",0, DXGI_FORMAT_R8G8B8A8_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BLENDWEIGHT", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( VertexPositionNormalTangentColorTextureSkinning::InputElementCount == VertexPositionNormalTangentColorTexture::InputElementCount + 2, "layout mismatch"); + +static_assert( sizeof(VertexPositionNormalTangentColorTextureSkinning) == 60, "Vertex struct/layout mismatch" ); + +void VertexPositionNormalTangentColorTextureSkinning::SetBlendIndices( XMUINT4 const& iindices ) +{ + this->indices = ( (iindices.w & 0xff) << 24 ) | ( (iindices.z & 0xff) << 16 ) | ( (iindices.y & 0xff) << 8 ) | ( iindices.x & 0xff ); +} + +void XM_CALLCONV VertexPositionNormalTangentColorTextureSkinning::SetBlendWeights( FXMVECTOR iweights ) +{ + XMUBYTEN4 packed; + XMStoreUByteN4( &packed, iweights ); + this->weights = packed.v; +} diff --git a/JGE/src/DirectX/VertexTypes.h b/JGE/src/DirectX/VertexTypes.h new file mode 100644 index 000000000..59eb66efe --- /dev/null +++ b/JGE/src/DirectX/VertexTypes.h @@ -0,0 +1,331 @@ +//-------------------------------------------------------------------------------------- +// File: VertexTypes.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include + + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + // Vertex struct holding position and color information. + struct VertexPositionColor + { + VertexPositionColor() + { } + + VertexPositionColor(XMFLOAT3 const& position, XMFLOAT4 const& color) + : position(position), + color(color) + { } + + VertexPositionColor(FXMVECTOR position, FXMVECTOR color) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat4(&this->color, color); + } + + XMFLOAT3 position; + XMFLOAT4 color; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position and texture mapping information. + struct VertexPositionTexture + { + VertexPositionTexture() + { } + + VertexPositionTexture(XMFLOAT3 const& position, XMFLOAT2 const& textureCoordinate) + : position(position), + textureCoordinate(textureCoordinate) + { } + + VertexPositionTexture(FXMVECTOR position, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position and normal vector. + struct VertexPositionNormal + { + VertexPositionNormal() + { } + + VertexPositionNormal(XMFLOAT3 const& position, XMFLOAT3 const& normal) + : position(position), + normal(normal) + { } + + VertexPositionNormal(FXMVECTOR position, FXMVECTOR normal) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, color, and texture mapping information. + struct VertexPositionColorTexture + { + VertexPositionColorTexture() + { } + + VertexPositionColorTexture(XMFLOAT3 const& position, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + color(color), + textureCoordinate(textureCoordinate) + { } + + VertexPositionColorTexture(FXMVECTOR position, FXMVECTOR color, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat4(&this->color, color); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT4 color; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, and color information. + struct VertexPositionNormalColor + { + VertexPositionNormalColor() + { } + + VertexPositionNormalColor(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color) + : position(position), + normal(normal), + color(color) + { } + + VertexPositionNormalColor(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR color) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->color, color); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 color; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, and texture mapping information. + struct VertexPositionNormalTexture + { + VertexPositionNormalTexture() + { } + + VertexPositionNormalTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + textureCoordinate(textureCoordinate) + { } + + VertexPositionNormalTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, color, and texture mapping information. + struct VertexPositionNormalColorTexture + { + VertexPositionNormalColorTexture() + { } + + VertexPositionNormalColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + color(color), + textureCoordinate(textureCoordinate) + { } + + VertexPositionNormalColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR color, CXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->color, color); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 color; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 4; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, + // tangent, color (RGBA), and texture mapping information + struct VertexPositionNormalTangentColorTexture + { + VertexPositionNormalTangentColorTexture() + { } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 tangent; + uint32_t color; + XMFLOAT2 textureCoordinate; + + VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, uint32_t rgba, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + tangent(tangent), + color(rgba), + textureCoordinate(textureCoordinate) + { + } + + VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, uint32_t rgba, CXMVECTOR textureCoordinate) + : color(rgba) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->tangent, tangent); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + tangent(tangent), + textureCoordinate(textureCoordinate) + { + SetColor( color ); + } + + VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, CXMVECTOR color, CXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->tangent, tangent); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + + SetColor( color ); + } + + void __cdecl SetColor( XMFLOAT4 const& icolor ) { SetColor( XMLoadFloat4( &icolor ) ); } + void XM_CALLCONV SetColor( FXMVECTOR icolor ); + + static const int InputElementCount = 5; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, + // tangent, color (RGBA), texture mapping information, and skinning weights + struct VertexPositionNormalTangentColorTextureSkinning : public VertexPositionNormalTangentColorTexture + { + VertexPositionNormalTangentColorTextureSkinning() + { } + + uint32_t indices; + uint32_t weights; + + VertexPositionNormalTangentColorTextureSkinning(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, uint32_t rgba, + XMFLOAT2 const& textureCoordinate, XMUINT4 const& indices, XMFLOAT4 const& weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,rgba,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + VertexPositionNormalTangentColorTextureSkinning(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, uint32_t rgba, CXMVECTOR textureCoordinate, + XMUINT4 const& indices, CXMVECTOR weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,rgba,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + VertexPositionNormalTangentColorTextureSkinning(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, XMFLOAT4 const& color, + XMFLOAT2 const& textureCoordinate, XMUINT4 const& indices, XMFLOAT4 const& weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,color,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + VertexPositionNormalTangentColorTextureSkinning(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, CXMVECTOR color, CXMVECTOR textureCoordinate, + XMUINT4 const& indices, CXMVECTOR weights) + : VertexPositionNormalTangentColorTexture(position,normal,tangent,color,textureCoordinate) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + void __cdecl SetBlendIndices( XMUINT4 const& iindices ); + + void __cdecl SetBlendWeights( XMFLOAT4 const& iweights ) { SetBlendWeights( XMLoadFloat4( &iweights ) ); } + void XM_CALLCONV SetBlendWeights( FXMVECTOR iweights ); + + static const int InputElementCount = 7; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; +} diff --git a/JGE/src/JFileSystem.cpp b/JGE/src/JFileSystem.cpp index eee1612d5..c853c5072 100644 --- a/JGE/src/JFileSystem.cpp +++ b/JGE/src/JFileSystem.cpp @@ -32,7 +32,6 @@ The content that users should not be touching. #include "../include/JGE.h" #include "../include/JFileSystem.h" #include "../include/JLogger.h" -#include #ifdef QT_CONFIG #include @@ -139,9 +138,11 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath) DebugTrace("Current path " << QDir::currentPath().toStdString()); #elif defined (WP8) char buff[500]; +// auto appInstallDirectory = Windows::Storage::KnownFolders::DocumentsLibrary::get()->Path; auto appInstallDirectory = Windows::ApplicationModel::Package::Current->InstalledLocation->Path; WideCharToMultiByte(CP_ACP, 0, appInstallDirectory->Data(), -1, buff, appInstallDirectory->Length()+1, NULL, NULL); systemPath = buff; + systemPath += "\\Assets\\"; auto localfolder = Windows::Storage::ApplicationData::Current->LocalFolder->Path; WideCharToMultiByte(CP_ACP, 0, localfolder->Data(), -1, buff, localfolder->Length()+1, NULL, NULL); @@ -257,7 +258,7 @@ void JFileSystem::clearZipCache() bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL */) { - if (mZipAvailable && mZipFile != NULL) + if (mZipAvailable && mZipFile.is_open()) { if (mZipFileName != zipfile) DetachZipFile(); // close the previous zip file diff --git a/JGE/src/WRLmain.cpp b/JGE/src/WRLmain.cpp index d0c47f0c2..811ee2698 100644 --- a/JGE/src/WRLmain.cpp +++ b/JGE/src/WRLmain.cpp @@ -149,8 +149,6 @@ void WagicApp::Initialize(CoreApplicationView^ applicationView) void WagicApp::SetWindow(CoreWindow^ window) { m_window = window; - window->SizeChanged += - ref new TypedEventHandler(this, &WagicApp::OnWindowSizeChanged); window->VisibilityChanged += ref new TypedEventHandler(this, &WagicApp::OnVisibilityChanged); @@ -158,8 +156,6 @@ void WagicApp::SetWindow(CoreWindow^ window) window->Closed += ref new TypedEventHandler(this, &WagicApp::OnWindowClosed); - window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); - window->PointerPressed += ref new TypedEventHandler(this, &WagicApp::OnPointerPressed); @@ -175,8 +171,50 @@ void WagicApp::SetWindow(CoreWindow^ window) window->PointerWheelChanged += ref new TypedEventHandler(this, &WagicApp::OnPointerWheelChanged); +#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); + + window->SizeChanged += + ref new TypedEventHandler(this, &WagicApp::OnWindowSizeChanged); +#endif + static const float dipsPerInch = 96.0f; m_Wagic.initApp(); - m_Wagic.onWindowResize((void*)window, window->Bounds.Width, window->Bounds.Height); + m_Wagic.onWindowResize( + (void*)window, + floor(window->Bounds.Width * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f), + floor(window->Bounds.Height * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f)); + + /* + window->VisibilityChanged += + ref new TypedEventHandler(this, &App::OnVisibilityChanged); + + window->Closed += + ref new TypedEventHandler(this, &App::OnWindowClosed); + + DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); + + DisplayInformation::DisplayContentsInvalidated += + ref new TypedEventHandler(this, &App::OnDisplayContentsInvalidated); + +#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + window->SizeChanged += + ref new TypedEventHandler(this, &App::OnWindowSizeChanged); + + currentDisplayInformation->DpiChanged += + ref new TypedEventHandler(this, &App::OnDpiChanged); + + currentDisplayInformation->OrientationChanged += + ref new TypedEventHandler(this, &App::OnOrientationChanged); + + // Désactivez tout retour visuel du pointeur pour de meilleures performances tactiles. + // Ceci n'est pas pris en charge sur les applications Windows Phone. + auto pointerVisualizationSettings = PointerVisualizationSettings::GetForCurrentView(); + pointerVisualizationSettings->IsContactFeedbackEnabled = false; + pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false; +#endif + + m_deviceResources->SetWindow(window); + */ } void WagicApp::Load(Platform::String^ entryPoint) diff --git a/JGE/src/zipFS/fileio.h b/JGE/src/zipFS/fileio.h index dc3302fa2..7f6ad3c9f 100644 --- a/JGE/src/zipFS/fileio.h +++ b/JGE/src/zipFS/fileio.h @@ -51,9 +51,7 @@ #include #endif -#include #include - #include namespace io_facilities { diff --git a/projects/mtg/WRL/Assets/Logo.png b/projects/mtg/WRL/Assets/Logo.png new file mode 100644 index 0000000000000000000000000000000000000000..e26771cb33a49bbef824aa333737181b0a5b09a3 GIT binary patch literal 801 zcmeAS@N?(olHy`uVBq!ia0vp^(?FPm4M^HB7Cr(}k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m=1foIEGZ*dUJQLud<^=L*gE#63Ho!PGzwUb%GPK6&5iF zt!p@aGNX}6(PVh|N)M-?0RNcTbjaWgEU8noxUax-n>&3Ay)#!y&O11y2sKEF zt72@XC1)RvT6Xw=y_`Ce)`nGULLL^lI$kwi^E+dQT7YeXY4GvlRR%kj1x$VZi%Bdd zz}2Giy=-_$h+v#(S+};)DuE4EM?_^qB_eDeo@&q%StD1F>L|*0ZC2sb-}llSMTM?O z6{b3iid~yk@VE7q7Wb+P8?H5IYp?pSVcLE~18m#ygK20HL@6W5woI~Fjlw$fX1U{xQA5a+t0 zH$WNIb=fNpWHo}M9#;K6eszDZKty_|-?j4iocj5#zotrWc;@;w`H@=mjsvS2wXX0_ zY}l$4@^sE?UcC)ji*L=Z&}P!xaL&2((OQlj2dv~pV-ifAS;ZsH1{`D!GY%yys5WH)f>ZLo5m%6XjuXdbKMR7MEHSyb{m!_{Afji&MT$_sz7 z>1{~MlIFe28FRN(GC_~;#Jp4ADipP+9hh|P#-&`vO-Upt3jE0@YLh(^55uYWl9g)Z RA3>Rb!PC{xWt~$(69A&hN*MqE literal 0 HcmV?d00001 diff --git a/projects/mtg/WRL/Assets/Logo.scale-240.png b/projects/mtg/WRL/Assets/Logo.scale-240.png new file mode 100644 index 0000000000000000000000000000000000000000..76921ca99715449322ce4575b714262598766ebb GIT binary patch literal 2516 zcma)8e^gWF8NRs*$>m340*H_V3IrWmSyAF81<^|bF*@;AU9F(UpdhglLIe?&VlKge zU_jhiMWK52AY*G$dK!Ut0zrXVoS4COL|`OH(K@8MLKRTv-jB1tclJk;@BQBAdEWQl z-1oWPsV$q<@!iC37>4oJtK+s|7)y&j1Q&LWjV1pbe*CiIKhFM8zd!p(@}X2LHbuWT zHE_KyIW2WtYI4d^!}qDHG0Zh*eO&DJ+<|99Bf6x!3r}u6yRg~&Gfhs&jz?$zRuEMY z#jH22)s>t(^7zpG^EWUVbBytMBybxq$`Bh@~p2>_?jf$QK;M7hr&Pm zkP9GuG*nCP#>0AzitGA4O^^ue8Ncvgl|7hWJULlE9-yt@cFcU!rSn9K_Z4VAE0c*A z3!gaW!R@rq0jk=>MhZM0T!BF#K(bQl{~%~yD%Js(epuz@53v0i33(t{d1HkV?g8yL zxN;*3>z68BAUvPAau*7(1}V8HJFp@h!n)zpm!T*%_L0XsAn_;iN*vnlH?M?-m_)A) zh`J#xbP-C*nG{HNd~<8!9N(%oDa!LFuL3!+N9H&-1D8=eSr@q`9zk|8F(J-cmjP3O zVn^H9Q@Alsv&#URow0+7kr!umR(&1?w;D;VASjIMnk9QpHO7hm; z#v()QT)a7kCcQJWa9uc{6Bs^ksFHHGvgkoitrCwMtK|$ZwlG&~vY$_L5KV?>M&n_2 zGdDxU@C8F|xGvYJ;tXJXVbci784$K75OS_-Ml8ek8Zv?mT`=Kpy)0fvmQ#}D{ohji zn){nApl;H+TPexPe)zJ+?z>A^lTCbgIk#*g*lre(@7jG=H-7R3uA4TOTimQvG}e$n zcLiyFM_5f5bS~wR#ZQY#~d-wR3Bs)@X|Lj2CCl&pEx7+Bp2J)oHO0} zOsJLmkUxCR8K9G+8)bHdJe^DDWC{dHBCRxlETBfQulTf&wx~EE(5_IYv*?^kK_54r zVhl{~agMmCByy3K&S}U!2i?`(@Fd+QRPprzu(Q?@fz)2>GqCv^bDvd8Kj06#?>;M<|u= zg9J&W^fZ?JD}V+2`$o-&Hs`4b+@j{0H&=_aaZ%w$AnZF$2YCY@H-!R}W8MlW!lOnZ zvkQGU04pfG5>QHwqSKEy+l(a5)Hn9v0lRH(_V}iz6MT<&=8sauWC^v?<1f>?pP$>a_NOHdOA(0oA(9tdod>DsL8s?I zLI8CMP0CO}fwNGM5p|U^<(D1=f@eP+3ntcc_GtrO&TB3zi_lvot08Zzdyx z?ZsJNWg?bl=DbKttLol7Bjos)#7N0Dwz`0r`&oSfC5vn2<9z%FNsyf=*Ppyc$O}fR zV9js!$1S#LGyL7b%Uc)Y7G}DZuu`&+)-c>+bV_7)qDT)t_)b42Z%I1D^hOO!@RS* zKwGiv<|=$bu0kMu=C!2Z~n`jMSO_Lcl3INRSPL;fr2fR8$X1K~*ec(Ds)h zk=tf8vWM@I zyeY)aP2J)I&pcz(fj3En%`0e9YO8m(wi~Owv`W^{MM^?6w~vN6z$4j1S11X`xx{5a zh}@ZlWkA!bi>Ed=MIB~3{f54zj%#fbZdM+*;@Y9xeJ+XBu{B`$ct#?4e{pu_;KgA3 zBah%Pdw?Kw91rWEeyMs-qBU?U0_I-+hKtbe%9&lDRM%UujrK`nwt01P607M?bfF@E zEhG0%Q>77GZY)&tV7L38F9~wn_1~QVtj28iSOlQ`2fp8e!rEF7FBBfUD@0*eR|n$k zOoG=U>}G6AhccBhy%mt8YS`?s9;2EEEwCyC9##b#>;zz7A5fq;TLW0(QybI{?4|z? z!c00961 literal 0 HcmV?d00001 diff --git a/projects/mtg/WRL/Assets/SmallLogo.scale-100.png b/projects/mtg/WRL/Assets/SmallLogo.scale-100.png new file mode 100644 index 0000000000000000000000000000000000000000..a3c1ff4fb03ce812a2316ad971d2aefc3539ea1f GIT binary patch literal 6819 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 RNJRhu002ovPDHLkV1gr$Y(4-0 literal 0 HcmV?d00001 diff --git a/projects/mtg/WRL/Assets/SmallLogo.scale-240.png b/projects/mtg/WRL/Assets/SmallLogo.scale-240.png new file mode 100644 index 0000000000000000000000000000000000000000..316630124fd17743032a79102625b0b525005e74 GIT binary patch literal 753 zcmVJ-E9w)W3i)0Su7y!3rf(|qyfmM&R849dgq+L*8)gkSM0;>k;5ENMXNQa@o z%0)T_1y&x?X(+IAkh(yDm6K5yD6rzQ=>`Q>Y$jcyz>3SFI}}(k8H7Mx9V?>mVNh4a zit2MH)YY&e`x*{)6|Cq!ra+C3mC?5}s8O-9`jiSa8dhds(xFDd%I-r6lsi^M+smL_ zv8vi!3gw1X+17F>7p&?wNjDG%!~6iB&PhoC^p$Jz}AQVrHFD3I!~ zHba3_i?s;~qg@n*v@1|s#GQ665=9@Rxy?u0YW0&WN+~=RXpPbVXXL4m7Aq=E6I0%{06TwRn=U9d8>exk> zD-Z%M3DNQ`bTLSEF=%NFyoHcAkD*CiXqljo*0E?o$GiDC4q}}|%*0WghLlK#npw?hecrM}Mw?`E(z5C8< z8&*b^!{>5?4aT89vdrgBgSc-x6JZD3F^l#*G(@OO*^1D%Eu7?HAy<3kTLqW9N{^#6vso zVQwY48q7)m{~xQ64RV7{E7Y=&T~?^05Ky`5oNQ8bLgFCPq9co^R09BVRS1OAmH;hU zC#q(N!gNqm!zU#%sv{r5mm-Uv8b-~a1F-;p^>)pnXfKge4s9?;;MFIr*fixPG}NBA z6_G5BEmeO6XXh(emkciB{7tA;iwC2^s^VzyU_h0@ae84ACMY`cIDEju=<`q|2QAEv zW_)W|i|9aknqdmS=#w73eW_csQ$8IhT^vY1^1;X3&J0{%*tcQq!gJpr3w?TJc~@5= zKV5sM{$3k>b#S$@CTkhIF*{v*u(F&$&Yq1naHxt8Mz2N%7aQ3(^VNRZahk1||7?Bl z*idzO_u)FhRj4cPzDO>YA>>lxAGaciEiX8Xzp1SVPv91};$OG3cC&8!v3{Jq^kH@8 UTIccK;hzT5*3#}uZuEx!0OwrBv;Y7A literal 0 HcmV?d00001 diff --git a/projects/mtg/WRL/Assets/SplashScreen.scale-240.png b/projects/mtg/WRL/Assets/SplashScreen.scale-240.png new file mode 100644 index 0000000000000000000000000000000000000000..33f26b33107b5958dc2a068cee9da4ab92047640 GIT binary patch literal 14715 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 aeE1)epL)B$w-u`Z0000SK>Qt}(H-q=T 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 gV5~u<%>&ppbSls(D;2H23k0DxD+50(=0|+ + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + 248F659F-DAC5-46E8-AC09-60EC9FC95053 + true + 8d01c384-882c-4ac8-a178-e4c946e5a542 + {1c587904-01ba-482e-806e-0617aea0b059} + Wagic + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + true + NotUsing + + + true + NotUsing + + + NotUsing + + + + + + + + Document + true + + + \ No newline at end of file diff --git a/projects/mtg/WRL/Wagic.Shared.vcxitems.filters b/projects/mtg/WRL/Wagic.Shared.vcxitems.filters new file mode 100644 index 000000000..eccc418c5 --- /dev/null +++ b/projects/mtg/WRL/Wagic.Shared.vcxitems.filters @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/projects/mtg/WRL/Wagic.WindowsDesktop.Package.appxmanifest b/projects/mtg/WRL/Wagic.WindowsDesktop.Package.appxmanifest new file mode 100644 index 000000000..043b1f618 --- /dev/null +++ b/projects/mtg/WRL/Wagic.WindowsDesktop.Package.appxmanifest @@ -0,0 +1,35 @@ + + + + + Wagic + xawot_000 + Assets\StoreLogo.png + + + 6.3 + 6.3 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/mtg/WRL/Wagic.WindowsDesktop.vcxproj b/projects/mtg/WRL/Wagic.WindowsDesktop.vcxproj new file mode 100644 index 000000000..b1214cbb6 --- /dev/null +++ b/projects/mtg/WRL/Wagic.WindowsDesktop.vcxproj @@ -0,0 +1,176 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + + {45306c0e-e90b-4e84-a32f-504ed7b5c299} + Wagic + en-US + 12.0 + true + app + Windows Store + 8.1 + + + + Application + true + v120 + + + Application + true + v120 + + + Application + true + v120 + + + Application + false + true + v120 + + + Application + false + true + v120 + + + Application + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + Wagic_TemporaryKey.pfx + + + $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\$(ProjectName) + + + $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\$(ProjectName) + + + $(Platform)\$(Configuration)\$(ProjectName) + + + $(Platform)\$(Configuration)\$(ProjectName) + + + $(Platform)\$(Configuration)\$(ProjectName) + + + $(Platform)\$(Configuration)\$(ProjectName) + + + + d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;JGE.lib;zlib.lib;libpng.lib;libjpeg.lib;wagic.lib;%(AdditionalDependencies) + + + pch.h + $(IntDir)pch.pch + ../include;../../../JGE/include;../../../JGE/Dependencies/zlib;../../../JGE/src/zipFS;../../../JGE/Dependencies/include;$(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + 4453 + + + + + NDEBUG;%(PreprocessorDefinitions);WP8 + + + $(SolutionDir)$(Configuration)\;$(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\JGE;$(SolutionDir)$(Platform)\$(Configuration)\zlib;$(SolutionDir)$(Platform)\$(Configuration)\libjpeg;$(SolutionDir)$(Platform)\$(Configuration)\libpng;$(SolutionDir)$(Platform)\$(Configuration)\wagic;%(AdditionalLibraryDirectories) + + + $(SolutionDir)$(Configuration)\;$(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\JGE;$(SolutionDir)$(Platform)\$(Configuration)\zlib;$(SolutionDir)$(Platform)\$(Configuration)\libjpeg;$(SolutionDir)$(Platform)\$(Configuration)\libpng;$(SolutionDir)$(Platform)\$(Configuration)\wagic;%(AdditionalLibraryDirectories) + + + $(SolutionDir)$(Configuration)\;$(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\JGE;$(SolutionDir)$(Platform)\$(Configuration)\zlib;$(SolutionDir)$(Platform)\$(Configuration)\libjpeg;$(SolutionDir)$(Platform)\$(Configuration)\libpng;$(SolutionDir)$(Platform)\$(Configuration)\wagic;%(AdditionalLibraryDirectories) + + + + + PSAPI_VERSION=2;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WP8;%(PreprocessorDefinitions) + + + $(SolutionDir)$(Configuration)\;$(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\JGE;$(SolutionDir)$(Platform)\$(Configuration)\zlib;$(SolutionDir)$(Platform)\$(Configuration)\libjpeg;$(SolutionDir)$(Platform)\$(Configuration)\libpng;$(SolutionDir)$(Platform)\$(Configuration)\wagic;%(AdditionalLibraryDirectories) + + + $(SolutionDir)$(Configuration)\;$(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\JGE;$(SolutionDir)$(Platform)\$(Configuration)\zlib;$(SolutionDir)$(Platform)\$(Configuration)\libjpeg;$(SolutionDir)$(Platform)\$(Configuration)\libpng;$(SolutionDir)$(Platform)\$(Configuration)\wagic;%(AdditionalLibraryDirectories) + + + $(SolutionDir)$(Configuration)\;$(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)$(Platform)\$(Configuration)\JGE;$(SolutionDir)$(Platform)\$(Configuration)\zlib;$(SolutionDir)$(Platform)\$(Configuration)\libjpeg;$(SolutionDir)$(Platform)\$(Configuration)\libpng;$(SolutionDir)$(Platform)\$(Configuration)\wagic;%(AdditionalLibraryDirectories) + + + + + + + true + + + + + + + Designer + + + + + + + \ No newline at end of file diff --git a/projects/mtg/WRL/Wagic.WindowsPhone.Package.appxmanifest b/projects/mtg/WRL/Wagic.WindowsPhone.Package.appxmanifest new file mode 100644 index 000000000..6542ed0d7 --- /dev/null +++ b/projects/mtg/WRL/Wagic.WindowsPhone.Package.appxmanifest @@ -0,0 +1,43 @@ + + + + + + app.WindowsPhone + wagic + Assets\StoreLogo.png + + + 6.3.1 + 6.3.1 + + + + + + + + + + + + + + + + + + Wagic Resources + + .zip + + + + + + + + + + + \ No newline at end of file diff --git a/projects/mtg/WRL/Wagic.WindowsPhone.vcxproj b/projects/mtg/WRL/Wagic.WindowsPhone.vcxproj new file mode 100644 index 000000000..78d117dd9 --- /dev/null +++ b/projects/mtg/WRL/Wagic.WindowsPhone.vcxproj @@ -0,0 +1,138 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + + {b1a69919-8795-4071-ad05-883294596217} + Wagic + en + 12.0 + true + Windows Phone + 8.1 + + + + Application + true + v120_wp81 + + + Application + true + v120_wp81 + + + Application + false + true + v120_wp81 + + + Application + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + + + + + + %(AdditionalLibraryDirectories);$(WindowsPhoneSDK_LibraryPath_x86) + WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;DXGI.lib;D3D11.lib;D2D1.lib;DWrite.lib;%(AdditionalDependencies) + false + + + + + %(AdditionalLibraryDirectories);$(WindowsPhoneSDK_LibraryPath_x86) + WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;DXGI.lib;D3D11.lib;D2D1.lib;DWrite.lib;%(AdditionalDependencies) + false + + + + + %(AdditionalLibraryDirectories);$(WindowsPhoneSDK_LibraryPath_arm);$(SolutionDir)$(Platform)\$(Configuration)\JGE;$(SolutionDir)$(Platform)\$(Configuration)\zlib;$(SolutionDir)$(Platform)\$(Configuration)\libjpeg;$(SolutionDir)$(Platform)\$(Configuration)\libpng;$(SolutionDir)$(Platform)\$(Configuration)\wagic + JGE.lib;zlib.lib;libpng.lib;libjpeg.lib;wagic.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;DXGI.lib;D3D11.lib;D2D1.lib;DWrite.lib;%(AdditionalDependencies) + false + + + %(AdditionalIncludeDirectories);$(IntermediateOutputPath);../../../JGE/include;../../../JGE/Dependencies/zlib;../../../JGE/src/zipFS;../include;../../../JGE/Dependencies/include + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WP8;%(PreprocessorDefinitions) + + + + + %(AdditionalLibraryDirectories);$(WindowsPhoneSDK_LibraryPath_arm) + WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;DXGI.lib;D3D11.lib;D2D1.lib;DWrite.lib;%(AdditionalDependencies) + false + + + + + $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\$(ProjectName) + + + $(Platform)\$(Configuration)\$(ProjectName) + + + $(Platform)\$(Configuration)\$(ProjectName) + + + $(Platform)\$(Configuration)\$(ProjectName) + $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + + + + + + + + + + Designer + + + + + + + + + \ No newline at end of file diff --git a/projects/mtg/WRL/Wagic.WindowsPhone.vcxproj.filters b/projects/mtg/WRL/Wagic.WindowsPhone.vcxproj.filters new file mode 100644 index 000000000..fee9198e3 --- /dev/null +++ b/projects/mtg/WRL/Wagic.WindowsPhone.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + 20a460d3-908d-4e24-9f44-f887aea6fda6 + + + c9191f0f-4b13-4395-81a7-d9bbf2fcf5cd + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png;zip + + + b1a69919-8795-4071-ad05-883294596217 + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + + + + \ No newline at end of file diff --git a/projects/mtg/WRL/Wagic.sln b/projects/mtg/WRL/Wagic.sln new file mode 100644 index 000000000..0b5127e1e --- /dev/null +++ b/projects/mtg/WRL/Wagic.sln @@ -0,0 +1,195 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "app", "Wagic.WindowsDesktop.vcxproj", "{45306C0E-E90B-4E84-A32F-504ED7B5C299}" + ProjectSection(ProjectDependencies) = postProject + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6} = {1DE5241B-2F18-4662-A196-F5C2A26CE5D6} + {89159C26-2282-404A-A194-103B0A49DF7B} = {89159C26-2282-404A-A194-103B0A49DF7B} + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470} = {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470} + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3} = {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3} + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC} = {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JGE - win8", "..\..\..\JGE\JGE - win8.vcxproj", "{89159C26-2282-404A-A194-103B0A49DF7B}" + ProjectSection(ProjectDependencies) = postProject + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6} = {1DE5241B-2F18-4662-A196-F5C2A26CE5D6} + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470} = {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470} + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3} = {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wagic", "wagic.vcxproj", "{C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}" + ProjectSection(ProjectDependencies) = postProject + {89159C26-2282-404A-A194-103B0A49DF7B} = {89159C26-2282-404A-A194-103B0A49DF7B} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\JGE\Dependencies\zlib\zlib.vcxproj", "{6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpeg", "..\..\..\JGE\Dependencies\libjpeg\libjpeg.vcxproj", "{1DE5241B-2F18-4662-A196-F5C2A26CE5D6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "..\..\..\JGE\Dependencies\libpng\libpng.vcxproj", "{6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wagic App", "Wagic App", "{8314F48C-574C-483F-AA48-55A29510CC00}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wagic.Shared", "Wagic.Shared.vcxitems", "{1C587904-01BA-482E-806E-0617AEA0B059}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wagic.WindowsPhone", "Wagic.WindowsPhone.vcxproj", "{B1A69919-8795-4071-AD05-883294596217}" + ProjectSection(ProjectDependencies) = postProject + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6} = {1DE5241B-2F18-4662-A196-F5C2A26CE5D6} + {89159C26-2282-404A-A194-103B0A49DF7B} = {89159C26-2282-404A-A194-103B0A49DF7B} + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470} = {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470} + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3} = {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3} + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC} = {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC} + EndProjectSection +EndProject +Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + Wagic.Shared.vcxitems*{b1a69919-8795-4071-ad05-883294596217}*SharedItemsImports = 4 + Wagic.Shared.vcxitems*{45306c0e-e90b-4e84-a32f-504ed7b5c299}*SharedItemsImports = 4 + Wagic.Shared.vcxitems*{1c587904-01ba-482e-806e-0617aea0b059}*SharedItemsImports = 9 + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Profile|ARM = Profile|ARM + Profile|Win32 = Profile|Win32 + Profile|x64 = Profile|x64 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Debug|ARM.ActiveCfg = Debug|ARM + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Debug|Win32.ActiveCfg = Debug|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Debug|Win32.Build.0 = Debug|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Debug|Win32.Deploy.0 = Debug|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Debug|x64.ActiveCfg = Debug|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Debug|x64.Build.0 = Debug|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Debug|x64.Deploy.0 = Debug|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|ARM.ActiveCfg = Release|ARM + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|ARM.Build.0 = Release|ARM + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|ARM.Deploy.0 = Release|ARM + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|Win32.ActiveCfg = Release|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|Win32.Build.0 = Release|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|Win32.Deploy.0 = Release|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|x64.ActiveCfg = Release|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|x64.Build.0 = Release|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Profile|x64.Deploy.0 = Release|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|ARM.ActiveCfg = Release|ARM + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|ARM.Build.0 = Release|ARM + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|ARM.Deploy.0 = Release|ARM + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|Win32.ActiveCfg = Release|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|Win32.Build.0 = Release|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|Win32.Deploy.0 = Release|Win32 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|x64.ActiveCfg = Release|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|x64.Build.0 = Release|x64 + {45306C0E-E90B-4E84-A32F-504ED7B5C299}.Release|x64.Deploy.0 = Release|x64 + {89159C26-2282-404A-A194-103B0A49DF7B}.Debug|ARM.ActiveCfg = Debug|ARM + {89159C26-2282-404A-A194-103B0A49DF7B}.Debug|ARM.Build.0 = Debug|ARM + {89159C26-2282-404A-A194-103B0A49DF7B}.Debug|Win32.ActiveCfg = Debug|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Debug|Win32.Build.0 = Debug|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Debug|x64.ActiveCfg = Debug|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Profile|ARM.ActiveCfg = Profile|ARM + {89159C26-2282-404A-A194-103B0A49DF7B}.Profile|ARM.Build.0 = Profile|ARM + {89159C26-2282-404A-A194-103B0A49DF7B}.Profile|Win32.ActiveCfg = Profile|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Profile|Win32.Build.0 = Profile|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Profile|x64.ActiveCfg = Profile|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Release|ARM.ActiveCfg = Release|ARM + {89159C26-2282-404A-A194-103B0A49DF7B}.Release|ARM.Build.0 = Release|ARM + {89159C26-2282-404A-A194-103B0A49DF7B}.Release|Win32.ActiveCfg = Release|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Release|Win32.Build.0 = Release|Win32 + {89159C26-2282-404A-A194-103B0A49DF7B}.Release|x64.ActiveCfg = Release|Win32 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Debug|ARM.ActiveCfg = Debug|ARM + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Debug|ARM.Build.0 = Debug|ARM + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Debug|Win32.ActiveCfg = Debug|Win32 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Debug|Win32.Build.0 = Debug|Win32 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Debug|x64.ActiveCfg = Debug|x64 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Debug|x64.Build.0 = Debug|x64 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Profile|ARM.ActiveCfg = Release|ARM + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Profile|ARM.Build.0 = Release|ARM + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Profile|Win32.ActiveCfg = Release|Win32 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Profile|Win32.Build.0 = Release|Win32 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Profile|x64.ActiveCfg = Release|x64 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Profile|x64.Build.0 = Release|x64 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Release|ARM.ActiveCfg = Release|ARM + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Release|ARM.Build.0 = Release|ARM + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Release|Win32.ActiveCfg = Release|Win32 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Release|Win32.Build.0 = Release|Win32 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Release|x64.ActiveCfg = Release|x64 + {C724E4D7-A1D1-41BE-8F22-382C6CB3CDAC}.Release|x64.Build.0 = Release|x64 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Debug|ARM.ActiveCfg = Debug|ARM + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Debug|ARM.Build.0 = Debug|ARM + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Debug|Win32.ActiveCfg = Debug|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Debug|Win32.Build.0 = Debug|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Debug|x64.ActiveCfg = Debug|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Profile|ARM.ActiveCfg = Release|ARM + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Profile|ARM.Build.0 = Release|ARM + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Profile|Win32.ActiveCfg = Release|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Profile|Win32.Build.0 = Release|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Profile|x64.ActiveCfg = Release|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Release|ARM.ActiveCfg = Release|ARM + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Release|ARM.Build.0 = Release|ARM + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Release|Win32.ActiveCfg = Release|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Release|Win32.Build.0 = Release|Win32 + {6CD25DC7-5D2C-48FB-B10B-345F1A13E3F3}.Release|x64.ActiveCfg = Release|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Debug|ARM.ActiveCfg = Debug|ARM + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Debug|ARM.Build.0 = Debug|ARM + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Debug|Win32.ActiveCfg = Debug|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Debug|Win32.Build.0 = Debug|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Debug|x64.ActiveCfg = Debug|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Profile|ARM.ActiveCfg = Release|ARM + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Profile|ARM.Build.0 = Release|ARM + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Profile|Win32.ActiveCfg = Release|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Profile|Win32.Build.0 = Release|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Profile|x64.ActiveCfg = Release|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Release|ARM.ActiveCfg = Release|ARM + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Release|ARM.Build.0 = Release|ARM + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Release|Win32.ActiveCfg = Release|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Release|Win32.Build.0 = Release|Win32 + {1DE5241B-2F18-4662-A196-F5C2A26CE5D6}.Release|x64.ActiveCfg = Release|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Debug|ARM.ActiveCfg = Debug|ARM + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Debug|ARM.Build.0 = Debug|ARM + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Debug|Win32.ActiveCfg = Debug|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Debug|Win32.Build.0 = Debug|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Debug|x64.ActiveCfg = Debug|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Profile|ARM.ActiveCfg = Release|ARM + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Profile|ARM.Build.0 = Release|ARM + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Profile|Win32.ActiveCfg = Release|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Profile|Win32.Build.0 = Release|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Profile|x64.ActiveCfg = Release|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Release|ARM.ActiveCfg = Release|ARM + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Release|ARM.Build.0 = Release|ARM + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Release|Win32.ActiveCfg = Release|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Release|Win32.Build.0 = Release|Win32 + {6BEE6FBA-C260-4A82-A8DA-6463F4FFA470}.Release|x64.ActiveCfg = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Debug|ARM.ActiveCfg = Debug|ARM + {B1A69919-8795-4071-AD05-883294596217}.Debug|ARM.Build.0 = Debug|ARM + {B1A69919-8795-4071-AD05-883294596217}.Debug|ARM.Deploy.0 = Debug|ARM + {B1A69919-8795-4071-AD05-883294596217}.Debug|Win32.ActiveCfg = Debug|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Debug|x64.ActiveCfg = Debug|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Profile|ARM.ActiveCfg = Release|ARM + {B1A69919-8795-4071-AD05-883294596217}.Profile|ARM.Build.0 = Release|ARM + {B1A69919-8795-4071-AD05-883294596217}.Profile|ARM.Deploy.0 = Release|ARM + {B1A69919-8795-4071-AD05-883294596217}.Profile|Win32.ActiveCfg = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Profile|Win32.Build.0 = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Profile|Win32.Deploy.0 = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Profile|x64.ActiveCfg = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Release|ARM.ActiveCfg = Release|ARM + {B1A69919-8795-4071-AD05-883294596217}.Release|ARM.Build.0 = Release|ARM + {B1A69919-8795-4071-AD05-883294596217}.Release|ARM.Deploy.0 = Release|ARM + {B1A69919-8795-4071-AD05-883294596217}.Release|Win32.ActiveCfg = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Release|Win32.Build.0 = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Release|Win32.Deploy.0 = Release|Win32 + {B1A69919-8795-4071-AD05-883294596217}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {45306C0E-E90B-4E84-A32F-504ED7B5C299} = {8314F48C-574C-483F-AA48-55A29510CC00} + {1C587904-01BA-482E-806E-0617AEA0B059} = {8314F48C-574C-483F-AA48-55A29510CC00} + {B1A69919-8795-4071-AD05-883294596217} = {8314F48C-574C-483F-AA48-55A29510CC00} + EndGlobalSection +EndGlobal diff --git a/projects/mtg/WRL/Wagic.vcxproj.filters b/projects/mtg/WRL/Wagic.vcxproj.filters new file mode 100644 index 000000000..df8c3e582 --- /dev/null +++ b/projects/mtg/WRL/Wagic.vcxproj.filters @@ -0,0 +1,249 @@ + + + + + 45306c0e-e90b-4e84-a32f-504ed7b5c299 + + + fa0c4a9e-0e3e-41e3-b373-64a5adc01ce4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/mtg/WRL/wagic.vcxproj b/projects/mtg/WRL/wagic.vcxproj new file mode 100644 index 000000000..bbfb719f0 --- /dev/null +++ b/projects/mtg/WRL/wagic.vcxproj @@ -0,0 +1,787 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {c724e4d7-a1d1-41be-8f22-382c6cb3cdac} + Win32Proj + wagic + wagic + en-US + 12.0 + true + Windows Store + 8.1 + + + + StaticLibrary + true + v120 + + + StaticLibrary + true + + + StaticLibrary + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\$(ProjectName) + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\$(ProjectName) + + + false + $(Platform)\$(Configuration)\$(ProjectName) + + + false + $(Platform)\$(Configuration)\$(ProjectName) + + + false + $(Platform)\$(Configuration)\$(ProjectName) + + + false + $(Platform)\$(Configuration)\$(ProjectName) + + + + NotUsing + false + true + ../include;../../../JGE/include;../../../JGE/src/zipFS;../../../JGE/Dependencies/zlib;../../../JGE/Dependencies/libpng;../../../JGE/Dependencies/libjpeg;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ../include;../../../JGE/include;../../../JGE/src/zipFS;../../../JGE/Dependencies/zlib;../../../JGE/Dependencies/libpng;../../../JGE/Dependencies/libjpeg;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ../include;../../../JGE/include;../../../JGE/src/zipFS;../../../JGE/Dependencies/zlib;../../../JGE/Dependencies/libpng;../../../JGE/Dependencies/libjpeg;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ../include;../../../JGE/include;../../../JGE/src/zipFS;../../../JGE/Dependencies/zlib;../../../JGE/Dependencies/libpng;../../../JGE/Dependencies/libjpeg;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ../include;../../../JGE/include;../../../JGE/src/zipFS;../../../JGE/Dependencies/zlib;../../../JGE/Dependencies/libpng;../../../JGE/Dependencies/libjpeg;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ../include;../../../JGE/include;../../../JGE/src/zipFS;../../../JGE/Dependencies/zlib;../../../JGE/Dependencies/libpng;../../../JGE/Dependencies/libjpeg;%(AdditionalIncludeDirectories) + TIXML_USE_STL;WP8;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + NotUsing + NotUsing + + + + + + \ No newline at end of file diff --git a/projects/mtg/include/GameStateMenu.h b/projects/mtg/include/GameStateMenu.h index d8fb9106a..0bec718e7 100644 --- a/projects/mtg/include/GameStateMenu.h +++ b/projects/mtg/include/GameStateMenu.h @@ -2,7 +2,6 @@ #define _GAME_STATE_MENU_H_ #include -#include #include "GameState.h" #include "SimpleMenu.h" #include "TextScroller.h" diff --git a/projects/mtg/include/MTGDeck.h b/projects/mtg/include/MTGDeck.h index fcba1b192..bd3292657 100644 --- a/projects/mtg/include/MTGDeck.h +++ b/projects/mtg/include/MTGDeck.h @@ -5,7 +5,7 @@ #include "MTGDefinitions.h" #include "WResourceManager.h" -#include +#include "PrecompiledHeader.h" #include #include #include diff --git a/projects/mtg/include/PrecompiledHeader.h b/projects/mtg/include/PrecompiledHeader.h index 5e6d0b458..3c0fd3930 100644 --- a/projects/mtg/include/PrecompiledHeader.h +++ b/projects/mtg/include/PrecompiledHeader.h @@ -16,10 +16,58 @@ #include #ifdef WP8 -#include -#include +#if !defined(WIN32_LEAN_AND_MEAN) +#define WIN32_LEAN_AND_MEAN +#endif + +#if !defined(NOMINMAX) +#define NOMINMAX +#endif + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#define DCOMMON_H_INCLUDED +#define NO_D3D11_DEBUG_NAME #else +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// VS 2010's stdint.h conflicts with intsafe.h +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + +#include +#include "..\extra\dirent.h" + +namespace DirectX +{ +#if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) +#define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; +#endif +} + +#else //WP8 #include +#include #endif #include "JGE.h" diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 80fb9a0f4..c3f66ef0b 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1509,7 +1509,7 @@ ostream& operator<<(ostream& out, const GameObserver& g) out << g.mSeed; out << endl; out << "rvalues:"; - out << g.randomGenerator.saveUsedRandValues(out); + g.randomGenerator.saveUsedRandValues(out); out << endl; out << g.startupGameSerialized; } diff --git a/projects/mtg/src/GameStateStory.cpp b/projects/mtg/src/GameStateStory.cpp index 8ec25b7f5..714249baa 100644 --- a/projects/mtg/src/GameStateStory.cpp +++ b/projects/mtg/src/GameStateStory.cpp @@ -4,7 +4,6 @@ #include "StoryFlow.h" #include "SimpleMenu.h" #include "GameApp.h" -#include GameStateStory::GameStateStory(GameApp* parent) : GameState(parent, "story") diff --git a/projects/mtg/src/MTGPack.cpp b/projects/mtg/src/MTGPack.cpp index 5e8b53d34..7e2026397 100644 --- a/projects/mtg/src/MTGPack.cpp +++ b/projects/mtg/src/MTGPack.cpp @@ -1,8 +1,6 @@ #include "PrecompiledHeader.h" #include -#include - #include "GameApp.h" #include "Translate.h" #include "WDataSrc.h" diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index 4fee0a0ea..61d2fa8a7 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -6,7 +6,6 @@ #include "Subtypes.h" #include "TranslateKeys.h" #include "StyleManager.h" -#include #include "SimpleMenu.h" //OptionItem diff --git a/projects/mtg/src/utils.cpp b/projects/mtg/src/utils.cpp index 2217b6143..c93fab4cf 100644 --- a/projects/mtg/src/utils.cpp +++ b/projects/mtg/src/utils.cpp @@ -41,7 +41,7 @@ int RandomGenerator::random() ostream& RandomGenerator::saveUsedRandValues(ostream& out) const { list::const_iterator ite; - for(ite=usedRandomValues.begin(); ite != usedRandomValues.end(); ite++) + for(ite=usedRandomValues.cbegin(); ite != usedRandomValues.cend(); ite++) { out << *ite << ","; }