Set Up DirextXTK in git
This commit is contained in:
parent
79558eed4f
commit
3aafec5bf8
181
enginecustom/include/Src/CMO.h
Normal file
181
enginecustom/include/Src/CMO.h
Normal file
@ -0,0 +1,181 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: CMO.h
|
||||
//
|
||||
// .CMO files are built by Visual Studio's MeshContentTask and an example renderer was
|
||||
// provided in the VS Direct3D Starter Kit
|
||||
// https://devblogs.microsoft.com/cppblog/developing-an-app-with-the-visual-studio-3d-starter-kit-part-1-of-3/
|
||||
// https://devblogs.microsoft.com/cppblog/developing-an-app-with-the-visual-studio-3d-starter-kit-part-2-of-3/
|
||||
// https://devblogs.microsoft.com/cppblog/developing-an-app-with-the-visual-studio-3d-starter-kit-part-3-of-3/
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
// http://go.microsoft.com/fwlink/?LinkID=615561
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <DirectXMath.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace VSD3DStarter
|
||||
{
|
||||
// .CMO files
|
||||
|
||||
// UINT - Mesh count
|
||||
// { [Mesh count]
|
||||
// UINT - Length of name
|
||||
// wchar_t[] - Name of mesh (if length > 0)
|
||||
// UINT - Material count
|
||||
// { [Material count]
|
||||
// UINT - Length of material name
|
||||
// wchar_t[] - Name of material (if length > 0)
|
||||
// Material structure
|
||||
// UINT - Length of pixel shader name
|
||||
// wchar_t[] - Name of pixel shader (if length > 0)
|
||||
// { [8]
|
||||
// UINT - Length of texture name
|
||||
// wchar_t[] - Name of texture (if length > 0)
|
||||
// }
|
||||
// }
|
||||
// BYTE - 1 if there is skeletal animation data present
|
||||
// UINT - SubMesh count
|
||||
// { [SubMesh count]
|
||||
// SubMesh structure
|
||||
// }
|
||||
// UINT - IB Count
|
||||
// { [IB Count]
|
||||
// UINT - Number of USHORTs in IB
|
||||
// USHORT[] - Array of indices
|
||||
// }
|
||||
// UINT - VB Count
|
||||
// { [VB Count]
|
||||
// UINT - Number of verts in VB
|
||||
// Vertex[] - Array of vertices
|
||||
// }
|
||||
// UINT - Skinning VB Count
|
||||
// { [Skinning VB Count]
|
||||
// UINT - Number of verts in Skinning VB
|
||||
// SkinningVertex[] - Array of skinning verts
|
||||
// }
|
||||
// MeshExtents structure
|
||||
// [If skeleton animation data is not present, file ends here]
|
||||
// UINT - Bone count
|
||||
// { [Bone count]
|
||||
// UINT - Length of bone name
|
||||
// wchar_t[] - Bone name (if length > 0)
|
||||
// Bone structure
|
||||
// }
|
||||
// UINT - Animation clip count
|
||||
// { [Animation clip count]
|
||||
// UINT - Length of clip name
|
||||
// wchar_t[] - Clip name (if length > 0)
|
||||
// float - Start time
|
||||
// float - End time
|
||||
// UINT - Keyframe count
|
||||
// { [Keyframe count]
|
||||
// Keyframe structure
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct Material
|
||||
{
|
||||
DirectX::XMFLOAT4 Ambient;
|
||||
DirectX::XMFLOAT4 Diffuse;
|
||||
DirectX::XMFLOAT4 Specular;
|
||||
float SpecularPower;
|
||||
DirectX::XMFLOAT4 Emissive;
|
||||
DirectX::XMFLOAT4X4 UVTransform;
|
||||
};
|
||||
|
||||
constexpr uint32_t MAX_TEXTURE = 8;
|
||||
|
||||
struct SubMesh
|
||||
{
|
||||
uint32_t MaterialIndex;
|
||||
uint32_t IndexBufferIndex;
|
||||
uint32_t VertexBufferIndex;
|
||||
uint32_t StartIndex;
|
||||
uint32_t PrimCount;
|
||||
};
|
||||
|
||||
constexpr uint32_t NUM_BONE_INFLUENCES = 4;
|
||||
|
||||
// Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal,
|
||||
// tangent, color (RGBA), and texture mapping information
|
||||
struct VertexPositionNormalTangentColorTexture
|
||||
{
|
||||
DirectX::XMFLOAT3 position;
|
||||
DirectX::XMFLOAT3 normal;
|
||||
DirectX::XMFLOAT4 tangent;
|
||||
uint32_t color;
|
||||
DirectX::XMFLOAT2 textureCoordinate;
|
||||
};
|
||||
|
||||
struct SkinningVertex
|
||||
{
|
||||
uint32_t boneIndex[NUM_BONE_INFLUENCES];
|
||||
float boneWeight[NUM_BONE_INFLUENCES];
|
||||
};
|
||||
|
||||
struct MeshExtents
|
||||
{
|
||||
float CenterX, CenterY, CenterZ;
|
||||
float Radius;
|
||||
|
||||
float MinX, MinY, MinZ;
|
||||
float MaxX, MaxY, MaxZ;
|
||||
};
|
||||
|
||||
struct Bone
|
||||
{
|
||||
int32_t ParentIndex;
|
||||
DirectX::XMFLOAT4X4 InvBindPos;
|
||||
DirectX::XMFLOAT4X4 BindPos;
|
||||
DirectX::XMFLOAT4X4 LocalTransform;
|
||||
};
|
||||
|
||||
struct Clip
|
||||
{
|
||||
float StartTime;
|
||||
float EndTime;
|
||||
uint32_t keys;
|
||||
};
|
||||
|
||||
struct Keyframe
|
||||
{
|
||||
uint32_t BoneIndex;
|
||||
float Time;
|
||||
DirectX::XMFLOAT4X4 Transform;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
const Material s_defMaterial =
|
||||
{
|
||||
{ 0.2f, 0.2f, 0.2f, 1.f },
|
||||
{ 0.8f, 0.8f, 0.8f, 1.f },
|
||||
{ 0.0f, 0.0f, 0.0f, 1.f },
|
||||
1.f,
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
{ 1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f },
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static_assert(sizeof(VSD3DStarter::Material) == 132, "CMO Mesh structure size incorrect");
|
||||
static_assert(sizeof(VSD3DStarter::SubMesh) == 20, "CMO Mesh structure size incorrect");
|
||||
static_assert(sizeof(VSD3DStarter::VertexPositionNormalTangentColorTexture) == 52, "CMO Mesh structure size incorrect");
|
||||
static_assert(sizeof(VSD3DStarter::SkinningVertex) == 32, "CMO Mesh structure size incorrect");
|
||||
static_assert(sizeof(VSD3DStarter::MeshExtents) == 40, "CMO Mesh structure size incorrect");
|
||||
static_assert(sizeof(VSD3DStarter::Bone) == 196, "CMO Mesh structure size incorrect");
|
||||
static_assert(sizeof(VSD3DStarter::Clip) == 12, "CMO Mesh structure size incorrect");
|
||||
static_assert(sizeof(VSD3DStarter::Keyframe) == 72, "CMO Mesh structure size incorrect");
|
330
enginecustom/include/Src/DDS.h
Normal file
330
enginecustom/include/Src/DDS.h
Normal file
@ -0,0 +1,330 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// DDS.h
|
||||
//
|
||||
// This header defines constants and structures that are useful when parsing
|
||||
// DDS files. DDS files were originally designed to use several structures
|
||||
// and constants that are native to DirectDraw and are defined in ddraw.h,
|
||||
// such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar
|
||||
// (compatible) constants and structures so that one can use DDS files
|
||||
// without needing to include ddraw.h.
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
// http://go.microsoft.com/fwlink/?LinkID=615561
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS "
|
||||
|
||||
struct DDS_PIXELFORMAT
|
||||
{
|
||||
uint32_t size;
|
||||
uint32_t flags;
|
||||
uint32_t fourCC;
|
||||
uint32_t RGBBitCount;
|
||||
uint32_t RBitMask;
|
||||
uint32_t GBitMask;
|
||||
uint32_t BBitMask;
|
||||
uint32_t ABitMask;
|
||||
};
|
||||
|
||||
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
|
||||
#define DDS_RGB 0x00000040 // DDPF_RGB
|
||||
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
|
||||
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
|
||||
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
|
||||
#define DDS_ALPHAPIXELS 0x00000001 // DDPF_ALPHAPIXELS
|
||||
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
|
||||
#define DDS_PAL8 0x00000020 // DDPF_PALETTEINDEXED8
|
||||
#define DDS_PAL8A 0x00000021 // DDPF_PALETTEINDEXED8 | DDPF_ALPHAPIXELS
|
||||
#define DDS_BUMPLUMINANCE 0x00040000 // DDPF_BUMPLUMINANCE
|
||||
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
|
||||
#define DDS_BUMPDUDVA 0x00080001 // DDPF_BUMPDUDV | DDPF_ALPHAPIXELS
|
||||
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
(static_cast<uint32_t>(static_cast<uint8_t>(ch0)) \
|
||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch1)) << 8) \
|
||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch2)) << 16) \
|
||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch3)) << 24))
|
||||
#endif /* MAKEFOURCC */
|
||||
|
||||
#ifndef DDSGLOBALCONST
|
||||
#if defined(__GNUC__) && !defined(__MINGW32__)
|
||||
#define DDSGLOBALCONST extern const __attribute__((weak))
|
||||
#else
|
||||
#define DDSGLOBALCONST extern const __declspec(selectany)
|
||||
#endif
|
||||
#endif /* DDSGLOBALCONST */
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT2 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT3 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT4 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_UNORM =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_SNORM =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_UNORM =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_SNORM =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_YUY2 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_UYVY =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G16R16 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R5G6B5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X1R5G5B5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x7c00, 0x03e0, 0x001f, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X4R4G4B4 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0f00, 0x00f0, 0x000f, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8B8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R3G3B2 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00e0, 0x001c, 0x0003, 0xff00 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R3G3B2 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xe0, 0x1c, 0x03, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4L4 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0f, 0, 0, 0xf0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x00ff, 0, 0, 0xff00 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8_NVTT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xff, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16_NVTT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xffff, 0, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00ff, 0, 0, 0xff00 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V8U8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_Q8W8V8U8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
|
||||
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V16U16 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
|
||||
|
||||
// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2R10G10B10 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 };
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 };
|
||||
|
||||
// The following legacy Direct3D 9 formats use 'mixed' signed & unsigned channels so requires special handling
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2W10V10U10 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDVA, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 };
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L6V5U5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 16, 0x001f, 0x03e0, 0xfc00, 0 };
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8L8V8U8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
|
||||
|
||||
// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
|
||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 };
|
||||
|
||||
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
|
||||
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
|
||||
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
||||
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
||||
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
||||
|
||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
||||
|
||||
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
||||
#define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
|
||||
#define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX
|
||||
|
||||
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
||||
#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
|
||||
#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
|
||||
#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
|
||||
#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
|
||||
|
||||
#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
|
||||
DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
|
||||
DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
|
||||
|
||||
#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP
|
||||
|
||||
#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
|
||||
|
||||
// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
|
||||
enum DDS_RESOURCE_DIMENSION : uint32_t
|
||||
{
|
||||
DDS_DIMENSION_TEXTURE1D = 2,
|
||||
DDS_DIMENSION_TEXTURE2D = 3,
|
||||
DDS_DIMENSION_TEXTURE3D = 4,
|
||||
};
|
||||
|
||||
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
|
||||
enum DDS_RESOURCE_MISC_FLAG : uint32_t
|
||||
{
|
||||
DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L,
|
||||
};
|
||||
|
||||
enum DDS_MISC_FLAGS2 : uint32_t
|
||||
{
|
||||
DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L,
|
||||
};
|
||||
|
||||
#ifndef DDS_ALPHA_MODE_DEFINED
|
||||
#define DDS_ALPHA_MODE_DEFINED
|
||||
enum DDS_ALPHA_MODE : uint32_t
|
||||
{
|
||||
DDS_ALPHA_MODE_UNKNOWN = 0,
|
||||
DDS_ALPHA_MODE_STRAIGHT = 1,
|
||||
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
||||
DDS_ALPHA_MODE_OPAQUE = 3,
|
||||
DDS_ALPHA_MODE_CUSTOM = 4,
|
||||
};
|
||||
#endif
|
||||
|
||||
struct DDS_HEADER
|
||||
{
|
||||
uint32_t size;
|
||||
uint32_t flags;
|
||||
uint32_t height;
|
||||
uint32_t width;
|
||||
uint32_t pitchOrLinearSize;
|
||||
uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags
|
||||
uint32_t mipMapCount;
|
||||
uint32_t reserved1[11];
|
||||
DDS_PIXELFORMAT ddspf;
|
||||
uint32_t caps;
|
||||
uint32_t caps2;
|
||||
uint32_t caps3;
|
||||
uint32_t caps4;
|
||||
uint32_t reserved2;
|
||||
};
|
||||
|
||||
struct DDS_HEADER_DXT10
|
||||
{
|
||||
DXGI_FORMAT dxgiFormat;
|
||||
uint32_t resourceDimension;
|
||||
uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG
|
||||
uint32_t arraySize;
|
||||
uint32_t miscFlags2; // see DDS_MISC_FLAGS2
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
static_assert(sizeof(DDS_PIXELFORMAT) == 32, "DDS pixel format size mismatch");
|
||||
static_assert(sizeof(DDS_HEADER) == 124, "DDS Header size mismatch");
|
||||
static_assert(sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch");
|
||||
|
||||
constexpr size_t DDS_MIN_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER);
|
||||
constexpr size_t DDS_DX10_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10);
|
||||
static_assert(DDS_DX10_HEADER_SIZE > DDS_MIN_HEADER_SIZE, "DDS DX10 Header should be larger than standard header");
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace Xbox
|
||||
{
|
||||
DDSGLOBALCONST DirectX::DDS_PIXELFORMAT DDSPF_XBOX =
|
||||
{ sizeof(DirectX::DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('X','B','O','X'), 0, 0, 0, 0, 0 };
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
struct DDS_HEADER_XBOX
|
||||
// Must match structure in XboxDDSTextureLoader module
|
||||
{
|
||||
DXGI_FORMAT dxgiFormat;
|
||||
uint32_t resourceDimension;
|
||||
uint32_t miscFlag; // see DDS_RESOURCE_MISC_FLAG
|
||||
uint32_t arraySize;
|
||||
uint32_t miscFlags2; // see DDS_MISC_FLAGS2
|
||||
uint32_t tileMode; // see XG_TILE_MODE / XG_SWIZZLE_MODE
|
||||
uint32_t baseAlignment;
|
||||
uint32_t dataSize;
|
||||
uint32_t xdkVer; // matching _XDK_VER / _GXDK_VER
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
static_assert(sizeof(DDS_HEADER_XBOX) == 36, "DDS XBOX Header size mismatch");
|
||||
static_assert(sizeof(DDS_HEADER_XBOX) > sizeof(DirectX::DDS_HEADER_DXT10), "DDS XBOX Header should be larger than DX10 header");
|
||||
|
||||
constexpr size_t DDS_XBOX_HEADER_SIZE = sizeof(uint32_t) + sizeof(DirectX::DDS_HEADER) + sizeof(DDS_HEADER_XBOX);
|
||||
|
||||
constexpr uint32_t XBOX_TILEMODE_SCARLETT = 0x1000000;
|
||||
} // namespace
|
1439
enginecustom/include/Src/DDSTextureLoader.cpp
Normal file
1439
enginecustom/include/Src/DDSTextureLoader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
54
enginecustom/include/Src/DirectXHelpers.cpp
Normal file
54
enginecustom/include/Src/DirectXHelpers.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: DirectXHelpers.cpp
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#include "pch.h"
|
||||
#include "DirectXHelpers.h"
|
||||
#include "Effects.h"
|
||||
#include "PlatformHelpers.h"
|
||||
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
_Use_decl_annotations_
|
||||
HRESULT DirectX::CreateInputLayoutFromEffect(
|
||||
ID3D11Device* device,
|
||||
IEffect* effect,
|
||||
const D3D11_INPUT_ELEMENT_DESC* desc,
|
||||
size_t count,
|
||||
ID3D11InputLayout** pInputLayout) noexcept
|
||||
{
|
||||
if (!pInputLayout)
|
||||
return E_INVALIDARG;
|
||||
|
||||
*pInputLayout = nullptr;
|
||||
|
||||
if (!device || !effect || !desc || !count)
|
||||
return E_INVALIDARG;
|
||||
|
||||
void const* shaderByteCode;
|
||||
size_t byteCodeLength;
|
||||
|
||||
try
|
||||
{
|
||||
effect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
|
||||
}
|
||||
catch (com_exception e)
|
||||
{
|
||||
return e.get_result();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return device->CreateInputLayout(
|
||||
desc, static_cast<UINT>(count),
|
||||
shaderByteCode, byteCodeLength,
|
||||
pInputLayout);
|
||||
}
|
1107
enginecustom/include/Src/LoaderHelpers.h
Normal file
1107
enginecustom/include/Src/LoaderHelpers.h
Normal file
File diff suppressed because it is too large
Load Diff
94
enginecustom/include/Src/PlatformHelpers.h
Normal file
94
enginecustom/include/Src/PlatformHelpers.h
Normal file
@ -0,0 +1,94 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: PlatformHelpers.h
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
// http://go.microsoft.com/fwlink/?LinkID=615561
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4324)
|
||||
#endif
|
||||
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
(static_cast<uint32_t>(static_cast<uint8_t>(ch0)) \
|
||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch1)) << 8) \
|
||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch2)) << 16) \
|
||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch3)) << 24))
|
||||
#endif /* defined(MAKEFOURCC) */
|
||||
|
||||
// See https://walbourn.github.io/modern-c++-bitmask-types/
|
||||
#ifndef ENUM_FLAGS_CONSTEXPR
|
||||
#if defined(NTDDI_WIN10_RS1) && !defined(__MINGW32__)
|
||||
#define ENUM_FLAGS_CONSTEXPR constexpr
|
||||
#else
|
||||
#define ENUM_FLAGS_CONSTEXPR const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
// Helper class for COM exceptions
|
||||
class com_exception : public std::exception
|
||||
{
|
||||
public:
|
||||
com_exception(HRESULT hr) noexcept : result(hr) {}
|
||||
|
||||
const char* what() const noexcept override
|
||||
{
|
||||
static char s_str[64] = {};
|
||||
sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(result));
|
||||
return s_str;
|
||||
}
|
||||
|
||||
HRESULT get_result() const noexcept { return result; }
|
||||
|
||||
private:
|
||||
HRESULT result;
|
||||
};
|
||||
|
||||
// Helper utility converts D3D API failures into exceptions.
|
||||
inline void ThrowIfFailed(HRESULT hr) noexcept(false)
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
throw com_exception(hr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Helper for output debug tracing
|
||||
inline void DebugTrace(_In_z_ _Printf_format_string_ const char* format, ...) noexcept
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
char buff[1024] = {};
|
||||
vsprintf_s(buff, format, args);
|
||||
OutputDebugStringA(buff);
|
||||
va_end(args);
|
||||
#else
|
||||
UNREFERENCED_PARAMETER(format);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper smart-pointers
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) || (defined(_XBOX_ONE) && defined(_TITLE)) || !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
|
||||
struct virtual_deleter { void operator()(void* p) noexcept { if (p) VirtualFree(p, 0, MEM_RELEASE); } };
|
||||
#endif
|
||||
|
||||
struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } };
|
||||
|
||||
using ScopedHandle = std::unique_ptr<void, handle_closer>;
|
||||
|
||||
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
|
||||
}
|
247
enginecustom/include/Src/SimpleMath.cpp
Normal file
247
enginecustom/include/Src/SimpleMath.cpp
Normal file
@ -0,0 +1,247 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
// SimpleMath.cpp -- Simplified C++ Math wrapper for DirectXMath
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
// http://go.microsoft.com/fwlink/?LinkID=615561
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#include "pch.h"
|
||||
#include "SimpleMath.h"
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Constants
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
namespace SimpleMath
|
||||
{
|
||||
const Vector2 Vector2::Zero = { 0.f, 0.f };
|
||||
const Vector2 Vector2::One = { 1.f, 1.f };
|
||||
const Vector2 Vector2::UnitX = { 1.f, 0.f };
|
||||
const Vector2 Vector2::UnitY = { 0.f, 1.f };
|
||||
|
||||
const Vector3 Vector3::Zero = { 0.f, 0.f, 0.f };
|
||||
const Vector3 Vector3::One = { 1.f, 1.f, 1.f };
|
||||
const Vector3 Vector3::UnitX = { 1.f, 0.f, 0.f };
|
||||
const Vector3 Vector3::UnitY = { 0.f, 1.f, 0.f };
|
||||
const Vector3 Vector3::UnitZ = { 0.f, 0.f, 1.f };
|
||||
const Vector3 Vector3::Up = { 0.f, 1.f, 0.f };
|
||||
const Vector3 Vector3::Down = { 0.f, -1.f, 0.f };
|
||||
const Vector3 Vector3::Right = { 1.f, 0.f, 0.f };
|
||||
const Vector3 Vector3::Left = { -1.f, 0.f, 0.f };
|
||||
const Vector3 Vector3::Forward = { 0.f, 0.f, -1.f };
|
||||
const Vector3 Vector3::Backward = { 0.f, 0.f, 1.f };
|
||||
|
||||
const Vector4 Vector4::Zero = { 0.f, 0.f, 0.f, 0.f };
|
||||
const Vector4 Vector4::One = { 1.f, 1.f, 1.f, 1.f };
|
||||
const Vector4 Vector4::UnitX = { 1.f, 0.f, 0.f, 0.f };
|
||||
const Vector4 Vector4::UnitY = { 0.f, 1.f, 0.f, 0.f };
|
||||
const Vector4 Vector4::UnitZ = { 0.f, 0.f, 1.f, 0.f };
|
||||
const Vector4 Vector4::UnitW = { 0.f, 0.f, 0.f, 1.f };
|
||||
|
||||
const Matrix Matrix::Identity = { 1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f };
|
||||
|
||||
const Quaternion Quaternion::Identity = { 0.f, 0.f, 0.f, 1.f };
|
||||
}
|
||||
}
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace DirectX::SimpleMath;
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Quaternion
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void Quaternion::RotateTowards(const Quaternion& target, float maxAngle, Quaternion& result) const noexcept
|
||||
{
|
||||
const XMVECTOR T = XMLoadFloat4(this);
|
||||
|
||||
// We can use the conjugate here instead of inverse assuming q1 & q2 are normalized.
|
||||
const XMVECTOR R = XMQuaternionMultiply(XMQuaternionConjugate(T), target);
|
||||
|
||||
const float rs = XMVectorGetW(R);
|
||||
const XMVECTOR L = XMVector3Length(R);
|
||||
const float angle = 2.f * atan2f(XMVectorGetX(L), rs);
|
||||
if (angle > maxAngle)
|
||||
{
|
||||
const XMVECTOR delta = XMQuaternionRotationAxis(R, maxAngle);
|
||||
const XMVECTOR Q = XMQuaternionMultiply(delta, T);
|
||||
XMStoreFloat4(&result, Q);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't overshoot.
|
||||
result = target;
|
||||
}
|
||||
}
|
||||
|
||||
void Quaternion::FromToRotation(const Vector3& fromDir, const Vector3& toDir, Quaternion& result) noexcept
|
||||
{
|
||||
// Melax, "The Shortest Arc Quaternion", Game Programming Gems, Charles River Media (2000).
|
||||
|
||||
const XMVECTOR F = XMVector3Normalize(fromDir);
|
||||
const XMVECTOR T = XMVector3Normalize(toDir);
|
||||
|
||||
const float dot = XMVectorGetX(XMVector3Dot(F, T));
|
||||
if (dot >= 1.f)
|
||||
{
|
||||
result = Identity;
|
||||
}
|
||||
else if (dot <= -1.f)
|
||||
{
|
||||
XMVECTOR axis = XMVector3Cross(F, Vector3::Right);
|
||||
if (XMVector3NearEqual(XMVector3LengthSq(axis), g_XMZero, g_XMEpsilon))
|
||||
{
|
||||
axis = XMVector3Cross(F, Vector3::Up);
|
||||
}
|
||||
|
||||
const XMVECTOR Q = XMQuaternionRotationAxis(axis, XM_PI);
|
||||
XMStoreFloat4(&result, Q);
|
||||
}
|
||||
else
|
||||
{
|
||||
const XMVECTOR C = XMVector3Cross(F, T);
|
||||
XMStoreFloat4(&result, C);
|
||||
|
||||
const float s = sqrtf((1.f + dot) * 2.f);
|
||||
result.x /= s;
|
||||
result.y /= s;
|
||||
result.z /= s;
|
||||
result.w = s * 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
void Quaternion::LookRotation(const Vector3& forward, const Vector3& up, Quaternion& result) noexcept
|
||||
{
|
||||
Quaternion q1;
|
||||
FromToRotation(Vector3::Forward, forward, q1);
|
||||
|
||||
const XMVECTOR C = XMVector3Cross(forward, up);
|
||||
if (XMVector3NearEqual(XMVector3LengthSq(C), g_XMZero, g_XMEpsilon))
|
||||
{
|
||||
// forward and up are co-linear
|
||||
result = q1;
|
||||
return;
|
||||
}
|
||||
|
||||
const XMVECTOR U = XMQuaternionMultiply(q1, Vector3::Up);
|
||||
|
||||
Quaternion q2;
|
||||
FromToRotation(U, up, q2);
|
||||
|
||||
XMStoreFloat4(&result, XMQuaternionMultiply(q2, q1));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Viewport
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
||||
static_assert(sizeof(DirectX::SimpleMath::Viewport) == sizeof(D3D11_VIEWPORT), "Size mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, x) == offsetof(D3D11_VIEWPORT, TopLeftX), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, y) == offsetof(D3D11_VIEWPORT, TopLeftY), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, width) == offsetof(D3D11_VIEWPORT, Width), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, height) == offsetof(D3D11_VIEWPORT, Height), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, minDepth) == offsetof(D3D11_VIEWPORT, MinDepth), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, maxDepth) == offsetof(D3D11_VIEWPORT, MaxDepth), "Layout mismatch");
|
||||
#endif
|
||||
|
||||
#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||
static_assert(sizeof(DirectX::SimpleMath::Viewport) == sizeof(D3D12_VIEWPORT), "Size mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, x) == offsetof(D3D12_VIEWPORT, TopLeftX), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, y) == offsetof(D3D12_VIEWPORT, TopLeftY), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, width) == offsetof(D3D12_VIEWPORT, Width), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, height) == offsetof(D3D12_VIEWPORT, Height), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, minDepth) == offsetof(D3D12_VIEWPORT, MinDepth), "Layout mismatch");
|
||||
static_assert(offsetof(DirectX::SimpleMath::Viewport, maxDepth) == offsetof(D3D12_VIEWPORT, MaxDepth), "Layout mismatch");
|
||||
#endif
|
||||
|
||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||
RECT Viewport::ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight) noexcept
|
||||
{
|
||||
RECT rct = {};
|
||||
|
||||
switch (int(scaling))
|
||||
{
|
||||
case DXGI_SCALING_STRETCH:
|
||||
// Output fills the entire window area
|
||||
rct.top = 0;
|
||||
rct.left = 0;
|
||||
rct.right = outputWidth;
|
||||
rct.bottom = outputHeight;
|
||||
break;
|
||||
|
||||
case 2 /*DXGI_SCALING_ASPECT_RATIO_STRETCH*/:
|
||||
// Output fills the window area but respects the original aspect ratio, using pillar boxing or letter boxing as required
|
||||
// Note: This scaling option is not supported for legacy Win32 windows swap chains
|
||||
{
|
||||
assert(backBufferHeight > 0);
|
||||
const float aspectRatio = float(backBufferWidth) / float(backBufferHeight);
|
||||
|
||||
// Horizontal fill
|
||||
float scaledWidth = float(outputWidth);
|
||||
float scaledHeight = float(outputWidth) / aspectRatio;
|
||||
if (scaledHeight >= float(outputHeight))
|
||||
{
|
||||
// Do vertical fill
|
||||
scaledWidth = float(outputHeight) * aspectRatio;
|
||||
scaledHeight = float(outputHeight);
|
||||
}
|
||||
|
||||
const float offsetX = (float(outputWidth) - scaledWidth) * 0.5f;
|
||||
const float offsetY = (float(outputHeight) - scaledHeight) * 0.5f;
|
||||
|
||||
rct.left = static_cast<LONG>(offsetX);
|
||||
rct.top = static_cast<LONG>(offsetY);
|
||||
rct.right = static_cast<LONG>(offsetX + scaledWidth);
|
||||
rct.bottom = static_cast<LONG>(offsetY + scaledHeight);
|
||||
|
||||
// Clip to display window
|
||||
rct.left = std::max<LONG>(0, rct.left);
|
||||
rct.top = std::max<LONG>(0, rct.top);
|
||||
rct.right = std::min<LONG>(outputWidth, rct.right);
|
||||
rct.bottom = std::min<LONG>(outputHeight, rct.bottom);
|
||||
}
|
||||
break;
|
||||
|
||||
case DXGI_SCALING_NONE:
|
||||
default:
|
||||
// Output is displayed in the upper left corner of the window area
|
||||
rct.top = 0;
|
||||
rct.left = 0;
|
||||
rct.right = std::min<LONG>(static_cast<LONG>(backBufferWidth), outputWidth);
|
||||
rct.bottom = std::min<LONG>(static_cast<LONG>(backBufferHeight), outputHeight);
|
||||
break;
|
||||
}
|
||||
|
||||
return rct;
|
||||
}
|
||||
#endif
|
||||
|
||||
RECT Viewport::ComputeTitleSafeArea(UINT backBufferWidth, UINT backBufferHeight) noexcept
|
||||
{
|
||||
const float safew = (float(backBufferWidth) + 19.f) / 20.f;
|
||||
const float safeh = (float(backBufferHeight) + 19.f) / 20.f;
|
||||
|
||||
RECT rct;
|
||||
rct.left = static_cast<LONG>(safew);
|
||||
rct.top = static_cast<LONG>(safeh);
|
||||
rct.right = static_cast<LONG>(float(backBufferWidth) - safew + 0.5f);
|
||||
rct.bottom = static_cast<LONG>(float(backBufferHeight) - safeh + 0.5f);
|
||||
|
||||
return rct;
|
||||
}
|
1294
enginecustom/include/Src/WICTextureLoader.cpp
Normal file
1294
enginecustom/include/Src/WICTextureLoader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
10
enginecustom/include/Src/pch.cpp
Normal file
10
enginecustom/include/Src/pch.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: pch.cpp
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#include "pch.h"
|
193
enginecustom/include/Src/pch.h
Normal file
193
enginecustom/include/Src/pch.h
Normal file
@ -0,0 +1,193 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: pch.h
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Off by default warnings
|
||||
#pragma warning(disable : 4619 4616 4061 4265 4365 4571 4623 4625 4626 4628 4668 4710 4711 4746 4774 4820 4987 5026 5027 5031 5032 5039 5045 5219 5264 26812)
|
||||
// C4619/4616 #pragma warning warnings
|
||||
// C4061 enumerator 'X' in switch of enum 'X' is not explicitly handled by a case label
|
||||
// C4265 class has virtual functions, but destructor is not virtual
|
||||
// C4365 signed/unsigned mismatch
|
||||
// C4571 behavior change
|
||||
// C4623 default constructor was implicitly defined as deleted
|
||||
// C4625 copy constructor was implicitly defined as deleted
|
||||
// C4626 assignment operator was implicitly defined as deleted
|
||||
// C4628 digraphs not supported
|
||||
// C4668 not defined as a preprocessor macro
|
||||
// C4710 function not inlined
|
||||
// C4711 selected for automatic inline expansion
|
||||
// C4746 volatile access of '<expression>' is subject to /volatile:<iso|ms> setting
|
||||
// C4774 format string expected in argument 3 is not a string literal
|
||||
// C4820 padding added after data member
|
||||
// C4987 nonstandard extension used
|
||||
// C5026 move constructor was implicitly defined as deleted
|
||||
// C5027 move assignment operator was implicitly defined as deleted
|
||||
// C5031/5032 push/pop mismatches in windows headers
|
||||
// C5039 pointer or reference to potentially throwing function passed to extern C function under - EHc
|
||||
// C5045 Spectre mitigation warning
|
||||
// C5219 implicit conversion from 'int' to 'float', possible loss of data
|
||||
// C5264 'const' variable is not used
|
||||
// 26812: The enum type 'x' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
|
||||
|
||||
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||
// Xbox One XDK related Off by default warnings
|
||||
#pragma warning(disable : 4471 4643 4917 4986 5029 5038 5040 5043 5204 5246 5256 5262 5267)
|
||||
// C4471 forward declaration of an unscoped enumeration must have an underlying type
|
||||
// C4643 Forward declaring in namespace std is not permitted by the C++ Standard
|
||||
// C4917 a GUID can only be associated with a class, interface or namespace
|
||||
// C4986 exception specification does not match previous declaration
|
||||
// C5029 nonstandard extension used
|
||||
// C5038 data member 'X' will be initialized after data member 'Y'
|
||||
// C5040 dynamic exception specifications are valid only in C++14 and earlier; treating as noexcept(false)
|
||||
// C5043 exception specification does not match previous declaration
|
||||
// C5204 class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly
|
||||
// C5246 'anonymous struct or union': the initialization of a subobject should be wrapped in braces
|
||||
// C5256 a non-defining declaration of an enumeration with a fixed underlying type is only permitted as a standalone declaration
|
||||
// C5262 implicit fall-through occurs here; are you missing a break statement?
|
||||
// C5267 definition of implicit copy constructor for 'X' is deprecated because it has a user-provided assignment operator
|
||||
#endif // _XBOX_ONE && _TITLE
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
#pragma warning(disable : 161 2960 3280)
|
||||
// warning #161: unrecognized #pragma
|
||||
// message #2960: allocation may not satisfy the type's alignment; consider using <aligned_new> header
|
||||
// message #3280: declaration hides member
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||
#pragma clang diagnostic ignored "-Wc++98-compat-local-type-template-args"
|
||||
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||
#pragma clang diagnostic ignored "-Wfloat-equal"
|
||||
#pragma clang diagnostic ignored "-Wglobal-constructors"
|
||||
#pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
|
||||
#pragma clang diagnostic ignored "-Wlanguage-extension-token"
|
||||
#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
|
||||
#pragma clang diagnostic ignored "-Wmicrosoft-include"
|
||||
#pragma clang diagnostic ignored "-Wnested-anon-types"
|
||||
#pragma clang diagnostic ignored "-Wreserved-id-macro"
|
||||
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||
#pragma clang diagnostic ignored "-Wunused-member-function"
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
||||
#endif
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4005)
|
||||
#define NOMINMAX 1
|
||||
#define NODRAWTEXT
|
||||
#define NOGDI
|
||||
#define NOBITMAP
|
||||
#define NOMCX
|
||||
#define NOSERVICE
|
||||
#define NOHELP
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#ifndef _WIN32_WINNT_WIN10
|
||||
#define _WIN32_WINNT_WIN10 0x0A00
|
||||
#endif
|
||||
|
||||
#ifndef WINAPI_FAMILY_GAMES
|
||||
#define WINAPI_FAMILY_GAMES 6
|
||||
#endif
|
||||
|
||||
#ifdef _GAMING_XBOX
|
||||
#error This version of DirectX Tool Kit not supported for GDKX
|
||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||
#include <xdk.h>
|
||||
|
||||
#if _XDK_VER < 0x42EE13B6 /* XDK Edition 180704 */
|
||||
#error DirectX Tool Kit for Direct3D 11 requires the July 2018 QFE4 XDK or later
|
||||
#endif
|
||||
|
||||
#include <d3d11_x.h>
|
||||
#else
|
||||
#include <d3d11_1.h>
|
||||
#endif
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
#include <exception>
|
||||
#include <iterator>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4702)
|
||||
#include <functional>
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
#define _XM_NO_XMVECTOR_OVERLOADS_
|
||||
|
||||
#include <DirectXMath.h>
|
||||
#include <DirectXPackedVector.h>
|
||||
#include <DirectXCollision.h>
|
||||
|
||||
#if (DIRECTX_MATH_VERSION < 315)
|
||||
#define XM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
|
||||
#endif
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4467 4986 5038 5204 5220 6101)
|
||||
#ifdef __MINGW32__
|
||||
#include <wrl/client.h>
|
||||
#else
|
||||
#include <wrl.h>
|
||||
#endif
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <wincodec.h>
|
||||
|
||||
#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__)
|
||||
#include <ocidl.h>
|
||||
#else
|
||||
#include <OCIdl.h>
|
||||
#endif
|
||||
|
||||
#if (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)) || (defined(_XBOX_ONE) && defined(_TITLE))
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4471 5204 5256)
|
||||
#include <Windows.UI.Core.h>
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <mutex>
|
Loading…
x
Reference in New Issue
Block a user