Added simple GUI + DirectX render target
This commit is contained in:
parent
0c40609b50
commit
cca56693f3
44 changed files with 7721 additions and 51 deletions
|
@ -102,7 +102,7 @@ void CPU::RunBenchmark()
|
||||||
{
|
{
|
||||||
std::ifstream romFile("6502_functional_test.bin", std::ios::in | std::ios::binary);
|
std::ifstream romFile("6502_functional_test.bin", std::ios::in | std::ios::binary);
|
||||||
if(!romFile) {
|
if(!romFile) {
|
||||||
std::cout << "Error";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *romMemory = new uint8_t[65536];
|
uint8_t *romMemory = new uint8_t[65536];
|
|
@ -18,13 +18,13 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
@ -84,9 +84,7 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="ReadMe.txt" />
|
<ClInclude Include="PPU.h" />
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="CPU.h" />
|
<ClInclude Include="CPU.h" />
|
||||||
<ClInclude Include="EventHandler.h" />
|
<ClInclude Include="EventHandler.h" />
|
||||||
<ClInclude Include="Memory.h" />
|
<ClInclude Include="Memory.h" />
|
||||||
|
@ -94,6 +92,7 @@
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="PPU.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="CPU.cpp" />
|
<ClCompile Include="CPU.cpp" />
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
|
@ -14,9 +14,6 @@
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Text Include="ReadMe.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="stdafx.h">
|
<ClInclude Include="stdafx.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
|
@ -33,6 +30,9 @@
|
||||||
<ClInclude Include="Memory.h">
|
<ClInclude Include="Memory.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="PPU.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp">
|
<ClCompile Include="main.cpp">
|
||||||
|
@ -47,5 +47,8 @@
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="PPU.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -19,6 +19,13 @@ class Timer
|
||||||
_start = li;
|
_start = li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reset()
|
||||||
|
{
|
||||||
|
LARGE_INTEGER li;
|
||||||
|
QueryPerformanceCounter(&li);
|
||||||
|
_start = li;
|
||||||
|
}
|
||||||
|
|
||||||
double GetElapsedMS()
|
double GetElapsedMS()
|
||||||
{
|
{
|
||||||
LARGE_INTEGER li;
|
LARGE_INTEGER li;
|
682
GUI/DirectXTK/Audio.h
Normal file
682
GUI/DirectXTK/Audio.h
Normal file
|
@ -0,0 +1,682 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: Audio.h
|
||||||
|
//
|
||||||
|
// DirectXTK for Audio header
|
||||||
|
//
|
||||||
|
// 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 <objbase.h>
|
||||||
|
#include <mmreg.h>
|
||||||
|
#include <audioclient.h>
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
|
#include <xma2defs.h>
|
||||||
|
#pragma comment(lib,"acphal.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||||
|
#pragma comment(lib,"PhoneAudioSes.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER < 1700)
|
||||||
|
#error DirectX Tool Kit for Audio does not support VS 2010 without the DirectX SDK
|
||||||
|
#endif
|
||||||
|
#include <xaudio2.h>
|
||||||
|
#include <xaudio2fx.h>
|
||||||
|
#include <x3daudio.h>
|
||||||
|
#include <xapofx.h>
|
||||||
|
#pragma comment(lib,"xaudio2.lib")
|
||||||
|
#else
|
||||||
|
// Using XAudio 2.7 requires the DirectX SDK
|
||||||
|
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\comdecl.h>
|
||||||
|
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h>
|
||||||
|
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\xaudio2fx.h>
|
||||||
|
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\xapofx.h>
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning( disable : 4005 )
|
||||||
|
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\x3daudio.h>
|
||||||
|
#pragma warning(pop)
|
||||||
|
#pragma comment(lib,"x3daudio.lib")
|
||||||
|
#pragma comment(lib,"xapofx.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4005)
|
||||||
|
#include <stdint.h>
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4481)
|
||||||
|
// VS 2010 considers 'override' to be a extension, but it's part of C++11 as of VS 2012
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
#if (DIRECTXMATH_VERSION < 305) && !defined(XM_CALLCONV)
|
||||||
|
#define XM_CALLCONV __fastcall
|
||||||
|
typedef const XMVECTOR& HXMVECTOR;
|
||||||
|
typedef const XMMATRIX& FXMMATRIX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class SoundEffectInstance;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
struct AudioStatistics
|
||||||
|
{
|
||||||
|
size_t playingOneShots; // Number of one-shot sounds currently playing
|
||||||
|
size_t playingInstances; // Number of sound effect instances currently playing
|
||||||
|
size_t allocatedInstances; // Number of SoundEffectInstance allocated
|
||||||
|
size_t allocatedVoices; // Number of XAudio2 voices allocated (standard, 3D, one-shots, and idle one-shots)
|
||||||
|
size_t allocatedVoices3d; // Number of XAudio2 voices allocated for 3D
|
||||||
|
size_t allocatedVoicesOneShot; // Number of XAudio2 voices allocated for one-shot sounds
|
||||||
|
size_t allocatedVoicesIdle; // Number of XAudio2 voices allocated for one-shot sounds but not currently in use
|
||||||
|
size_t audioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
|
size_t xmaAudioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks allocated with ApuAlloc
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
class IVoiceNotify
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void OnBufferEnd() = 0;
|
||||||
|
// Notfication that a voice buffer has finished
|
||||||
|
// Note this is called from XAudio2's worker thread, so it should perform very minimal and thread-safe operations
|
||||||
|
|
||||||
|
virtual void OnCriticalError() = 0;
|
||||||
|
// Notification that the audio engine encountered a critical error
|
||||||
|
|
||||||
|
virtual void OnReset() = 0;
|
||||||
|
// Notification of an audio engine reset
|
||||||
|
|
||||||
|
virtual void OnUpdate() = 0;
|
||||||
|
// Notification of an audio engine per-frame update (opt-in)
|
||||||
|
|
||||||
|
virtual void OnDestroyEngine() = 0;
|
||||||
|
// Notification that the audio engine is being destroyed
|
||||||
|
|
||||||
|
virtual void OnTrim() = 0;
|
||||||
|
// Notification of a request to trim the voice pool
|
||||||
|
|
||||||
|
virtual void GatherStatistics( AudioStatistics& stats ) const = 0;
|
||||||
|
// Contribute to statistics request
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
enum AUDIO_ENGINE_FLAGS
|
||||||
|
{
|
||||||
|
AudioEngine_Default = 0x0,
|
||||||
|
|
||||||
|
AudioEngine_EnvironmentalReverb = 0x1,
|
||||||
|
AudioEngine_ReverbUseFilters = 0x2,
|
||||||
|
AudioEngine_UseMasteringLimiter = 0x4,
|
||||||
|
|
||||||
|
AudioEngine_Debug = 0x10000,
|
||||||
|
AudioEngine_ThrowOnNoAudioHW = 0x20000,
|
||||||
|
AudioEngine_DisableVoiceReuse = 0x40000,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline AUDIO_ENGINE_FLAGS operator|(AUDIO_ENGINE_FLAGS a, AUDIO_ENGINE_FLAGS b) { return static_cast<AUDIO_ENGINE_FLAGS>( static_cast<int>(a) | static_cast<int>(b) ); }
|
||||||
|
|
||||||
|
enum SOUND_EFFECT_INSTANCE_FLAGS
|
||||||
|
{
|
||||||
|
SoundEffectInstance_Default = 0x0,
|
||||||
|
|
||||||
|
SoundEffectInstance_Use3D = 0x1,
|
||||||
|
SoundEffectInstance_ReverbUseFilters = 0x2,
|
||||||
|
SoundEffectInstance_NoSetPitch = 0x4,
|
||||||
|
|
||||||
|
SoundEffectInstance_UseRedirectLFE = 0x10000,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline SOUND_EFFECT_INSTANCE_FLAGS operator|(SOUND_EFFECT_INSTANCE_FLAGS a, SOUND_EFFECT_INSTANCE_FLAGS b) { return static_cast<SOUND_EFFECT_INSTANCE_FLAGS>( static_cast<int>(a) | static_cast<int>(b) ); }
|
||||||
|
|
||||||
|
enum AUDIO_ENGINE_REVERB
|
||||||
|
{
|
||||||
|
Reverb_Off,
|
||||||
|
Reverb_Default,
|
||||||
|
Reverb_Generic,
|
||||||
|
Reverb_Forest,
|
||||||
|
Reverb_PaddedCell,
|
||||||
|
Reverb_Room,
|
||||||
|
Reverb_Bathroom,
|
||||||
|
Reverb_LivingRoom,
|
||||||
|
Reverb_StoneRoom,
|
||||||
|
Reverb_Auditorium,
|
||||||
|
Reverb_ConcertHall,
|
||||||
|
Reverb_Cave,
|
||||||
|
Reverb_Arena,
|
||||||
|
Reverb_Hangar,
|
||||||
|
Reverb_CarpetedHallway,
|
||||||
|
Reverb_Hallway,
|
||||||
|
Reverb_StoneCorridor,
|
||||||
|
Reverb_Alley,
|
||||||
|
Reverb_City,
|
||||||
|
Reverb_Mountains,
|
||||||
|
Reverb_Quarry,
|
||||||
|
Reverb_Plain,
|
||||||
|
Reverb_ParkingLot,
|
||||||
|
Reverb_SewerPipe,
|
||||||
|
Reverb_Underwater,
|
||||||
|
Reverb_SmallRoom,
|
||||||
|
Reverb_MediumRoom,
|
||||||
|
Reverb_LargeRoom,
|
||||||
|
Reverb_MediumHall,
|
||||||
|
Reverb_LargeHall,
|
||||||
|
Reverb_Plate,
|
||||||
|
Reverb_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SoundState
|
||||||
|
{
|
||||||
|
STOPPED = 0,
|
||||||
|
PLAYING,
|
||||||
|
PAUSED
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
class AudioEngine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AudioEngine( AUDIO_ENGINE_FLAGS flags = AudioEngine_Default, _In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr,
|
||||||
|
AUDIO_STREAM_CATEGORY category = AudioCategory_GameEffects );
|
||||||
|
|
||||||
|
AudioEngine(AudioEngine&& moveFrom);
|
||||||
|
AudioEngine& operator= (AudioEngine&& moveFrom);
|
||||||
|
virtual ~AudioEngine();
|
||||||
|
|
||||||
|
bool Update();
|
||||||
|
// Performs per-frame processing for the audio engine, returns false if in 'silent mode'
|
||||||
|
|
||||||
|
bool Reset( _In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr );
|
||||||
|
// Reset audio engine from critical error/silent mode using a new device; can also 'migrate' the graph
|
||||||
|
// Returns true if succesfully reset, false if in 'silent mode' due to no default device
|
||||||
|
// Note: One shots are lost, all SoundEffectInstances are in the STOPPED state after successful reset
|
||||||
|
|
||||||
|
void Suspend();
|
||||||
|
void Resume();
|
||||||
|
// Suspend/resumes audio processing (i.e. global pause/resume)
|
||||||
|
|
||||||
|
void SetReverb( AUDIO_ENGINE_REVERB reverb );
|
||||||
|
void SetReverb( _In_opt_ const XAUDIO2FX_REVERB_PARAMETERS* native );
|
||||||
|
// Sets environmental reverb for 3D positional audio (if active)
|
||||||
|
|
||||||
|
void SetMasteringLimit( int release, int loudness );
|
||||||
|
// Sets the mastering volume limiter properties (if active)
|
||||||
|
|
||||||
|
AudioStatistics GetStatistics() const;
|
||||||
|
// Gathers audio engine statistics
|
||||||
|
|
||||||
|
WAVEFORMATEXTENSIBLE GetOutputFormat() const;
|
||||||
|
// Returns the format consumed by the mastering voice (which is the same as the device output if defaults are used)
|
||||||
|
|
||||||
|
uint32_t GetChannelMask() const;
|
||||||
|
// Returns the output channel mask
|
||||||
|
|
||||||
|
int GetOutputChannels() const;
|
||||||
|
// Returns the number of output channels
|
||||||
|
|
||||||
|
bool IsAudioDevicePresent() const;
|
||||||
|
// Returns true if the audio graph is operating normally, false if in 'silent mode'
|
||||||
|
|
||||||
|
bool IsCriticalError() const;
|
||||||
|
// Returns true if the audio graph is halted due to a critical error (which also places the engine into 'silent mode')
|
||||||
|
|
||||||
|
// Voice pool management.
|
||||||
|
void SetDefaultSampleRate( int sampleRate );
|
||||||
|
// Sample rate for voices in the reuse pool (defaults to 44100)
|
||||||
|
|
||||||
|
void SetMaxVoicePool( size_t maxOneShots, size_t maxInstances );
|
||||||
|
// Maximum number of voices to allocate for one-shots and instances
|
||||||
|
// Note: one-shots over this limit are ignored; too many instance voices throws an exception
|
||||||
|
|
||||||
|
void TrimVoicePool();
|
||||||
|
// Releases any currently unused voices
|
||||||
|
|
||||||
|
void AllocateVoice( _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags, bool oneshot, _Outptr_result_maybenull_ IXAudio2SourceVoice** voice );
|
||||||
|
|
||||||
|
void DestroyVoice( _In_ IXAudio2SourceVoice* voice );
|
||||||
|
// Should only be called for instance voices, not one-shots
|
||||||
|
|
||||||
|
void RegisterNotify( _In_ IVoiceNotify* notify, bool usesUpdate );
|
||||||
|
void UnregisterNotify( _In_ IVoiceNotify* notify, bool usesOneShots, bool usesUpdate );
|
||||||
|
|
||||||
|
// XAudio2 interface access
|
||||||
|
IXAudio2* GetInterface() const;
|
||||||
|
IXAudio2MasteringVoice* GetMasterVoice() const;
|
||||||
|
IXAudio2SubmixVoice* GetReverbVoice() const;
|
||||||
|
X3DAUDIO_HANDLE& Get3DHandle() const;
|
||||||
|
|
||||||
|
struct RendererDetail
|
||||||
|
{
|
||||||
|
std::wstring deviceId;
|
||||||
|
std::wstring description;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::vector<RendererDetail> GetRendererDetails();
|
||||||
|
// Returns a list of valid audio endpoint devices
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
AudioEngine(AudioEngine const&);
|
||||||
|
AudioEngine& operator= (AudioEngine const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
class WaveBank
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WaveBank( _In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName );
|
||||||
|
|
||||||
|
WaveBank(WaveBank&& moveFrom);
|
||||||
|
WaveBank& operator= (WaveBank&& moveFrom);
|
||||||
|
virtual ~WaveBank();
|
||||||
|
|
||||||
|
void Play( int index );
|
||||||
|
void Play( _In_z_ const char* name );
|
||||||
|
|
||||||
|
std::unique_ptr<SoundEffectInstance> CreateInstance( int index, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
|
||||||
|
std::unique_ptr<SoundEffectInstance> CreateInstance( _In_z_ const char* name, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
|
||||||
|
|
||||||
|
bool IsPrepared() const;
|
||||||
|
bool IsInUse() const;
|
||||||
|
bool IsStreamingBank() const;
|
||||||
|
|
||||||
|
size_t GetSampleSizeInBytes( int index ) const;
|
||||||
|
// Returns size of wave audio data
|
||||||
|
|
||||||
|
size_t GetSampleDuration( int index ) const;
|
||||||
|
// Returns the duration in samples
|
||||||
|
|
||||||
|
size_t GetSampleDurationMS( int index ) const;
|
||||||
|
// Returns the duration in milliseconds
|
||||||
|
|
||||||
|
const WAVEFORMATEX* GetFormat( int index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* wfx, size_t maxsize ) const;
|
||||||
|
|
||||||
|
int Find( _In_z_ const char* name ) const;
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
|
||||||
|
bool FillSubmitBuffer( int index, _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const;
|
||||||
|
#else
|
||||||
|
void FillSubmitBuffer( int index, _Out_ XAUDIO2_BUFFER& buffer ) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
WaveBank(WaveBank const&);
|
||||||
|
WaveBank& operator= (WaveBank const&);
|
||||||
|
|
||||||
|
// Private interface
|
||||||
|
void UnregisterInstance( _In_ SoundEffectInstance* instance );
|
||||||
|
|
||||||
|
friend class SoundEffectInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
class SoundEffect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SoundEffect( _In_ AudioEngine* engine, _In_z_ const wchar_t* waveFileName );
|
||||||
|
|
||||||
|
SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
|
||||||
|
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes );
|
||||||
|
|
||||||
|
SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
|
||||||
|
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
||||||
|
uint32_t loopStart, uint32_t loopLength );
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
|
||||||
|
|
||||||
|
SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
|
||||||
|
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
||||||
|
_In_reads_(seekCount) const uint32_t* seekTable, size_t seekCount );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SoundEffect(SoundEffect&& moveFrom);
|
||||||
|
SoundEffect& operator= (SoundEffect&& moveFrom);
|
||||||
|
virtual ~SoundEffect();
|
||||||
|
|
||||||
|
void Play();
|
||||||
|
|
||||||
|
std::unique_ptr<SoundEffectInstance> CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
|
||||||
|
|
||||||
|
bool IsInUse() const;
|
||||||
|
|
||||||
|
size_t GetSampleSizeInBytes() const;
|
||||||
|
// Returns size of wave audio data
|
||||||
|
|
||||||
|
size_t GetSampleDuration() const;
|
||||||
|
// Returns the duration in samples
|
||||||
|
|
||||||
|
size_t GetSampleDurationMS() const;
|
||||||
|
// Returns the duration in milliseconds
|
||||||
|
|
||||||
|
const WAVEFORMATEX* GetFormat() const;
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
|
||||||
|
bool FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const;
|
||||||
|
#else
|
||||||
|
void FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer ) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
SoundEffect(SoundEffect const&);
|
||||||
|
SoundEffect& operator= (SoundEffect const&);
|
||||||
|
|
||||||
|
// Private interface
|
||||||
|
void UnregisterInstance( _In_ SoundEffectInstance* instance );
|
||||||
|
|
||||||
|
friend class SoundEffectInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
struct AudioListener : public X3DAUDIO_LISTENER
|
||||||
|
{
|
||||||
|
AudioListener()
|
||||||
|
{
|
||||||
|
memset( this, 0, sizeof(X3DAUDIO_LISTENER) );
|
||||||
|
|
||||||
|
OrientFront.z =
|
||||||
|
OrientTop.y = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetPosition( FXMVECTOR v )
|
||||||
|
{
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), v );
|
||||||
|
}
|
||||||
|
void SetPosition( const XMFLOAT3& pos )
|
||||||
|
{
|
||||||
|
Position.x = pos.x;
|
||||||
|
Position.y = pos.y;
|
||||||
|
Position.z = pos.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetVelocity( FXMVECTOR v )
|
||||||
|
{
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
|
||||||
|
}
|
||||||
|
void SetVelocity( const XMFLOAT3& vel )
|
||||||
|
{
|
||||||
|
Velocity.x = vel.x;
|
||||||
|
Velocity.y = vel.y;
|
||||||
|
Velocity.z = vel.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetOrientation( FXMVECTOR forward, FXMVECTOR up )
|
||||||
|
{
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
|
||||||
|
}
|
||||||
|
void SetOrientation( const XMFLOAT3& forward, const XMFLOAT3& up )
|
||||||
|
{
|
||||||
|
OrientFront.x = forward.x; OrientTop.x = up.x;
|
||||||
|
OrientFront.y = forward.y; OrientTop.y = up.y;
|
||||||
|
OrientFront.z = forward.z; OrientTop.z = up.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetOrientationFromQuaternion( FXMVECTOR quat )
|
||||||
|
{
|
||||||
|
XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
|
||||||
|
|
||||||
|
XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV Update( FXMVECTOR newPos, XMVECTOR upDir, float dt )
|
||||||
|
// Updates velocity and orientation by tracking changes in position over time...
|
||||||
|
{
|
||||||
|
if ( dt > 0.f )
|
||||||
|
{
|
||||||
|
XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast<const XMFLOAT3*>( &Position ) );
|
||||||
|
|
||||||
|
XMVECTOR vDelta = ( newPos - lastPos );
|
||||||
|
XMVECTOR v = vDelta / dt;
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
|
||||||
|
|
||||||
|
vDelta = XMVector3Normalize( vDelta );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), vDelta );
|
||||||
|
|
||||||
|
v = XMVector3Cross( upDir, vDelta );
|
||||||
|
v = XMVector3Normalize( v );
|
||||||
|
|
||||||
|
v = XMVector3Cross( vDelta, v );
|
||||||
|
v = XMVector3Normalize( v );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), v );
|
||||||
|
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), newPos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
struct AudioEmitter : public X3DAUDIO_EMITTER
|
||||||
|
{
|
||||||
|
float EmitterAzimuths[XAUDIO2_MAX_AUDIO_CHANNELS];
|
||||||
|
|
||||||
|
AudioEmitter()
|
||||||
|
{
|
||||||
|
memset( this, 0, sizeof(X3DAUDIO_EMITTER) );
|
||||||
|
memset( EmitterAzimuths, 0, sizeof(EmitterAzimuths) );
|
||||||
|
|
||||||
|
OrientFront.z =
|
||||||
|
OrientTop.y =
|
||||||
|
ChannelRadius =
|
||||||
|
CurveDistanceScaler =
|
||||||
|
DopplerScaler = 1.f;
|
||||||
|
|
||||||
|
ChannelCount = 1;
|
||||||
|
pChannelAzimuths = EmitterAzimuths;
|
||||||
|
|
||||||
|
InnerRadiusAngle = X3DAUDIO_PI / 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetPosition( FXMVECTOR v )
|
||||||
|
{
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), v );
|
||||||
|
}
|
||||||
|
void SetPosition( const XMFLOAT3& pos )
|
||||||
|
{
|
||||||
|
Position.x = pos.x;
|
||||||
|
Position.y = pos.y;
|
||||||
|
Position.z = pos.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetVelocity( FXMVECTOR v )
|
||||||
|
{
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
|
||||||
|
}
|
||||||
|
void SetVelocity( const XMFLOAT3& vel )
|
||||||
|
{
|
||||||
|
Velocity.x = vel.x;
|
||||||
|
Velocity.y = vel.y;
|
||||||
|
Velocity.z = vel.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetOrientation( FXMVECTOR forward, FXMVECTOR up )
|
||||||
|
{
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
|
||||||
|
}
|
||||||
|
void SetOrientation( const XMFLOAT3& forward, const XMFLOAT3& up )
|
||||||
|
{
|
||||||
|
OrientFront.x = forward.x; OrientTop.x = up.x;
|
||||||
|
OrientFront.y = forward.y; OrientTop.y = up.y;
|
||||||
|
OrientFront.z = forward.z; OrientTop.z = up.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV SetOrientationFromQuaternion( FXMVECTOR quat )
|
||||||
|
{
|
||||||
|
XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
|
||||||
|
|
||||||
|
XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
|
||||||
|
}
|
||||||
|
|
||||||
|
void XM_CALLCONV Update( FXMVECTOR newPos, XMVECTOR upDir, float dt )
|
||||||
|
// Updates velocity and orientation by tracking changes in position over time...
|
||||||
|
{
|
||||||
|
if ( dt > 0.f )
|
||||||
|
{
|
||||||
|
XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast<const XMFLOAT3*>( &Position ) );
|
||||||
|
|
||||||
|
XMVECTOR vDelta = ( newPos - lastPos );
|
||||||
|
XMVECTOR v = vDelta / dt;
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
|
||||||
|
|
||||||
|
vDelta = XMVector3Normalize( vDelta );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), vDelta );
|
||||||
|
|
||||||
|
v = XMVector3Cross( upDir, vDelta );
|
||||||
|
v = XMVector3Normalize( v );
|
||||||
|
|
||||||
|
v = XMVector3Cross( vDelta, v );
|
||||||
|
v = XMVector3Normalize( v );
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), v );
|
||||||
|
|
||||||
|
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), newPos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
class SoundEffectInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SoundEffectInstance(SoundEffectInstance&& moveFrom);
|
||||||
|
SoundEffectInstance& operator= (SoundEffectInstance&& moveFrom);
|
||||||
|
virtual ~SoundEffectInstance();
|
||||||
|
|
||||||
|
void Play( bool loop = false );
|
||||||
|
void Stop( bool immediate = true );
|
||||||
|
void Pause();
|
||||||
|
void Resume();
|
||||||
|
|
||||||
|
void SetVolume( float volume );
|
||||||
|
void SetPitch( float pitch );
|
||||||
|
void SetPan( float pan );
|
||||||
|
|
||||||
|
void Apply3D( const AudioListener& listener, const AudioEmitter& emitter );
|
||||||
|
|
||||||
|
bool IsLooped() const;
|
||||||
|
|
||||||
|
SoundState GetState();
|
||||||
|
|
||||||
|
// Notifications.
|
||||||
|
void OnDestroyParent();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Private constructors
|
||||||
|
SoundEffectInstance( _In_ AudioEngine* engine, _In_ SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags );
|
||||||
|
SoundEffectInstance( _In_ AudioEngine* engine, _In_ WaveBank* effect, int index, SOUND_EFFECT_INSTANCE_FLAGS flags );
|
||||||
|
|
||||||
|
friend std::unique_ptr<SoundEffectInstance> SoundEffect::CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS );
|
||||||
|
friend std::unique_ptr<SoundEffectInstance> WaveBank::CreateInstance( int, SOUND_EFFECT_INSTANCE_FLAGS );
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
SoundEffectInstance(SoundEffectInstance const&);
|
||||||
|
SoundEffectInstance& operator= (SoundEffectInstance const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
class DynamicSoundEffectInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DynamicSoundEffectInstance( _In_ AudioEngine* engine,
|
||||||
|
_In_opt_ std::function<void(DynamicSoundEffectInstance*)> bufferNeeded,
|
||||||
|
int sampleRate, int channels, int sampleBits = 16,
|
||||||
|
SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
|
||||||
|
DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom);
|
||||||
|
DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance&& moveFrom);
|
||||||
|
virtual ~DynamicSoundEffectInstance();
|
||||||
|
|
||||||
|
void Play();
|
||||||
|
void Stop( bool immediate = true );
|
||||||
|
void Pause();
|
||||||
|
void Resume();
|
||||||
|
|
||||||
|
void SetVolume( float volume );
|
||||||
|
void SetPitch( float pitch );
|
||||||
|
void SetPan( float pan );
|
||||||
|
|
||||||
|
void Apply3D( const AudioListener& listener, const AudioEmitter& emitter );
|
||||||
|
|
||||||
|
void SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, size_t audioBytes );
|
||||||
|
void SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, uint32_t offset, size_t audioBytes );
|
||||||
|
|
||||||
|
SoundState GetState();
|
||||||
|
|
||||||
|
size_t GetSampleDuration( size_t bytes ) const;
|
||||||
|
// Returns duration in samples of a buffer of a given size
|
||||||
|
|
||||||
|
size_t GetSampleDurationMS( size_t bytes ) const;
|
||||||
|
// Returns duration in milliseconds of a buffer of a given size
|
||||||
|
|
||||||
|
size_t GetSampleSizeInBytes( uint64_t duration ) const;
|
||||||
|
// Returns size of a buffer for a duration given in milliseconds
|
||||||
|
|
||||||
|
int GetPendingBufferCount() const;
|
||||||
|
|
||||||
|
const WAVEFORMATEX* GetFormat() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
DynamicSoundEffectInstance(DynamicSoundEffectInstance const&);
|
||||||
|
DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance const&);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning(pop)
|
70
GUI/DirectXTK/CommonStates.h
Normal file
70
GUI/DirectXTK/CommonStates.h
Normal file
|
@ -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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
class CommonStates
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CommonStates(_In_ ID3D11Device* device);
|
||||||
|
CommonStates(CommonStates&& moveFrom);
|
||||||
|
CommonStates& operator= (CommonStates&& moveFrom);
|
||||||
|
virtual ~CommonStates();
|
||||||
|
|
||||||
|
// Blend states.
|
||||||
|
ID3D11BlendState* Opaque() const;
|
||||||
|
ID3D11BlendState* AlphaBlend() const;
|
||||||
|
ID3D11BlendState* Additive() const;
|
||||||
|
ID3D11BlendState* NonPremultiplied() const;
|
||||||
|
|
||||||
|
// Depth stencil states.
|
||||||
|
ID3D11DepthStencilState* DepthNone() const;
|
||||||
|
ID3D11DepthStencilState* DepthDefault() const;
|
||||||
|
ID3D11DepthStencilState* DepthRead() const;
|
||||||
|
|
||||||
|
// Rasterizer states.
|
||||||
|
ID3D11RasterizerState* CullNone() const;
|
||||||
|
ID3D11RasterizerState* CullClockwise() const;
|
||||||
|
ID3D11RasterizerState* CullCounterClockwise() const;
|
||||||
|
ID3D11RasterizerState* Wireframe() const;
|
||||||
|
|
||||||
|
// Sampler states.
|
||||||
|
ID3D11SamplerState* PointWrap() const;
|
||||||
|
ID3D11SamplerState* PointClamp() const;
|
||||||
|
ID3D11SamplerState* LinearWrap() const;
|
||||||
|
ID3D11SamplerState* LinearClamp() const;
|
||||||
|
ID3D11SamplerState* AnisotropicWrap() const;
|
||||||
|
ID3D11SamplerState* AnisotropicClamp() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::shared_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
CommonStates(CommonStates const&);
|
||||||
|
CommonStates& operator= (CommonStates const&);
|
||||||
|
};
|
||||||
|
}
|
142
GUI/DirectXTK/DDSTextureLoader.h
Normal file
142
GUI/DirectXTK/DDSTextureLoader.h
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: DDSTextureLoader.h
|
||||||
|
//
|
||||||
|
// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it
|
||||||
|
//
|
||||||
|
// Note these functions are useful as a light-weight runtime loader for DDS files. For
|
||||||
|
// a full-featured DDS file reader, writer, and texture processing pipeline see
|
||||||
|
// the 'Texconv' sample and the 'DirectXTex' library.
|
||||||
|
//
|
||||||
|
// 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=248926
|
||||||
|
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4005)
|
||||||
|
#include <stdint.h>
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
enum DDS_ALPHA_MODE
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Standard version
|
||||||
|
HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
// Standard version with optional auto-gen mipmap support
|
||||||
|
HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
// Extended version
|
||||||
|
HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
// Extended version with optional auto-gen mipmap support
|
||||||
|
HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||||
|
);
|
||||||
|
}
|
120
GUI/DirectXTK/DirectXHelpers.h
Normal file
120
GUI/DirectXTK/DirectXHelpers.h
Normal file
|
@ -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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#define NO_D3D11_DEBUG_NAME
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||||
|
#pragma comment(lib,"dxguid.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4005)
|
||||||
|
#include <stdint.h>
|
||||||
|
#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<uint8_t*>( pData );
|
||||||
|
}
|
||||||
|
uint8_t* get(size_t slice) const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<uint8_t*>( pData ) + ( slice * DepthPitch );
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* scanline(size_t row) const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<uint8_t*>( pData ) + ( row * RowPitch );
|
||||||
|
}
|
||||||
|
uint8_t* scanline(size_t slice, size_t row) const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<uint8_t*>( 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<UINT TNameLength>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
598
GUI/DirectXTK/Effects.h
Normal file
598
GUI/DirectXTK/Effects.h
Normal file
|
@ -0,0 +1,598 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: Effects.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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4481)
|
||||||
|
// VS 2010 considers 'override' to be a extension, but it's part of C++11 as of VS 2012
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
#if (DIRECTXMATH_VERSION < 305) && !defined(XM_CALLCONV)
|
||||||
|
#define XM_CALLCONV __fastcall
|
||||||
|
typedef const XMVECTOR& HXMVECTOR;
|
||||||
|
typedef const XMMATRIX& FXMMATRIX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Abstract interface representing any effect which can be applied onto a D3D device context.
|
||||||
|
class IEffect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IEffect() { }
|
||||||
|
|
||||||
|
virtual void Apply(_In_ ID3D11DeviceContext* deviceContext) = 0;
|
||||||
|
|
||||||
|
virtual void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Abstract interface for effects with world, view, and projection matrices.
|
||||||
|
class IEffectMatrices
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IEffectMatrices() { }
|
||||||
|
|
||||||
|
virtual void XM_CALLCONV SetWorld(FXMMATRIX value) = 0;
|
||||||
|
virtual void XM_CALLCONV SetView(FXMMATRIX value) = 0;
|
||||||
|
virtual void XM_CALLCONV SetProjection(FXMMATRIX value) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Abstract interface for effects which support directional lighting.
|
||||||
|
class IEffectLights
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IEffectLights() { }
|
||||||
|
|
||||||
|
virtual void SetLightingEnabled(bool value) = 0;
|
||||||
|
virtual void SetPerPixelLighting(bool value) = 0;
|
||||||
|
virtual void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) = 0;
|
||||||
|
|
||||||
|
virtual void SetLightEnabled(int whichLight, bool value) = 0;
|
||||||
|
virtual void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) = 0;
|
||||||
|
virtual void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) = 0;
|
||||||
|
virtual void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) = 0;
|
||||||
|
|
||||||
|
virtual void EnableDefaultLighting() = 0;
|
||||||
|
|
||||||
|
static const int MaxDirectionalLights = 3;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Abstract interface for effects which support fog.
|
||||||
|
class IEffectFog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IEffectFog() { }
|
||||||
|
|
||||||
|
virtual void SetFogEnabled(bool value) = 0;
|
||||||
|
virtual void SetFogStart(float value) = 0;
|
||||||
|
virtual void SetFogEnd(float value) = 0;
|
||||||
|
virtual void XM_CALLCONV SetFogColor(FXMVECTOR value) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Abstract interface for effects which support skinning
|
||||||
|
class IEffectSkinning
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IEffectSkinning() { }
|
||||||
|
|
||||||
|
virtual void SetWeightsPerVertex(int value) = 0;
|
||||||
|
virtual void SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) = 0;
|
||||||
|
virtual void ResetBoneTransforms() = 0;
|
||||||
|
|
||||||
|
static const int MaxBones = 72;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Built-in shader supports optional texture mapping, vertex coloring, directional lighting, and fog.
|
||||||
|
class BasicEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit BasicEffect(_In_ ID3D11Device* device);
|
||||||
|
BasicEffect(BasicEffect&& moveFrom);
|
||||||
|
BasicEffect& operator= (BasicEffect&& moveFrom);
|
||||||
|
virtual ~BasicEffect();
|
||||||
|
|
||||||
|
// IEffect methods.
|
||||||
|
void Apply(_In_ ID3D11DeviceContext* deviceContext) override;
|
||||||
|
|
||||||
|
void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override;
|
||||||
|
|
||||||
|
// Camera settings.
|
||||||
|
void XM_CALLCONV SetWorld(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetView(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetProjection(FXMMATRIX value) override;
|
||||||
|
|
||||||
|
// Material settings.
|
||||||
|
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetEmissiveColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetSpecularColor(FXMVECTOR value);
|
||||||
|
void SetSpecularPower(float value);
|
||||||
|
void DisableSpecular();
|
||||||
|
void SetAlpha(float value);
|
||||||
|
|
||||||
|
// Light settings.
|
||||||
|
void SetLightingEnabled(bool value) override;
|
||||||
|
void SetPerPixelLighting(bool value) override;
|
||||||
|
void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void SetLightEnabled(int whichLight, bool value) override;
|
||||||
|
void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override;
|
||||||
|
void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void EnableDefaultLighting() override;
|
||||||
|
|
||||||
|
// Fog settings.
|
||||||
|
void SetFogEnabled(bool value) override;
|
||||||
|
void SetFogStart(float value) override;
|
||||||
|
void SetFogEnd(float value) override;
|
||||||
|
void XM_CALLCONV SetFogColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
// Vertex color setting.
|
||||||
|
void SetVertexColorEnabled(bool value);
|
||||||
|
|
||||||
|
// Texture setting.
|
||||||
|
void SetTextureEnabled(bool value);
|
||||||
|
void SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
BasicEffect(BasicEffect const&);
|
||||||
|
BasicEffect& operator= (BasicEffect const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Built-in shader supports per-pixel alpha testing.
|
||||||
|
class AlphaTestEffect : public IEffect, public IEffectMatrices, public IEffectFog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AlphaTestEffect(_In_ ID3D11Device* device);
|
||||||
|
AlphaTestEffect(AlphaTestEffect&& moveFrom);
|
||||||
|
AlphaTestEffect& operator= (AlphaTestEffect&& moveFrom);
|
||||||
|
virtual ~AlphaTestEffect();
|
||||||
|
|
||||||
|
// IEffect methods.
|
||||||
|
void Apply(_In_ ID3D11DeviceContext* deviceContext) override;
|
||||||
|
|
||||||
|
void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override;
|
||||||
|
|
||||||
|
// Camera settings.
|
||||||
|
void XM_CALLCONV SetWorld(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetView(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetProjection(FXMMATRIX value) override;
|
||||||
|
|
||||||
|
// Material settings.
|
||||||
|
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
|
||||||
|
void SetAlpha(float value);
|
||||||
|
|
||||||
|
// Fog settings.
|
||||||
|
void SetFogEnabled(bool value) override;
|
||||||
|
void SetFogStart(float value) override;
|
||||||
|
void SetFogEnd(float value) override;
|
||||||
|
void XM_CALLCONV SetFogColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
// Vertex color setting.
|
||||||
|
void SetVertexColorEnabled(bool value);
|
||||||
|
|
||||||
|
// Texture setting.
|
||||||
|
void SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
|
||||||
|
// Alpha test settings.
|
||||||
|
void SetAlphaFunction(D3D11_COMPARISON_FUNC value);
|
||||||
|
void SetReferenceAlpha(int value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
AlphaTestEffect(AlphaTestEffect const&);
|
||||||
|
AlphaTestEffect& operator= (AlphaTestEffect const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Built-in shader supports two layer multitexturing (eg. for lightmaps or detail textures).
|
||||||
|
class DualTextureEffect : public IEffect, public IEffectMatrices, public IEffectFog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DualTextureEffect(_In_ ID3D11Device* device);
|
||||||
|
DualTextureEffect(DualTextureEffect&& moveFrom);
|
||||||
|
DualTextureEffect& operator= (DualTextureEffect&& moveFrom);
|
||||||
|
~DualTextureEffect();
|
||||||
|
|
||||||
|
// IEffect methods.
|
||||||
|
void Apply(_In_ ID3D11DeviceContext* deviceContext) override;
|
||||||
|
|
||||||
|
void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override;
|
||||||
|
|
||||||
|
// Camera settings.
|
||||||
|
void XM_CALLCONV SetWorld(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetView(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetProjection(FXMMATRIX value) override;
|
||||||
|
|
||||||
|
// Material settings.
|
||||||
|
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
|
||||||
|
void SetAlpha(float value);
|
||||||
|
|
||||||
|
// Fog settings.
|
||||||
|
void SetFogEnabled(bool value) override;
|
||||||
|
void SetFogStart(float value) override;
|
||||||
|
void SetFogEnd(float value) override;
|
||||||
|
void XM_CALLCONV SetFogColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
// Vertex color setting.
|
||||||
|
void SetVertexColorEnabled(bool value);
|
||||||
|
|
||||||
|
// Texture settings.
|
||||||
|
void SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
void SetTexture2(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
DualTextureEffect(DualTextureEffect const&);
|
||||||
|
DualTextureEffect& operator= (DualTextureEffect const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Built-in shader supports cubic environment mapping.
|
||||||
|
class EnvironmentMapEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit EnvironmentMapEffect(_In_ ID3D11Device* device);
|
||||||
|
EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom);
|
||||||
|
EnvironmentMapEffect& operator= (EnvironmentMapEffect&& moveFrom);
|
||||||
|
virtual ~EnvironmentMapEffect();
|
||||||
|
|
||||||
|
// IEffect methods.
|
||||||
|
void Apply(_In_ ID3D11DeviceContext* deviceContext) override;
|
||||||
|
|
||||||
|
void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override;
|
||||||
|
|
||||||
|
// Camera settings.
|
||||||
|
void XM_CALLCONV SetWorld(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetView(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetProjection(FXMMATRIX value) override;
|
||||||
|
|
||||||
|
// Material settings.
|
||||||
|
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetEmissiveColor(FXMVECTOR value);
|
||||||
|
void SetAlpha(float value);
|
||||||
|
|
||||||
|
// Light settings.
|
||||||
|
void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void SetLightEnabled(int whichLight, bool value) override;
|
||||||
|
void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override;
|
||||||
|
void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void EnableDefaultLighting() override;
|
||||||
|
|
||||||
|
// Fog settings.
|
||||||
|
void SetFogEnabled(bool value) override;
|
||||||
|
void SetFogStart(float value) override;
|
||||||
|
void SetFogEnd(float value) override;
|
||||||
|
void XM_CALLCONV SetFogColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
// Texture setting.
|
||||||
|
void SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
|
||||||
|
// Environment map settings.
|
||||||
|
void SetEnvironmentMap(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
void SetEnvironmentMapAmount(float value);
|
||||||
|
void XM_CALLCONV SetEnvironmentMapSpecular(FXMVECTOR value);
|
||||||
|
void SetFresnelFactor(float value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Unsupported interface methods.
|
||||||
|
void SetLightingEnabled(bool value) override;
|
||||||
|
void SetPerPixelLighting(bool value) override;
|
||||||
|
void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
EnvironmentMapEffect(EnvironmentMapEffect const&);
|
||||||
|
EnvironmentMapEffect& operator= (EnvironmentMapEffect const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Built-in shader supports skinned animation.
|
||||||
|
class SkinnedEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog, public IEffectSkinning
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SkinnedEffect(_In_ ID3D11Device* device);
|
||||||
|
SkinnedEffect(SkinnedEffect&& moveFrom);
|
||||||
|
SkinnedEffect& operator= (SkinnedEffect&& moveFrom);
|
||||||
|
virtual ~SkinnedEffect();
|
||||||
|
|
||||||
|
// IEffect methods.
|
||||||
|
void Apply(_In_ ID3D11DeviceContext* deviceContext) override;
|
||||||
|
|
||||||
|
void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override;
|
||||||
|
|
||||||
|
// Camera settings.
|
||||||
|
void XM_CALLCONV SetWorld(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetView(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetProjection(FXMMATRIX value) override;
|
||||||
|
|
||||||
|
// Material settings.
|
||||||
|
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetEmissiveColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetSpecularColor(FXMVECTOR value);
|
||||||
|
void SetSpecularPower(float value);
|
||||||
|
void DisableSpecular();
|
||||||
|
void SetAlpha(float value);
|
||||||
|
|
||||||
|
// Light settings.
|
||||||
|
void SetPerPixelLighting(bool value) override;
|
||||||
|
void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void SetLightEnabled(int whichLight, bool value) override;
|
||||||
|
void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override;
|
||||||
|
void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void EnableDefaultLighting() override;
|
||||||
|
|
||||||
|
// Fog settings.
|
||||||
|
void SetFogEnabled(bool value) override;
|
||||||
|
void SetFogStart(float value) override;
|
||||||
|
void SetFogEnd(float value) override;
|
||||||
|
void XM_CALLCONV SetFogColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
// Texture setting.
|
||||||
|
void SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
|
||||||
|
// Animation settings.
|
||||||
|
void SetWeightsPerVertex(int value) override;
|
||||||
|
void SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override;
|
||||||
|
void ResetBoneTransforms() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Unsupported interface method.
|
||||||
|
void SetLightingEnabled(bool value) override;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
SkinnedEffect(SkinnedEffect const&);
|
||||||
|
SkinnedEffect& operator= (SkinnedEffect const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Built-in effect for Visual Studio Shader Designer (DGSL) shaders
|
||||||
|
class DGSLEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectSkinning
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DGSLEffect( _In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader = nullptr,
|
||||||
|
_In_ bool enableSkinning = false );
|
||||||
|
DGSLEffect(DGSLEffect&& moveFrom);
|
||||||
|
DGSLEffect& operator= (DGSLEffect&& moveFrom);
|
||||||
|
virtual ~DGSLEffect();
|
||||||
|
|
||||||
|
// IEffect methods.
|
||||||
|
void Apply(_In_ ID3D11DeviceContext* deviceContext) override;
|
||||||
|
|
||||||
|
void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override;
|
||||||
|
|
||||||
|
// Camera settings.
|
||||||
|
void XM_CALLCONV SetWorld(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetView(FXMMATRIX value) override;
|
||||||
|
void XM_CALLCONV SetProjection(FXMMATRIX value) override;
|
||||||
|
|
||||||
|
// Material settings.
|
||||||
|
void XM_CALLCONV SetAmbientColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetEmissiveColor(FXMVECTOR value);
|
||||||
|
void XM_CALLCONV SetSpecularColor(FXMVECTOR value);
|
||||||
|
void SetSpecularPower(float value);
|
||||||
|
void DisableSpecular();
|
||||||
|
void SetAlpha(float value);
|
||||||
|
|
||||||
|
// Additional settings.
|
||||||
|
void XM_CALLCONV SetUVTransform(FXMMATRIX value);
|
||||||
|
void SetViewport( float width, float height );
|
||||||
|
void SetTime( float time );
|
||||||
|
void SetAlphaDiscardEnable(bool value);
|
||||||
|
|
||||||
|
// Light settings.
|
||||||
|
void SetLightingEnabled(bool value) override;
|
||||||
|
void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void SetLightEnabled(int whichLight, bool value) override;
|
||||||
|
void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override;
|
||||||
|
void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override;
|
||||||
|
|
||||||
|
void EnableDefaultLighting() override;
|
||||||
|
|
||||||
|
static const int MaxDirectionalLights = 4;
|
||||||
|
|
||||||
|
// Vertex color setting.
|
||||||
|
void SetVertexColorEnabled(bool value);
|
||||||
|
|
||||||
|
// Texture settings.
|
||||||
|
void SetTextureEnabled(bool value);
|
||||||
|
void SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
void SetTexture(int whichTexture, _In_opt_ ID3D11ShaderResourceView* value);
|
||||||
|
|
||||||
|
static const int MaxTextures = 8;
|
||||||
|
|
||||||
|
// Animation setting.
|
||||||
|
void SetWeightsPerVertex(int value) override;
|
||||||
|
void SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override;
|
||||||
|
void ResetBoneTransforms() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Unsupported interface methods.
|
||||||
|
void SetPerPixelLighting(bool value) override;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
DGSLEffect(DGSLEffect const&);
|
||||||
|
DGSLEffect& operator= (DGSLEffect const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Abstract interface to factory for sharing effects and texture resources
|
||||||
|
class IEffectFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IEffectFactory() {}
|
||||||
|
|
||||||
|
struct EffectInfo
|
||||||
|
{
|
||||||
|
const WCHAR* name;
|
||||||
|
bool perVertexColor;
|
||||||
|
bool enableSkinning;
|
||||||
|
float specularPower;
|
||||||
|
float alpha;
|
||||||
|
DirectX::XMFLOAT3 ambientColor;
|
||||||
|
DirectX::XMFLOAT3 diffuseColor;
|
||||||
|
DirectX::XMFLOAT3 specularColor;
|
||||||
|
DirectX::XMFLOAT3 emissiveColor;
|
||||||
|
const WCHAR* texture;
|
||||||
|
|
||||||
|
EffectInfo() { memset( this, 0, sizeof(EffectInfo) ); };
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual std::shared_ptr<IEffect> CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) = 0;
|
||||||
|
|
||||||
|
virtual void CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Factory for sharing effects and texture resources
|
||||||
|
class EffectFactory : public IEffectFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit EffectFactory(_In_ ID3D11Device* device);
|
||||||
|
EffectFactory(EffectFactory&& moveFrom);
|
||||||
|
EffectFactory& operator= (EffectFactory&& moveFrom);
|
||||||
|
virtual ~EffectFactory();
|
||||||
|
|
||||||
|
// IEffectFactory methods.
|
||||||
|
virtual std::shared_ptr<IEffect> CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override;
|
||||||
|
virtual void CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override;
|
||||||
|
|
||||||
|
// Settings.
|
||||||
|
void ReleaseCache();
|
||||||
|
|
||||||
|
void SetSharing( bool enabled );
|
||||||
|
|
||||||
|
void SetDirectory( _In_opt_z_ const WCHAR* path );
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::shared_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
EffectFactory(EffectFactory const&);
|
||||||
|
EffectFactory& operator= (EffectFactory const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Factory for sharing Visual Studio Shader Designer (DGSL) shaders and texture resources
|
||||||
|
class DGSLEffectFactory : public IEffectFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DGSLEffectFactory(_In_ ID3D11Device* device);
|
||||||
|
DGSLEffectFactory(DGSLEffectFactory&& moveFrom);
|
||||||
|
DGSLEffectFactory& operator= (DGSLEffectFactory&& moveFrom);
|
||||||
|
virtual ~DGSLEffectFactory();
|
||||||
|
|
||||||
|
// IEffectFactory methods.
|
||||||
|
virtual std::shared_ptr<IEffect> CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override;
|
||||||
|
virtual void CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override;
|
||||||
|
|
||||||
|
// DGSL methods.
|
||||||
|
struct DGSLEffectInfo : public EffectInfo
|
||||||
|
{
|
||||||
|
const WCHAR* textures[7];
|
||||||
|
const WCHAR* pixelShader;
|
||||||
|
|
||||||
|
DGSLEffectInfo() { memset( this, 0, sizeof(DGSLEffectInfo) ); };
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual std::shared_ptr<IEffect> CreateDGSLEffect( _In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext );
|
||||||
|
|
||||||
|
virtual void CreatePixelShader( _In_z_ const WCHAR* shader, _Outptr_ ID3D11PixelShader** pixelShader );
|
||||||
|
|
||||||
|
// Settings.
|
||||||
|
void ReleaseCache();
|
||||||
|
|
||||||
|
void SetSharing( bool enabled );
|
||||||
|
|
||||||
|
void SetDirectory( _In_opt_z_ const WCHAR* path );
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::shared_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
DGSLEffectFactory(DGSLEffectFactory const&);
|
||||||
|
DGSLEffectFactory& operator= (DGSLEffectFactory const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning(pop)
|
77
GUI/DirectXTK/GeometricPrimitive.h
Normal file
77
GUI/DirectXTK/GeometricPrimitive.h
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: GeometricPrimitive.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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
#include <DirectXColors.h>
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
#if (DIRECTXMATH_VERSION < 305) && !defined(XM_CALLCONV)
|
||||||
|
#define XM_CALLCONV __fastcall
|
||||||
|
typedef const XMVECTOR& HXMVECTOR;
|
||||||
|
typedef const XMMATRIX& FXMMATRIX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class IEffect;
|
||||||
|
|
||||||
|
class GeometricPrimitive
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~GeometricPrimitive();
|
||||||
|
|
||||||
|
// Factory methods.
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateCube (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 16, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateGeoSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 3, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateCylinder (_In_ ID3D11DeviceContext* deviceContext, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateCone (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateTorus (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateTetrahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateOctahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateDodecahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateIcosahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
|
||||||
|
static std::unique_ptr<GeometricPrimitive> CreateTeapot (_In_ ID3D11DeviceContext* deviceContext, float size = 1, size_t tessellation = 8, bool rhcoords = true);
|
||||||
|
|
||||||
|
// Draw the primitive.
|
||||||
|
void XM_CALLCONV Draw(FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, FXMVECTOR color = Colors::White, _In_opt_ ID3D11ShaderResourceView* texture = nullptr, bool wireframe = false, _In_opt_ std::function<void()> setCustomState = nullptr);
|
||||||
|
|
||||||
|
// Draw the primitive using a custom effect.
|
||||||
|
void Draw( _In_ IEffect* effect, _In_ ID3D11InputLayout* inputLayout, bool alpha = false, bool wireframe = false, _In_opt_ std::function<void()> setCustomState = nullptr );
|
||||||
|
|
||||||
|
// Create input layout for drawing with a custom effect.
|
||||||
|
void CreateInputLayout( _In_ IEffect* effect, _Outptr_ ID3D11InputLayout** inputLayout );
|
||||||
|
|
||||||
|
private:
|
||||||
|
GeometricPrimitive();
|
||||||
|
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
GeometricPrimitive(GeometricPrimitive const&);
|
||||||
|
GeometricPrimitive& operator= (GeometricPrimitive const&);
|
||||||
|
};
|
||||||
|
}
|
141
GUI/DirectXTK/Model.h
Normal file
141
GUI/DirectXTK/Model.h
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: Model.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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
#include <DirectXCollision.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4005)
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <intsafe.h>
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
#include <wrl.h>
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
#if (DIRECTXMATH_VERSION < 305) && !defined(XM_CALLCONV)
|
||||||
|
#define XM_CALLCONV __fastcall
|
||||||
|
typedef const XMVECTOR& HXMVECTOR;
|
||||||
|
typedef const XMMATRIX& FXMMATRIX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class IEffect;
|
||||||
|
class IEffectFactory;
|
||||||
|
class CommonStates;
|
||||||
|
class ModelMesh;
|
||||||
|
|
||||||
|
// Each mesh part is a submesh with a single effect
|
||||||
|
class ModelMeshPart
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ModelMeshPart();
|
||||||
|
|
||||||
|
uint32_t indexCount;
|
||||||
|
uint32_t startIndex;
|
||||||
|
uint32_t vertexOffset;
|
||||||
|
uint32_t vertexStride;
|
||||||
|
D3D_PRIMITIVE_TOPOLOGY primitiveType;
|
||||||
|
DXGI_FORMAT indexFormat;
|
||||||
|
Microsoft::WRL::ComPtr<ID3D11InputLayout> inputLayout;
|
||||||
|
Microsoft::WRL::ComPtr<ID3D11Buffer> indexBuffer;
|
||||||
|
Microsoft::WRL::ComPtr<ID3D11Buffer> vertexBuffer;
|
||||||
|
std::shared_ptr<IEffect> effect;
|
||||||
|
std::shared_ptr<std::vector<D3D11_INPUT_ELEMENT_DESC>> vbDecl;
|
||||||
|
bool isAlpha;
|
||||||
|
|
||||||
|
typedef std::vector<std::unique_ptr<ModelMeshPart>> Collection;
|
||||||
|
|
||||||
|
// Draw mesh part with custom effect
|
||||||
|
void Draw( _In_ ID3D11DeviceContext* deviceContext, _In_ IEffect* effect, _In_ ID3D11InputLayout* inputLayout,
|
||||||
|
_In_opt_ std::function<void()> setCustomState = nullptr ) const;
|
||||||
|
|
||||||
|
// Create input layout for drawing with a custom effect.
|
||||||
|
void CreateInputLayout( _In_ ID3D11Device* d3dDevice, _In_ IEffect* effect, _Outptr_ ID3D11InputLayout** inputLayout );
|
||||||
|
|
||||||
|
// Change effect used by part and regenerate input layout (be sure to call Model::Modified as well)
|
||||||
|
void ModifyEffect( _In_ ID3D11Device* d3dDevice, _In_ std::shared_ptr<IEffect>& effect, bool isalpha = false );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// A mesh consists of one or more model parts
|
||||||
|
class ModelMesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ModelMesh();
|
||||||
|
|
||||||
|
BoundingSphere boundingSphere;
|
||||||
|
BoundingBox boundingBox;
|
||||||
|
ModelMeshPart::Collection meshParts;
|
||||||
|
std::wstring name;
|
||||||
|
bool ccw;
|
||||||
|
bool pmalpha;
|
||||||
|
|
||||||
|
typedef std::vector<std::shared_ptr<ModelMesh>> Collection;
|
||||||
|
|
||||||
|
// Setup states for drawing mesh
|
||||||
|
void PrepareForRendering( _In_ ID3D11DeviceContext* deviceContext, CommonStates& states, bool alpha = false, bool wireframe = false ) const;
|
||||||
|
|
||||||
|
// Draw the mesh
|
||||||
|
void XM_CALLCONV Draw(_In_ ID3D11DeviceContext* deviceContext, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection,
|
||||||
|
bool alpha = false, _In_opt_ std::function<void()> setCustomState = nullptr ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// A model consists of one or more meshes
|
||||||
|
class Model
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ModelMesh::Collection meshes;
|
||||||
|
std::wstring name;
|
||||||
|
|
||||||
|
// Draw all the meshes in the model
|
||||||
|
void XM_CALLCONV Draw(_In_ ID3D11DeviceContext* deviceContext, CommonStates& states, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection,
|
||||||
|
bool wireframe = false, _In_opt_ std::function<void()> setCustomState = nullptr ) const;
|
||||||
|
|
||||||
|
// Notify model that effects, parts list, or mesh list has changed
|
||||||
|
void Modified() { mEffectCache.clear(); }
|
||||||
|
|
||||||
|
// Update all effects used by the model
|
||||||
|
void UpdateEffects( _In_ std::function<void(IEffect*)> setEffect );
|
||||||
|
|
||||||
|
// Loads a model from a Visual Studio Starter Kit .CMO file
|
||||||
|
static std::unique_ptr<Model> CreateFromCMO( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, size_t dataSize,
|
||||||
|
_In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false );
|
||||||
|
static std::unique_ptr<Model> CreateFromCMO( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false );
|
||||||
|
|
||||||
|
// Loads a model from a DirectX SDK .SDKMESH file
|
||||||
|
static std::unique_ptr<Model> CreateFromSDKMESH( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize,
|
||||||
|
_In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false );
|
||||||
|
static std::unique_ptr<Model> CreateFromSDKMESH( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false );
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::set<IEffect*> mEffectCache;
|
||||||
|
};
|
||||||
|
}
|
147
GUI/DirectXTK/PrimitiveBatch.h
Normal file
147
GUI/DirectXTK/PrimitiveBatch.h
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: PrimitiveBatch.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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4005)
|
||||||
|
#include <stdint.h>
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
namespace Internal
|
||||||
|
{
|
||||||
|
// Base class, not to be used directly: clients should access this via the derived PrimitiveBatch<T>.
|
||||||
|
class PrimitiveBatchBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
PrimitiveBatchBase(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize);
|
||||||
|
PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom);
|
||||||
|
PrimitiveBatchBase& operator= (PrimitiveBatchBase&& moveFrom);
|
||||||
|
virtual ~PrimitiveBatchBase();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Begin/End a batch of primitive drawing operations.
|
||||||
|
void Begin();
|
||||||
|
void End();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Internal, untyped drawing method.
|
||||||
|
void Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIndexed, _In_opt_count_(indexCount) uint16_t const* indices, size_t indexCount, size_t vertexCount, _Out_ void** pMappedVertices);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
PrimitiveBatchBase(PrimitiveBatchBase const&);
|
||||||
|
PrimitiveBatchBase& operator= (PrimitiveBatchBase const&);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Template makes the API typesafe, eg. PrimitiveBatch<VertexPositionColor>.
|
||||||
|
template<typename TVertex>
|
||||||
|
class PrimitiveBatch : public Internal::PrimitiveBatchBase
|
||||||
|
{
|
||||||
|
static const size_t DefaultBatchSize = 2048;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PrimitiveBatch(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices = DefaultBatchSize * 3, size_t maxVertices = DefaultBatchSize)
|
||||||
|
: PrimitiveBatchBase(deviceContext, maxIndices, maxVertices, sizeof(TVertex))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
PrimitiveBatch(PrimitiveBatch&& moveFrom)
|
||||||
|
: PrimitiveBatchBase(std::move(moveFrom))
|
||||||
|
{ }
|
||||||
|
|
||||||
|
PrimitiveBatch& operator= (PrimitiveBatch&& moveFrom)
|
||||||
|
{
|
||||||
|
PrimitiveBatchBase::operator=(std::move(moveFrom));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Similar to the D3D9 API DrawPrimitiveUP.
|
||||||
|
void Draw(D3D11_PRIMITIVE_TOPOLOGY topology, _In_reads_(vertexCount) TVertex const* vertices, size_t vertexCount)
|
||||||
|
{
|
||||||
|
void* mappedVertices;
|
||||||
|
|
||||||
|
PrimitiveBatchBase::Draw(topology, false, nullptr, 0, vertexCount, &mappedVertices);
|
||||||
|
|
||||||
|
memcpy(mappedVertices, vertices, vertexCount * sizeof(TVertex));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Similar to the D3D9 API DrawIndexedPrimitiveUP.
|
||||||
|
void DrawIndexed(D3D11_PRIMITIVE_TOPOLOGY topology, _In_reads_(indexCount) uint16_t const* indices, size_t indexCount, _In_reads_(vertexCount) TVertex const* vertices, size_t vertexCount)
|
||||||
|
{
|
||||||
|
void* mappedVertices;
|
||||||
|
|
||||||
|
PrimitiveBatchBase::Draw(topology, true, indices, indexCount, vertexCount, &mappedVertices);
|
||||||
|
|
||||||
|
memcpy(mappedVertices, vertices, vertexCount * sizeof(TVertex));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawLine(TVertex const& v1, TVertex const& v2)
|
||||||
|
{
|
||||||
|
TVertex* mappedVertices;
|
||||||
|
|
||||||
|
PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_LINELIST, false, nullptr, 0, 2, reinterpret_cast<void**>(&mappedVertices));
|
||||||
|
|
||||||
|
mappedVertices[0] = v1;
|
||||||
|
mappedVertices[1] = v2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawTriangle(TVertex const& v1, TVertex const& v2, TVertex const& v3)
|
||||||
|
{
|
||||||
|
TVertex* mappedVertices;
|
||||||
|
|
||||||
|
PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, false, nullptr, 0, 3, reinterpret_cast<void**>(&mappedVertices));
|
||||||
|
|
||||||
|
mappedVertices[0] = v1;
|
||||||
|
mappedVertices[1] = v2;
|
||||||
|
mappedVertices[2] = v3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawQuad(TVertex const& v1, TVertex const& v2, TVertex const& v3, TVertex const& v4)
|
||||||
|
{
|
||||||
|
static const uint16_t quadIndices[] = { 0, 1, 2, 0, 2, 3 };
|
||||||
|
|
||||||
|
TVertex* mappedVertices;
|
||||||
|
|
||||||
|
PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, true, quadIndices, 6, 4, reinterpret_cast<void**>(&mappedVertices));
|
||||||
|
|
||||||
|
mappedVertices[0] = v1;
|
||||||
|
mappedVertices[1] = v2;
|
||||||
|
mappedVertices[2] = v3;
|
||||||
|
mappedVertices[3] = v4;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
57
GUI/DirectXTK/ScreenGrab.h
Normal file
57
GUI/DirectXTK/ScreenGrab.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: ScreenGrab.h
|
||||||
|
//
|
||||||
|
// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot'
|
||||||
|
// when used on a Direct3D 11 Render Target).
|
||||||
|
//
|
||||||
|
// Note these functions are useful as a light-weight runtime screen grabber. For
|
||||||
|
// full-featured texture capture, DDS writer, and texture processing pipeline,
|
||||||
|
// see the 'Texconv' sample and the 'DirectXTex' library.
|
||||||
|
//
|
||||||
|
// 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=248926
|
||||||
|
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ocidl.h>
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4005)
|
||||||
|
#include <stdint.h>
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
HRESULT SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||||
|
_In_ ID3D11Resource* pSource,
|
||||||
|
_In_z_ LPCWSTR fileName );
|
||||||
|
|
||||||
|
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8)
|
||||||
|
|
||||||
|
HRESULT SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||||
|
_In_ ID3D11Resource* pSource,
|
||||||
|
_In_ REFGUID guidContainerFormat,
|
||||||
|
_In_z_ LPCWSTR fileName,
|
||||||
|
_In_opt_ const GUID* targetFormat = nullptr,
|
||||||
|
_In_opt_ std::function<void(IPropertyBag2*)> setCustomProps = nullptr );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
796
GUI/DirectXTK/SimpleMath.h
Normal file
796
GUI/DirectXTK/SimpleMath.h
Normal file
|
@ -0,0 +1,796 @@
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
// SimpleMath.h -- Simplified C++ Math wrapper for DirectXMath
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
|
#include "DirectXMath.h"
|
||||||
|
#include "DirectXPackedVector.h"
|
||||||
|
#include "DirectXCollision.h"
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace SimpleMath
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Vector4;
|
||||||
|
struct Matrix;
|
||||||
|
struct Quaternion;
|
||||||
|
struct Plane;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// 2D vector
|
||||||
|
struct Vector2 : public XMFLOAT2
|
||||||
|
{
|
||||||
|
Vector2() : XMFLOAT2(0.f, 0.f) {}
|
||||||
|
explicit Vector2(float x) : XMFLOAT2( x, x ) {}
|
||||||
|
Vector2(float _x, float _y) : XMFLOAT2(_x, _y) {}
|
||||||
|
explicit Vector2(_In_reads_(2) const float *pArray) : XMFLOAT2(pArray) {}
|
||||||
|
Vector2(FXMVECTOR V) { XMStoreFloat2( this, V ); }
|
||||||
|
|
||||||
|
operator XMVECTOR() const { return XMLoadFloat2( this ); }
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Vector2& V ) const;
|
||||||
|
bool operator != ( const Vector2& V ) const;
|
||||||
|
|
||||||
|
// Assignment operators
|
||||||
|
Vector2& operator= (const Vector2& V) { x = V.x; y = V.y; return *this; }
|
||||||
|
Vector2& operator+= (const Vector2& V);
|
||||||
|
Vector2& operator-= (const Vector2& V);
|
||||||
|
Vector2& operator*= (const Vector2& V);
|
||||||
|
Vector2& operator*= (float S);
|
||||||
|
Vector2& operator/= (float S);
|
||||||
|
|
||||||
|
// Urnary operators
|
||||||
|
Vector2 operator+ () const { return *this; }
|
||||||
|
Vector2 operator- () const { return Vector2(-x, -y); }
|
||||||
|
|
||||||
|
// Vector operations
|
||||||
|
bool InBounds( const Vector2& Bounds ) const;
|
||||||
|
|
||||||
|
float Length() const;
|
||||||
|
float LengthSquared() const;
|
||||||
|
|
||||||
|
float Dot( const Vector2& V ) const;
|
||||||
|
void Cross( const Vector2& V, Vector2& result ) const;
|
||||||
|
Vector2 Cross( const Vector2& V ) const;
|
||||||
|
|
||||||
|
void Normalize();
|
||||||
|
void Normalize( Vector2& result ) const;
|
||||||
|
|
||||||
|
void Clamp( const Vector2& vmin, const Vector2& vmax );
|
||||||
|
void Clamp( const Vector2& vmin, const Vector2& vmax, Vector2& result ) const;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static float Distance( const Vector2& v1, const Vector2& v2 );
|
||||||
|
static float DistanceSquared( const Vector2& v1, const Vector2& v2 );
|
||||||
|
|
||||||
|
static void Min( const Vector2& v1, const Vector2& v2, Vector2& result );
|
||||||
|
static Vector2 Min( const Vector2& v1, const Vector2& v2 );
|
||||||
|
|
||||||
|
static void Max( const Vector2& v1, const Vector2& v2, Vector2& result );
|
||||||
|
static Vector2 Max( const Vector2& v1, const Vector2& v2 );
|
||||||
|
|
||||||
|
static void Lerp( const Vector2& v1, const Vector2& v2, float t, Vector2& result );
|
||||||
|
static Vector2 Lerp( const Vector2& v1, const Vector2& v2, float t );
|
||||||
|
|
||||||
|
static void SmoothStep( const Vector2& v1, const Vector2& v2, float t, Vector2& result );
|
||||||
|
static Vector2 SmoothStep( const Vector2& v1, const Vector2& v2, float t );
|
||||||
|
|
||||||
|
static void Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g, Vector2& result );
|
||||||
|
static Vector2 Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g );
|
||||||
|
|
||||||
|
static void CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t, Vector2& result );
|
||||||
|
static Vector2 CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t );
|
||||||
|
|
||||||
|
static void Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t, Vector2& result );
|
||||||
|
static Vector2 Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t );
|
||||||
|
|
||||||
|
static void Reflect( const Vector2& ivec, const Vector2& nvec, Vector2& result );
|
||||||
|
static Vector2 Reflect( const Vector2& ivec, const Vector2& nvec );
|
||||||
|
|
||||||
|
static void Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex, Vector2& result );
|
||||||
|
static Vector2 Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex );
|
||||||
|
|
||||||
|
static void Transform( const Vector2& v, const Quaternion& quat, Vector2& result );
|
||||||
|
static Vector2 Transform( const Vector2& v, const Quaternion& quat );
|
||||||
|
|
||||||
|
static void Transform( const Vector2& v, const Matrix& m, Vector2& result );
|
||||||
|
static Vector2 Transform( const Vector2& v, const Matrix& m );
|
||||||
|
static void Transform( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector2* resultArray );
|
||||||
|
|
||||||
|
static void Transform( const Vector2& v, const Matrix& m, Vector4& result );
|
||||||
|
static void Transform( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray );
|
||||||
|
|
||||||
|
static void TransformNormal( const Vector2& v, const Matrix& m, Vector2& result );
|
||||||
|
static Vector2 TransformNormal( const Vector2& v, const Matrix& m );
|
||||||
|
static void TransformNormal( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector2* resultArray );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Binary operators
|
||||||
|
Vector2 operator+ (const Vector2& V1, const Vector2& V2);
|
||||||
|
Vector2 operator- (const Vector2& V1, const Vector2& V2);
|
||||||
|
Vector2 operator* (const Vector2& V1, const Vector2& V2);
|
||||||
|
Vector2 operator* (const Vector2& V, float S);
|
||||||
|
Vector2 operator/ (const Vector2& V1, const Vector2& V2);
|
||||||
|
Vector2 operator* (float S, const Vector2& V);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// 3D vector
|
||||||
|
struct Vector3 : public XMFLOAT3
|
||||||
|
{
|
||||||
|
Vector3() : XMFLOAT3(0.f, 0.f, 0.f) {}
|
||||||
|
explicit Vector3(float x) : XMFLOAT3( x, x, x ) {}
|
||||||
|
Vector3(float _x, float _y, float _z) : XMFLOAT3(_x, _y, _z) {}
|
||||||
|
explicit Vector3(_In_reads_(3) const float *pArray) : XMFLOAT3(pArray) {}
|
||||||
|
Vector3(FXMVECTOR V) { XMStoreFloat3( this, V ); }
|
||||||
|
|
||||||
|
operator XMVECTOR() const { return XMLoadFloat3( this ); }
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Vector3& V ) const;
|
||||||
|
bool operator != ( const Vector3& V ) const;
|
||||||
|
|
||||||
|
// Assignment operators
|
||||||
|
Vector3& operator= (const Vector3& V) { x = V.x; y = V.y; z = V.z; return *this; }
|
||||||
|
Vector3& operator+= (const Vector3& V);
|
||||||
|
Vector3& operator-= (const Vector3& V);
|
||||||
|
Vector3& operator*= (const Vector3& V);
|
||||||
|
Vector3& operator*= (float S);
|
||||||
|
Vector3& operator/= (float S);
|
||||||
|
|
||||||
|
// Urnary operators
|
||||||
|
Vector3 operator+ () const { return *this; }
|
||||||
|
Vector3 operator- () const;
|
||||||
|
|
||||||
|
// Vector operations
|
||||||
|
bool InBounds( const Vector3& Bounds ) const;
|
||||||
|
|
||||||
|
float Length() const;
|
||||||
|
float LengthSquared() const;
|
||||||
|
|
||||||
|
float Dot( const Vector3& V ) const;
|
||||||
|
void Cross( const Vector3& V, Vector3& result ) const;
|
||||||
|
Vector3 Cross( const Vector3& V ) const;
|
||||||
|
|
||||||
|
void Normalize();
|
||||||
|
void Normalize( Vector3& result ) const;
|
||||||
|
|
||||||
|
void Clamp( const Vector3& vmin, const Vector3& vmax );
|
||||||
|
void Clamp( const Vector3& vmin, const Vector3& vmax, Vector3& result ) const;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static float Distance( const Vector3& v1, const Vector3& v2 );
|
||||||
|
static float DistanceSquared( const Vector3& v1, const Vector3& v2 );
|
||||||
|
|
||||||
|
static void Min( const Vector3& v1, const Vector3& v2, Vector3& result );
|
||||||
|
static Vector3 Min( const Vector3& v1, const Vector3& v2 );
|
||||||
|
|
||||||
|
static void Max( const Vector3& v1, const Vector3& v2, Vector3& result );
|
||||||
|
static Vector3 Max( const Vector3& v1, const Vector3& v2 );
|
||||||
|
|
||||||
|
static void Lerp( const Vector3& v1, const Vector3& v2, float t, Vector3& result );
|
||||||
|
static Vector3 Lerp( const Vector3& v1, const Vector3& v2, float t );
|
||||||
|
|
||||||
|
static void SmoothStep( const Vector3& v1, const Vector3& v2, float t, Vector3& result );
|
||||||
|
static Vector3 SmoothStep( const Vector3& v1, const Vector3& v2, float t );
|
||||||
|
|
||||||
|
static void Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g, Vector3& result );
|
||||||
|
static Vector3 Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g );
|
||||||
|
|
||||||
|
static void CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t, Vector3& result );
|
||||||
|
static Vector3 CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t );
|
||||||
|
|
||||||
|
static void Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t, Vector3& result );
|
||||||
|
static Vector3 Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t );
|
||||||
|
|
||||||
|
static void Reflect( const Vector3& ivec, const Vector3& nvec, Vector3& result );
|
||||||
|
static Vector3 Reflect( const Vector3& ivec, const Vector3& nvec );
|
||||||
|
|
||||||
|
static void Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex, Vector3& result );
|
||||||
|
static Vector3 Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex );
|
||||||
|
|
||||||
|
static void Transform( const Vector3& v, const Quaternion& quat, Vector3& result );
|
||||||
|
static Vector3 Transform( const Vector3& v, const Quaternion& quat );
|
||||||
|
|
||||||
|
static void Transform( const Vector3& v, const Matrix& m, Vector3& result );
|
||||||
|
static Vector3 Transform( const Vector3& v, const Matrix& m );
|
||||||
|
static void Transform( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector3* resultArray );
|
||||||
|
|
||||||
|
static void Transform( const Vector3& v, const Matrix& m, Vector4& result );
|
||||||
|
static void Transform( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray );
|
||||||
|
|
||||||
|
static void TransformNormal( const Vector3& v, const Matrix& m, Vector3& result );
|
||||||
|
static Vector3 TransformNormal( const Vector3& v, const Matrix& m );
|
||||||
|
static void TransformNormal( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector3* resultArray );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Binary operators
|
||||||
|
Vector3 operator+ (const Vector3& V1, const Vector3& V2);
|
||||||
|
Vector3 operator- (const Vector3& V1, const Vector3& V2);
|
||||||
|
Vector3 operator* (const Vector3& V1, const Vector3& V2);
|
||||||
|
Vector3 operator* (const Vector3& V, float S);
|
||||||
|
Vector3 operator/ (const Vector3& V1, const Vector3& V2);
|
||||||
|
Vector3 operator* (float S, const Vector3& V);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// 4D vector
|
||||||
|
struct Vector4 : public XMFLOAT4
|
||||||
|
{
|
||||||
|
Vector4() : XMFLOAT4(0.f, 0.f, 0.f, 0.f) {}
|
||||||
|
explicit Vector4(float x) : XMFLOAT4( x, x, x, x ) {}
|
||||||
|
Vector4(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {}
|
||||||
|
explicit Vector4(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {}
|
||||||
|
Vector4(FXMVECTOR V) { XMStoreFloat4( this, V ); }
|
||||||
|
|
||||||
|
operator XMVECTOR() const { return XMLoadFloat4( this ); }
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Vector4& V ) const;
|
||||||
|
bool operator != ( const Vector4& V ) const;
|
||||||
|
|
||||||
|
// Assignment operators
|
||||||
|
Vector4& operator= (const Vector4& V) { x = V.x; y = V.y; z = V.z; w = V.w; return *this; }
|
||||||
|
Vector4& operator+= (const Vector4& V);
|
||||||
|
Vector4& operator-= (const Vector4& V);
|
||||||
|
Vector4& operator*= (const Vector4& V);
|
||||||
|
Vector4& operator*= (float S);
|
||||||
|
Vector4& operator/= (float S);
|
||||||
|
|
||||||
|
// Urnary operators
|
||||||
|
Vector4 operator+ () const { return *this; }
|
||||||
|
Vector4 operator- () const;
|
||||||
|
|
||||||
|
// Vector operations
|
||||||
|
bool InBounds( const Vector4& Bounds ) const;
|
||||||
|
|
||||||
|
float Length() const;
|
||||||
|
float LengthSquared() const;
|
||||||
|
|
||||||
|
float Dot( const Vector4& V ) const;
|
||||||
|
void Cross( const Vector4& v1, const Vector4& v2, Vector4& result ) const;
|
||||||
|
Vector4 Cross( const Vector4& v1, const Vector4& v2 ) const;
|
||||||
|
|
||||||
|
void Normalize();
|
||||||
|
void Normalize( Vector4& result ) const;
|
||||||
|
|
||||||
|
void Clamp( const Vector4& vmin, const Vector4& vmax );
|
||||||
|
void Clamp( const Vector4& vmin, const Vector4& vmax, Vector4& result ) const;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static float Distance( const Vector4& v1, const Vector4& v2 );
|
||||||
|
static float DistanceSquared( const Vector4& v1, const Vector4& v2 );
|
||||||
|
|
||||||
|
static void Min( const Vector4& v1, const Vector4& v2, Vector4& result );
|
||||||
|
static Vector4 Min( const Vector4& v1, const Vector4& v2 );
|
||||||
|
|
||||||
|
static void Max( const Vector4& v1, const Vector4& v2, Vector4& result );
|
||||||
|
static Vector4 Max( const Vector4& v1, const Vector4& v2 );
|
||||||
|
|
||||||
|
static void Lerp( const Vector4& v1, const Vector4& v2, float t, Vector4& result );
|
||||||
|
static Vector4 Lerp( const Vector4& v1, const Vector4& v2, float t );
|
||||||
|
|
||||||
|
static void SmoothStep( const Vector4& v1, const Vector4& v2, float t, Vector4& result );
|
||||||
|
static Vector4 SmoothStep( const Vector4& v1, const Vector4& v2, float t );
|
||||||
|
|
||||||
|
static void Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g, Vector4& result );
|
||||||
|
static Vector4 Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g );
|
||||||
|
|
||||||
|
static void CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t, Vector4& result );
|
||||||
|
static Vector4 CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t );
|
||||||
|
|
||||||
|
static void Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t, Vector4& result );
|
||||||
|
static Vector4 Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t );
|
||||||
|
|
||||||
|
static void Reflect( const Vector4& ivec, const Vector4& nvec, Vector4& result );
|
||||||
|
static Vector4 Reflect( const Vector4& ivec, const Vector4& nvec );
|
||||||
|
|
||||||
|
static void Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex, Vector4& result );
|
||||||
|
static Vector4 Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex );
|
||||||
|
|
||||||
|
static void Transform( const Vector2& v, const Quaternion& quat, Vector4& result );
|
||||||
|
static Vector4 Transform( const Vector2& v, const Quaternion& quat );
|
||||||
|
|
||||||
|
static void Transform( const Vector3& v, const Quaternion& quat, Vector4& result );
|
||||||
|
static Vector4 Transform( const Vector3& v, const Quaternion& quat );
|
||||||
|
|
||||||
|
static void Transform( const Vector4& v, const Quaternion& quat, Vector4& result );
|
||||||
|
static Vector4 Transform( const Vector4& v, const Quaternion& quat );
|
||||||
|
|
||||||
|
static void Transform( const Vector4& v, const Matrix& m, Vector4& result );
|
||||||
|
static Vector4 Transform( const Vector4& v, const Matrix& m );
|
||||||
|
static void Transform( _In_reads_(count) const Vector4* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Binary operators
|
||||||
|
Vector4 operator+ (const Vector4& V1, const Vector4& V2);
|
||||||
|
Vector4 operator- (const Vector4& V1, const Vector4& V2);
|
||||||
|
Vector4 operator* (const Vector4& V1, const Vector4& V2);
|
||||||
|
Vector4 operator* (const Vector4& V, float S);
|
||||||
|
Vector4 operator/ (const Vector4& V1, const Vector4& V2);
|
||||||
|
Vector4 operator* (float S, const Vector4& V);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// 4x4 Matrix (assumes right-handed cooordinates)
|
||||||
|
struct Matrix : public XMFLOAT4X4
|
||||||
|
{
|
||||||
|
Matrix() : XMFLOAT4X4( 1.f, 0, 0, 0,
|
||||||
|
0, 1.f, 0, 0,
|
||||||
|
0, 0, 1.f, 0,
|
||||||
|
0, 0, 0, 1.f ) {}
|
||||||
|
Matrix(float m00, float m01, float m02, float m03,
|
||||||
|
float m10, float m11, float m12, float m13,
|
||||||
|
float m20, float m21, float m22, float m23,
|
||||||
|
float m30, float m31, float m32, float m33) : XMFLOAT4X4(m00, m01, m02, m03,
|
||||||
|
m10, m11, m12, m13,
|
||||||
|
m20, m21, m22, m23,
|
||||||
|
m30, m31, m32, m33) {}
|
||||||
|
explicit Matrix( const Vector3& r0, const Vector3& r1, const Vector3& r2 ) : XMFLOAT4X4( r0.x, r0.y, r0.z, 0,
|
||||||
|
r1.x, r1.y, r1.z, 0,
|
||||||
|
r2.x, r2.y, r2.z, 0,
|
||||||
|
0, 0, 0, 1.f ) {}
|
||||||
|
explicit Matrix( const Vector4& r0, const Vector4& r1, const Vector4& r2, const Vector4& r3 ) : XMFLOAT4X4( r0.x, r0.y, r0.z, r0.w,
|
||||||
|
r1.x, r1.y, r1.z, r1.w,
|
||||||
|
r2.x, r2.y, r2.z, r2.w,
|
||||||
|
r3.x, r3.y, r3.z, r3.w ) {}
|
||||||
|
explicit Matrix(_In_reads_(16) const float *pArray) : XMFLOAT4X4(pArray) {}
|
||||||
|
Matrix( CXMMATRIX M ) { XMStoreFloat4x4( this, M ); }
|
||||||
|
|
||||||
|
operator XMMATRIX() const { return XMLoadFloat4x4( this ); }
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Matrix& M ) const;
|
||||||
|
bool operator != ( const Matrix& M ) const;
|
||||||
|
|
||||||
|
// Assignment operators
|
||||||
|
Matrix& operator= (const Matrix& M) { memcpy_s( this, sizeof(float)*16, &M, sizeof(float)*16); return *this; }
|
||||||
|
Matrix& operator+= (const Matrix& M);
|
||||||
|
Matrix& operator-= (const Matrix& M);
|
||||||
|
Matrix& operator*= (const Matrix& M);
|
||||||
|
Matrix& operator*= (float S);
|
||||||
|
Matrix& operator/= (float S);
|
||||||
|
|
||||||
|
Matrix& operator/= (const Matrix& M);
|
||||||
|
// Element-wise divide
|
||||||
|
|
||||||
|
// Urnary operators
|
||||||
|
Matrix operator+ () const { return *this; }
|
||||||
|
Matrix operator- () const;
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
Vector3 Up() const { return Vector3( _21, _22, _23); }
|
||||||
|
void Up( const Vector3& v ) { _21 = v.x; _22 = v.y; _23 = v.z; }
|
||||||
|
|
||||||
|
Vector3 Down() const { return Vector3( -_21, -_22, -_23); }
|
||||||
|
void Down( const Vector3& v ) { _21 = -v.x; _22 = -v.y; _23 = -v.z; }
|
||||||
|
|
||||||
|
Vector3 Right() const { return Vector3( _11, _12, _13 ); }
|
||||||
|
void Right( const Vector3& v ) { _11 = v.x; _12 = v.y; _13 = v.z; }
|
||||||
|
|
||||||
|
Vector3 Left() const { return Vector3( -_11, -_12, -_13 ); }
|
||||||
|
void Left( const Vector3& v ) { _11 = -v.x; _12 = -v.y; _13 = -v.z; }
|
||||||
|
|
||||||
|
Vector3 Forward() const { return Vector3( -_31, -_32, -_33 ); }
|
||||||
|
void Forward( const Vector3& v ) { _31 = -v.x; _32 = -v.y; _33 = -v.z; }
|
||||||
|
|
||||||
|
Vector3 Backward() const { return Vector3( _31, _32, _33 ); }
|
||||||
|
void Backward( const Vector3& v ) { _31 = v.x; _32 = v.y; _33 = v.z; }
|
||||||
|
|
||||||
|
Vector3 Translation() const { return Vector3( _41, _42, _43 ); }
|
||||||
|
void Translation( const Vector3& v ) { _41 = v.x; _42 = v.y; _43 = v.z; }
|
||||||
|
|
||||||
|
// Matrix operations
|
||||||
|
bool Decompose( Vector3& scale, Quaternion& rotation, Vector3& translation );
|
||||||
|
|
||||||
|
Matrix Transpose() const;
|
||||||
|
void Transpose( Matrix& result ) const;
|
||||||
|
|
||||||
|
Matrix Invert() const;
|
||||||
|
void Invert( Matrix& result ) const;
|
||||||
|
|
||||||
|
float Determinant() const;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static Matrix Identity();
|
||||||
|
|
||||||
|
static Matrix CreateTranslation( const Vector3& position );
|
||||||
|
static Matrix CreateTranslation( float x, float y, float z );
|
||||||
|
|
||||||
|
static Matrix CreateScale( const Vector3& scales );
|
||||||
|
static Matrix CreateScale( float xs, float ys, float zs );
|
||||||
|
static Matrix CreateScale( float scale );
|
||||||
|
|
||||||
|
static Matrix CreateRotationX( float radians );
|
||||||
|
static Matrix CreateRotationY( float radians );
|
||||||
|
static Matrix CreateRotationZ( float radians );
|
||||||
|
|
||||||
|
static Matrix CreateFromAxisAngle( const Vector3& axis, float angle );
|
||||||
|
|
||||||
|
static Matrix CreatePerspectiveFieldOfView( float fov, float aspectRatio, float nearPlane, float farPlane );
|
||||||
|
static Matrix CreatePerspective( float width, float height, float nearPlane, float farPlane );
|
||||||
|
static Matrix CreatePerspectiveOffCenter( float left, float right, float bottom, float top, float nearPlane, float farPlane );
|
||||||
|
static Matrix CreateOrthographic( float width, float height, float zNearPlane, float zFarPlane );
|
||||||
|
static Matrix CreateOrthographicOffCenter( float left, float right, float bottom, float top, float zNearPlane, float zFarPlane );
|
||||||
|
|
||||||
|
static Matrix CreateLookAt( const Vector3& position, const Vector3& target, const Vector3& up );
|
||||||
|
static Matrix CreateWorld( const Vector3& position, const Vector3& forward, const Vector3& up );
|
||||||
|
|
||||||
|
static Matrix CreateFromQuaternion( const Quaternion& quat );
|
||||||
|
|
||||||
|
static Matrix CreateFromYawPitchRoll( float yaw, float pitch, float roll );
|
||||||
|
|
||||||
|
static Matrix CreateShadow( const Vector3& lightDir, const Plane& plane );
|
||||||
|
|
||||||
|
static Matrix CreateReflection( const Plane& plane );
|
||||||
|
|
||||||
|
static void Lerp( const Matrix& M1, const Matrix& M2, float t, Matrix& result );
|
||||||
|
static Matrix Lerp( const Matrix& M1, const Matrix& M2, float t );
|
||||||
|
|
||||||
|
static void Transform( const Matrix& M, const Quaternion& rotation, Matrix& result );
|
||||||
|
static Matrix Transform( const Matrix& M, const Quaternion& rotation );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Binary operators
|
||||||
|
Matrix operator+ (const Matrix& M1, const Matrix& M2);
|
||||||
|
Matrix operator- (const Matrix& M1, const Matrix& M2);
|
||||||
|
Matrix operator* (const Matrix& M1, const Matrix& M2);
|
||||||
|
Matrix operator* (const Matrix& M, float S);
|
||||||
|
Matrix operator/ (const Matrix& M, float S);
|
||||||
|
Matrix operator/ (const Matrix& M1, const Matrix& M2);
|
||||||
|
// Element-wise divide
|
||||||
|
Matrix operator* (float S, const Matrix& M);
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Plane
|
||||||
|
struct Plane : public XMFLOAT4
|
||||||
|
{
|
||||||
|
Plane() : XMFLOAT4(0.f, 1.f, 0.f, 0.f) {}
|
||||||
|
Plane(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {}
|
||||||
|
Plane(const Vector3& normal, float d) : XMFLOAT4(normal.x, normal.y, normal.z, d) {}
|
||||||
|
Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3 );
|
||||||
|
Plane(const Vector3& point, const Vector3& normal);
|
||||||
|
explicit Plane(const Vector4& v) : XMFLOAT4(v.x, v.y, v.z, v.w) {}
|
||||||
|
explicit Plane(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {}
|
||||||
|
Plane(FXMVECTOR V) { XMStoreFloat4( this, V ); }
|
||||||
|
|
||||||
|
operator XMVECTOR() const { return XMLoadFloat4( this ); }
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Plane& p ) const;
|
||||||
|
bool operator != ( const Plane& p ) const;
|
||||||
|
|
||||||
|
// Assignment operators
|
||||||
|
Plane& operator= (const Plane& p) { x = p.x; y = p.y; z = p.z; w = p.w; return *this; }
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
Vector3 Normal() const { return Vector3( x, y, z ); }
|
||||||
|
void Normal( const Vector3& normal ) { x = normal.x; y = normal.y; z = normal.z; }
|
||||||
|
|
||||||
|
float D() const { return w; }
|
||||||
|
void D(float d) { w = d; }
|
||||||
|
|
||||||
|
// Plane operations
|
||||||
|
void Normalize();
|
||||||
|
void Normalize( Plane& result ) const;
|
||||||
|
|
||||||
|
float Dot( const Vector4& v ) const;
|
||||||
|
float DotCoordinate( const Vector3& position ) const;
|
||||||
|
float DotNormal( const Vector3& normal ) const;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static void Transform( const Plane& plane, const Matrix& M, Plane& result );
|
||||||
|
static Plane Transform( const Plane& plane, const Matrix& M );
|
||||||
|
|
||||||
|
static void Transform( const Plane& plane, const Quaternion& rotation, Plane& result );
|
||||||
|
static Plane Transform( const Plane& plane, const Quaternion& rotation );
|
||||||
|
// Input quaternion must be the inverse transpose of the transformation
|
||||||
|
};
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Quaternion
|
||||||
|
struct Quaternion : public XMFLOAT4
|
||||||
|
{
|
||||||
|
Quaternion() : XMFLOAT4(0, 0, 0, 1.f) {}
|
||||||
|
Quaternion( float _x, float _y, float _z, float _w ) : XMFLOAT4(_x, _y, _z, _w) {}
|
||||||
|
Quaternion( const Vector3& v, float scalar ) : XMFLOAT4( v.x, v.y, v.z, scalar ) {}
|
||||||
|
explicit Quaternion( const Vector4& v ) : XMFLOAT4( v.x, v.y, v.z, v.w ) {}
|
||||||
|
explicit Quaternion(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {}
|
||||||
|
Quaternion(FXMVECTOR V) { XMStoreFloat4( this, V ); }
|
||||||
|
|
||||||
|
operator XMVECTOR() const { return XMLoadFloat4( this ); }
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Quaternion& q ) const;
|
||||||
|
bool operator != ( const Quaternion& q ) const;
|
||||||
|
|
||||||
|
// Assignment operators
|
||||||
|
Quaternion& operator= (const Quaternion& q) { x = q.x; y = q.y; z = q.z; w = q.w; return *this; }
|
||||||
|
Quaternion& operator+= (const Quaternion& q);
|
||||||
|
Quaternion& operator-= (const Quaternion& q);
|
||||||
|
Quaternion& operator*= (const Quaternion& q);
|
||||||
|
Quaternion& operator*= (float S);
|
||||||
|
Quaternion& operator/= (const Quaternion& q);
|
||||||
|
|
||||||
|
// Urnary operators
|
||||||
|
Quaternion operator+ () const { return *this; }
|
||||||
|
Quaternion operator- () const;
|
||||||
|
|
||||||
|
// Quaternion operations
|
||||||
|
float Length() const;
|
||||||
|
float LengthSquared() const;
|
||||||
|
|
||||||
|
void Normalize();
|
||||||
|
void Normalize( Quaternion& result ) const;
|
||||||
|
|
||||||
|
void Conjugate();
|
||||||
|
void Conjugate( Quaternion& result ) const;
|
||||||
|
|
||||||
|
void Inverse( Quaternion& result ) const;
|
||||||
|
|
||||||
|
float Dot( const Quaternion& Q ) const;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static Quaternion CreateFromAxisAngle( const Vector3& axis, float angle );
|
||||||
|
static Quaternion CreateFromYawPitchRoll( float yaw, float pitch, float roll );
|
||||||
|
static Quaternion CreateFromRotationMatrix( const Matrix& M );
|
||||||
|
|
||||||
|
static void Lerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result );
|
||||||
|
static Quaternion Lerp( const Quaternion& q1, const Quaternion& q2, float t );
|
||||||
|
|
||||||
|
static void Slerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result );
|
||||||
|
static Quaternion Slerp( const Quaternion& q1, const Quaternion& q2, float t );
|
||||||
|
|
||||||
|
static void Concatenate( const Quaternion& q1, const Quaternion& q2, Quaternion& result );
|
||||||
|
static Quaternion Concatenate( const Quaternion& q1, const Quaternion& q2 );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Binary operators
|
||||||
|
Quaternion operator+ (const Quaternion& Q1, const Quaternion& Q2);
|
||||||
|
Quaternion operator- (const Quaternion& Q1, const Quaternion& Q2);
|
||||||
|
Quaternion operator* (const Quaternion& Q1, const Quaternion& Q2);
|
||||||
|
Quaternion operator* (const Quaternion& Q, float S);
|
||||||
|
Quaternion operator/ (const Quaternion& Q1, const Quaternion& Q2);
|
||||||
|
Quaternion operator* (float S, const Quaternion& Q);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Color
|
||||||
|
struct Color : public XMFLOAT4
|
||||||
|
{
|
||||||
|
Color() : XMFLOAT4(0, 0, 0, 1.f) {}
|
||||||
|
Color( float _r, float _g, float _b ) : XMFLOAT4(_r, _g, _b, 1.f) {}
|
||||||
|
Color( float _r, float _g, float _b, float _a ) : XMFLOAT4(_r, _g, _b, _a) {}
|
||||||
|
explicit Color( const Vector3& clr ) : XMFLOAT4( clr.x, clr.y, clr.z, 1.f ) {}
|
||||||
|
explicit Color( const Vector4& clr ) : XMFLOAT4( clr.x, clr.y, clr.z, clr.w ) {}
|
||||||
|
explicit Color(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {}
|
||||||
|
Color(FXMVECTOR V) { XMStoreFloat4( this, V ); }
|
||||||
|
|
||||||
|
explicit Color( const DirectX::PackedVector::XMCOLOR& Packed );
|
||||||
|
// BGRA Direct3D 9 D3DCOLOR packed color
|
||||||
|
|
||||||
|
explicit Color( const DirectX::PackedVector::XMUBYTEN4& Packed );
|
||||||
|
// RGBA XNA Game Studio packed color
|
||||||
|
|
||||||
|
operator XMVECTOR() const { return XMLoadFloat4( this ); }
|
||||||
|
operator const float*() const { return reinterpret_cast<const float*>(this); }
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Color& c ) const;
|
||||||
|
bool operator != ( const Color& c ) const;
|
||||||
|
|
||||||
|
// Assignment operators
|
||||||
|
Color& operator= (const Color& c) { x = c.x; y = c.y; z = c.z; w = c.w; return *this; }
|
||||||
|
Color& operator+= (const Color& c);
|
||||||
|
Color& operator-= (const Color& c);
|
||||||
|
Color& operator*= (const Color& c);
|
||||||
|
Color& operator*= (float S);
|
||||||
|
Color& operator/= (const Color& c);
|
||||||
|
|
||||||
|
// Urnary operators
|
||||||
|
Color operator+ () const { return *this; }
|
||||||
|
Color operator- () const;
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
float R() const { return x; }
|
||||||
|
void R(float r) { x = r; }
|
||||||
|
|
||||||
|
float G() const { return y; }
|
||||||
|
void G(float g) { y = g; }
|
||||||
|
|
||||||
|
float B() const { return z; }
|
||||||
|
void B(float b) { z = b; }
|
||||||
|
|
||||||
|
float A() const { return w; }
|
||||||
|
void A(float a) { w = a; }
|
||||||
|
|
||||||
|
// Color operations
|
||||||
|
DirectX::PackedVector::XMCOLOR BGRA() const;
|
||||||
|
DirectX::PackedVector::XMUBYTEN4 RGBA() const;
|
||||||
|
|
||||||
|
Vector3 ToVector3() const;
|
||||||
|
Vector4 ToVector4() const;
|
||||||
|
|
||||||
|
void Negate();
|
||||||
|
void Negate( Color& result ) const;
|
||||||
|
|
||||||
|
void Saturate();
|
||||||
|
void Saturate( Color& result ) const;
|
||||||
|
|
||||||
|
void Premultiply();
|
||||||
|
void Premultiply( Color& result ) const;
|
||||||
|
|
||||||
|
void AdjustSaturation( float sat );
|
||||||
|
void AdjustSaturation( float sat, Color& result ) const;
|
||||||
|
|
||||||
|
void AdjustContrast( float contrast );
|
||||||
|
void AdjustContrast( float contrast, Color& result ) const;
|
||||||
|
|
||||||
|
// Static functions
|
||||||
|
static void Modulate( const Color& c1, const Color& c2, Color& result );
|
||||||
|
static Color Modulate( const Color& c1, const Color& c2 );
|
||||||
|
|
||||||
|
static void Lerp( const Color& c1, const Color& c2, float t, Color& result );
|
||||||
|
static Color Lerp( const Color& c1, const Color& c2, float t );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Binary operators
|
||||||
|
Color operator+ (const Color& C1, const Color& C2);
|
||||||
|
Color operator- (const Color& C1, const Color& C2);
|
||||||
|
Color operator* (const Color& C1, const Color& C2);
|
||||||
|
Color operator* (const Color& C, float S);
|
||||||
|
Color operator/ (const Color& C1, const Color& C2);
|
||||||
|
Color operator* (float S, const Color& C);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Ray
|
||||||
|
class Ray
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Vector3 position;
|
||||||
|
Vector3 direction;
|
||||||
|
|
||||||
|
Ray() : position(0,0,0), direction(0,0,1) {}
|
||||||
|
Ray( const Vector3& pos, const Vector3& dir ) : position(pos), direction(dir) {}
|
||||||
|
|
||||||
|
// Comparision operators
|
||||||
|
bool operator == ( const Ray& r ) const;
|
||||||
|
bool operator != ( const Ray& r ) const;
|
||||||
|
|
||||||
|
// Ray operations
|
||||||
|
bool Intersects( const BoundingSphere& sphere, _Out_ float& Dist ) const;
|
||||||
|
bool Intersects( const BoundingBox& box, _Out_ float& Dist ) const;
|
||||||
|
bool Intersects( const Vector3& tri0, const Vector3& tri1, const Vector3& tri2, _Out_ float& Dist ) const;
|
||||||
|
bool Intersects( const Plane& plane, _Out_ float& Dist ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "SimpleMath.inl"
|
||||||
|
|
||||||
|
}; // namespace SimpleMath
|
||||||
|
|
||||||
|
}; // namespace DirectX
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Support for SimpleMath and Standard C++ Library containers
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Vector2>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Vector2& V1, const DirectX::SimpleMath::Vector2& V2) const
|
||||||
|
{
|
||||||
|
return ( (V1.x < V2.x) || ((V1.x == V2.x) && (V1.y < V2.y)) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Vector3>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Vector3& V1, const DirectX::SimpleMath::Vector3& V2) const
|
||||||
|
{
|
||||||
|
return ( (V1.x < V2.x)
|
||||||
|
|| ((V1.x == V2.x) && (V1.y < V2.y))
|
||||||
|
|| ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z < V2.z)) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Vector4>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Vector4& V1, const DirectX::SimpleMath::Vector4& V2) const
|
||||||
|
{
|
||||||
|
return ( (V1.x < V2.x)
|
||||||
|
|| ((V1.x == V2.x) && (V1.y < V2.y))
|
||||||
|
|| ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z < V2.z))
|
||||||
|
|| ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z) && (V1.w < V2.w)) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Matrix>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Matrix& M1, const DirectX::SimpleMath::Matrix& M2) const
|
||||||
|
{
|
||||||
|
if (M1._11 != M2._11) return M1._11 < M2._11;
|
||||||
|
if (M1._12 != M2._12) return M1._12 < M2._12;
|
||||||
|
if (M1._13 != M2._13) return M1._13 < M2._13;
|
||||||
|
if (M1._14 != M2._14) return M1._14 < M2._14;
|
||||||
|
if (M1._21 != M2._21) return M1._21 < M2._21;
|
||||||
|
if (M1._22 != M2._22) return M1._22 < M2._22;
|
||||||
|
if (M1._23 != M2._23) return M1._23 < M2._23;
|
||||||
|
if (M1._24 != M2._24) return M1._24 < M2._24;
|
||||||
|
if (M1._31 != M2._31) return M1._31 < M2._31;
|
||||||
|
if (M1._32 != M2._32) return M1._32 < M2._32;
|
||||||
|
if (M1._33 != M2._33) return M1._33 < M2._33;
|
||||||
|
if (M1._34 != M2._34) return M1._34 < M2._34;
|
||||||
|
if (M1._41 != M2._41) return M1._41 < M2._41;
|
||||||
|
if (M1._42 != M2._42) return M1._42 < M2._42;
|
||||||
|
if (M1._43 != M2._43) return M1._43 < M2._43;
|
||||||
|
if (M1._44 != M2._44) return M1._44 < M2._44;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Plane>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Plane& P1, const DirectX::SimpleMath::Plane& P2) const
|
||||||
|
{
|
||||||
|
return ( (P1.x < P2.x)
|
||||||
|
|| ((P1.x == P2.x) && (P1.y < P2.y))
|
||||||
|
|| ((P1.x == P2.x) && (P1.y == P2.y) && (P1.z < P2.z))
|
||||||
|
|| ((P1.x == P2.x) && (P1.y == P2.y) && (P1.z == P2.z) && (P1.w < P2.w)) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Quaternion>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Quaternion& Q1, const DirectX::SimpleMath::Quaternion& Q2) const
|
||||||
|
{
|
||||||
|
return ( (Q1.x < Q2.x)
|
||||||
|
|| ((Q1.x == Q2.x) && (Q1.y < Q2.y))
|
||||||
|
|| ((Q1.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z < Q2.z))
|
||||||
|
|| ((Q1.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z == Q2.z) && (Q1.w < Q2.w)) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Color>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Color& C1, const DirectX::SimpleMath::Color& C2) const
|
||||||
|
{
|
||||||
|
return ( (C1.x < C2.x)
|
||||||
|
|| ((C1.x == C2.x) && (C1.y < C2.y))
|
||||||
|
|| ((C1.x == C2.x) && (C1.y == C2.y) && (C1.z < C2.z))
|
||||||
|
|| ((C1.x == C2.x) && (C1.y == C2.y) && (C1.z == C2.z) && (C1.w < C2.w)) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct less<DirectX::SimpleMath::Ray>
|
||||||
|
{
|
||||||
|
bool operator()(const DirectX::SimpleMath::Ray& R1, const DirectX::SimpleMath::Ray& R2) const
|
||||||
|
{
|
||||||
|
if (R1.position.x != R2.position.x) return R1.position.x < R2.position.x;
|
||||||
|
if (R1.position.y != R2.position.y) return R1.position.y < R2.position.y;
|
||||||
|
if (R1.position.z != R2.position.z) return R1.position.z < R2.position.z;
|
||||||
|
|
||||||
|
if (R1.direction.x != R2.direction.x) return R1.direction.x < R2.direction.x;
|
||||||
|
if (R1.direction.y != R2.direction.y) return R1.direction.y < R2.direction.y;
|
||||||
|
if (R1.direction.z != R2.direction.z) return R1.direction.z < R2.direction.z;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
3303
GUI/DirectXTK/SimpleMath.inl
Normal file
3303
GUI/DirectXTK/SimpleMath.inl
Normal file
File diff suppressed because it is too large
Load diff
98
GUI/DirectXTK/SpriteBatch.h
Normal file
98
GUI/DirectXTK/SpriteBatch.h
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// 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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
#include <DirectXColors.h>
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
#if (DIRECTXMATH_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<void()> setCustomShaders = nullptr, FXMMATRIX transformMatrix = MatrixIdentity);
|
||||||
|
void 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 SetRotation( DXGI_MODE_ROTATION mode );
|
||||||
|
DXGI_MODE_ROTATION GetRotation() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
static const XMMATRIX MatrixIdentity;
|
||||||
|
static const XMFLOAT2 Float2Zero;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
SpriteBatch(SpriteBatch const&);
|
||||||
|
SpriteBatch& operator= (SpriteBatch const&);
|
||||||
|
};
|
||||||
|
}
|
73
GUI/DirectXTK/SpriteFont.h
Normal file
73
GUI/DirectXTK/SpriteFont.h
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: SpriteFont.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 "SpriteBatch.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
class SpriteFont
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Glyph;
|
||||||
|
|
||||||
|
SpriteFont(_In_ ID3D11Device* device, _In_z_ wchar_t const* fileName);
|
||||||
|
SpriteFont(_In_ ID3D11Device* device, _In_reads_bytes_(dataSize) uint8_t const* dataBlob, _In_ size_t dataSize);
|
||||||
|
SpriteFont(_In_ ID3D11ShaderResourceView* texture, _In_reads_(glyphCount) Glyph const* glyphs, _In_ size_t glyphCount, _In_ float lineSpacing);
|
||||||
|
|
||||||
|
SpriteFont(SpriteFont&& moveFrom);
|
||||||
|
SpriteFont& operator= (SpriteFont&& moveFrom);
|
||||||
|
virtual ~SpriteFont();
|
||||||
|
|
||||||
|
void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0);
|
||||||
|
void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0);
|
||||||
|
void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color = Colors::White, float rotation = 0, FXMVECTOR origin = g_XMZero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0);
|
||||||
|
void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0);
|
||||||
|
|
||||||
|
XMVECTOR MeasureString(_In_z_ wchar_t const* text) const;
|
||||||
|
|
||||||
|
float GetLineSpacing() const;
|
||||||
|
void SetLineSpacing(float spacing);
|
||||||
|
|
||||||
|
wchar_t GetDefaultCharacter() const;
|
||||||
|
void SetDefaultCharacter(wchar_t character);
|
||||||
|
|
||||||
|
bool ContainsCharacter(wchar_t character) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Describes a single character glyph.
|
||||||
|
struct Glyph
|
||||||
|
{
|
||||||
|
uint32_t Character;
|
||||||
|
RECT Subrect;
|
||||||
|
float XOffset;
|
||||||
|
float YOffset;
|
||||||
|
float XAdvance;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation.
|
||||||
|
class Impl;
|
||||||
|
|
||||||
|
std::unique_ptr<Impl> pImpl;
|
||||||
|
|
||||||
|
static const XMFLOAT2 Float2Zero;
|
||||||
|
|
||||||
|
// Prevent copying.
|
||||||
|
SpriteFont(SpriteFont const&);
|
||||||
|
SpriteFont& operator= (SpriteFont const&);
|
||||||
|
};
|
||||||
|
}
|
331
GUI/DirectXTK/VertexTypes.h
Normal file
331
GUI/DirectXTK/VertexTypes.h
Normal file
|
@ -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) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
#if (DIRECTXMATH_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 SetColor( XMFLOAT4 const& color ) { SetColor( XMLoadFloat4( &color ) ); }
|
||||||
|
void XM_CALLCONV SetColor( FXMVECTOR color );
|
||||||
|
|
||||||
|
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 SetBlendIndices( XMUINT4 const& indices );
|
||||||
|
|
||||||
|
void SetBlendWeights( XMFLOAT4 const& weights ) { SetBlendWeights( XMLoadFloat4( &weights ) ); }
|
||||||
|
void XM_CALLCONV SetBlendWeights( FXMVECTOR weights );
|
||||||
|
|
||||||
|
static const int InputElementCount = 7;
|
||||||
|
static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount];
|
||||||
|
};
|
||||||
|
}
|
136
GUI/DirectXTK/WICTextureLoader.h
Normal file
136
GUI/DirectXTK/WICTextureLoader.h
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: WICTextureLoader.h
|
||||||
|
//
|
||||||
|
// Function for loading a WIC image and creating a Direct3D 11 runtime texture for it
|
||||||
|
// (auto-generating mipmaps if possible)
|
||||||
|
//
|
||||||
|
// Note: Assumes application has already called CoInitializeEx
|
||||||
|
//
|
||||||
|
// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for
|
||||||
|
// auto-gen mipmap support.
|
||||||
|
//
|
||||||
|
// Note these functions are useful for images created as simple 2D textures. For
|
||||||
|
// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader.
|
||||||
|
// For a full-featured DDS file reader, writer, and texture processing pipeline see
|
||||||
|
// the 'Texconv' sample and the 'DirectXTex' library.
|
||||||
|
//
|
||||||
|
// 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=248926
|
||||||
|
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (_WIN32_WINNT <= _WIN32_WINNT_WIN8)
|
||||||
|
#error WIC is not supported on Windows Phone 8.0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4005)
|
||||||
|
#include <stdint.h>
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
namespace DirectX
|
||||||
|
{
|
||||||
|
// Standard version
|
||||||
|
HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||||
|
_In_ size_t wicDataSize,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
// Standard version with optional auto-gen mipmap support
|
||||||
|
HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||||
|
_In_ size_t wicDataSize,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
// Extended version
|
||||||
|
HRESULT CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||||
|
_In_ size_t wicDataSize,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||||
|
);
|
||||||
|
|
||||||
|
// Extended version with optional auto-gen mipmap support
|
||||||
|
HRESULT CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||||
|
_In_ size_t wicDataSize,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Out_opt_ ID3D11Resource** texture,
|
||||||
|
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||||
|
);
|
||||||
|
}
|
69
GUI/DirectXTK/XboxDDSTextureLoader.h
Normal file
69
GUI/DirectXTK/XboxDDSTextureLoader.h
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: XboxDDSTextureLoader.h
|
||||||
|
//
|
||||||
|
// Functions for loading a DDS texture using the XBOX extended header and creating a
|
||||||
|
// Direct3D11.X runtime resource for it via the CreatePlacement APIs
|
||||||
|
//
|
||||||
|
// Note these functions will not load standard DDS files. Use the DDSTextureLoader
|
||||||
|
// module in the DirectXTex package or as part of the DirectXTK library to load
|
||||||
|
// these files which use standard Direct3D 11 resource creation APIs.
|
||||||
|
//
|
||||||
|
// 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=248926
|
||||||
|
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_XBOX_ONE) || !defined(_TITLE)
|
||||||
|
#error This module only supports Xbox One exclusive apps
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE) && MONOLITHIC
|
||||||
|
#include <d3d11_x.h>
|
||||||
|
#else
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace Xbox
|
||||||
|
{
|
||||||
|
enum DDS_ALPHA_MODE
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
|
HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device1* d3dDevice,
|
||||||
|
_In_ ID3DXboxPerformanceDevice* perfDevice,
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Outptr_ void** grfxMemory,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
|
||||||
|
_In_ bool forceSRGB = false
|
||||||
|
);
|
||||||
|
|
||||||
|
HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device1* d3dDevice,
|
||||||
|
_In_ ID3DXboxPerformanceDevice* perfDevice,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Outptr_ void** grfxMemory,
|
||||||
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
|
||||||
|
_In_ bool forceSRGB = false
|
||||||
|
);
|
||||||
|
}
|
BIN
GUI/GUI.ico
Normal file
BIN
GUI/GUI.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
GUI/GUI.rc
Normal file
BIN
GUI/GUI.rc
Normal file
Binary file not shown.
149
GUI/GUI.vcxproj
Normal file
149
GUI/GUI.vcxproj
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{6675D943-322A-4045-B16C-4756FD32CAF2}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>GUI</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v120</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<LibraryPath>$(ProjectDir)\DirectXTK;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>NESEmu</TargetName>
|
||||||
|
<LibraryPath>$(ProjectDir)\DirectXTK;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>DirectXTK.lib;d3d11.lib;d3dcompiler.lib;dxguid.lib;winmm.lib;comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<FxCompile>
|
||||||
|
<DisableOptimizations>false</DisableOptimizations>
|
||||||
|
</FxCompile>
|
||||||
|
<FxCompile>
|
||||||
|
<EnableDebuggingInformation>false</EnableDebuggingInformation>
|
||||||
|
</FxCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>DirectXTK.lib;d3d11.lib;d3dcompiler.lib;dxguid.lib;winmm.lib;comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<FxCompile>
|
||||||
|
<ShaderType>
|
||||||
|
</ShaderType>
|
||||||
|
<ShaderModel>4.0_level_9_1</ShaderModel>
|
||||||
|
</FxCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="DirectXTK\Audio.h" />
|
||||||
|
<ClInclude Include="DirectXTK\CommonStates.h" />
|
||||||
|
<ClInclude Include="DirectXTK\DDSTextureLoader.h" />
|
||||||
|
<ClInclude Include="DirectXTK\DirectXHelpers.h" />
|
||||||
|
<ClInclude Include="DirectXTK\Effects.h" />
|
||||||
|
<ClInclude Include="DirectXTK\GeometricPrimitive.h" />
|
||||||
|
<ClInclude Include="DirectXTK\Model.h" />
|
||||||
|
<ClInclude Include="DirectXTK\PrimitiveBatch.h" />
|
||||||
|
<ClInclude Include="DirectXTK\ScreenGrab.h" />
|
||||||
|
<ClInclude Include="DirectXTK\SimpleMath.h" />
|
||||||
|
<ClInclude Include="DirectXTK\SpriteBatch.h" />
|
||||||
|
<ClInclude Include="DirectXTK\SpriteFont.h" />
|
||||||
|
<ClInclude Include="DirectXTK\VertexTypes.h" />
|
||||||
|
<ClInclude Include="DirectXTK\WICTextureLoader.h" />
|
||||||
|
<ClInclude Include="DirectXTK\XboxDDSTextureLoader.h" />
|
||||||
|
<ClInclude Include="Renderer.h" />
|
||||||
|
<ClInclude Include="Resource.h" />
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
<ClInclude Include="MainWindow.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="Renderer.cpp" />
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="MainWindow.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="GUI.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="GUI.ico" />
|
||||||
|
<Image Include="small.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Core\Core.vcxproj">
|
||||||
|
<Project>{78fef1a1-6df1-4cbb-a373-ae6fa7ce5ce0}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="DirectXTK\SimpleMath.inl" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader.fx">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
</FxCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
122
GUI/GUI.vcxproj.filters
Normal file
122
GUI/GUI.vcxproj.filters
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\DirectXTK">
|
||||||
|
<UniqueIdentifier>{e3fb11e9-60dd-47df-8444-72d62eb07828}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Shaders">
|
||||||
|
<UniqueIdentifier>{ac76b5fc-ef73-414c-a9c5-a67ea8c3ed57}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="MainWindow.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Renderer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\Audio.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\CommonStates.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\DDSTextureLoader.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\DirectXHelpers.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\Effects.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\GeometricPrimitive.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\Model.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\PrimitiveBatch.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Resource.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\ScreenGrab.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\SimpleMath.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\SpriteBatch.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\SpriteFont.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\VertexTypes.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\WICTextureLoader.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="DirectXTK\XboxDDSTextureLoader.h">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="MainWindow.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Renderer.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="GUI.rc">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="small.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
<Image Include="GUI.ico">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="DirectXTK\SimpleMath.inl">
|
||||||
|
<Filter>Header Files\DirectXTK</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<FxCompile Include="Shader.fx">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</FxCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
155
GUI/MainWindow.cpp
Normal file
155
GUI/MainWindow.cpp
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
#include "..\Core\CPU.h"
|
||||||
|
#include "..\Core\Timer.h"
|
||||||
|
using namespace DirectX;
|
||||||
|
|
||||||
|
namespace NES
|
||||||
|
{
|
||||||
|
bool MainWindow::Initialize()
|
||||||
|
{
|
||||||
|
if(FAILED(InitWindow())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!_renderer.Initialize(_hInstance, _hWnd)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MainWindow::Run()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
|
||||||
|
MSG msg = { 0 };
|
||||||
|
Timer timer;
|
||||||
|
int frameCount = 0;
|
||||||
|
while(WM_QUIT != msg.message) {
|
||||||
|
if(PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
} else {
|
||||||
|
_renderer.Render();
|
||||||
|
frameCount++;
|
||||||
|
if(frameCount == 500) {
|
||||||
|
double fps = (double)frameCount / (timer.GetElapsedMS() / 1000);
|
||||||
|
OutputDebugString((std::to_wstring((int)fps) + L"\n").c_str());
|
||||||
|
timer.Reset();
|
||||||
|
frameCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(50));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)msg.wParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Register class and create window
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT MainWindow::InitWindow()
|
||||||
|
{
|
||||||
|
// Register class
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wcex.lpfnWndProc = WndProc;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = _hInstance;
|
||||||
|
wcex.hIcon = LoadIcon(_hInstance, (LPCTSTR)IDI_GUI);
|
||||||
|
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||||
|
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_GUI);
|
||||||
|
wcex.lpszClassName = L"NESEmu";
|
||||||
|
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
|
||||||
|
if(!RegisterClassEx(&wcex))
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
// Create window
|
||||||
|
RECT rc = { 0, 0, 320, 240 };
|
||||||
|
AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
|
_hWnd = CreateWindow(L"NESEmu", L"NESEmu",
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, _hInstance,
|
||||||
|
nullptr);
|
||||||
|
if(!_hWnd) {
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(_hWnd, _nCmdShow);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT_PTR CALLBACK MainWindow::About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (INT_PTR)FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::RunBenchmark()
|
||||||
|
{
|
||||||
|
std::thread bmThread(&CPU::RunBenchmark);
|
||||||
|
bmThread.detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
int wmId, wmEvent;
|
||||||
|
HDC hdc;
|
||||||
|
|
||||||
|
switch(message) {
|
||||||
|
case WM_COMMAND:
|
||||||
|
wmId = LOWORD(wParam);
|
||||||
|
wmEvent = HIWORD(wParam);
|
||||||
|
// Parse the menu selections:
|
||||||
|
switch (wmId)
|
||||||
|
{
|
||||||
|
case IDM_RunBenchmark:
|
||||||
|
RunBenchmark();
|
||||||
|
break;
|
||||||
|
case IDM_ABOUT:
|
||||||
|
DialogBox(nullptr, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
||||||
|
break;
|
||||||
|
case IDM_EXIT:
|
||||||
|
DestroyWindow(hWnd);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WM_PAINT:
|
||||||
|
hdc = BeginPaint(hWnd, &ps);
|
||||||
|
EndPaint(hWnd, &ps);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
24
GUI/MainWindow.h
Normal file
24
GUI/MainWindow.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
namespace NES {
|
||||||
|
class MainWindow
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
HINSTANCE _hInstance;
|
||||||
|
HWND _hWnd;
|
||||||
|
int _nCmdShow;
|
||||||
|
Renderer _renderer;
|
||||||
|
|
||||||
|
bool Initialize();
|
||||||
|
HRESULT InitWindow();
|
||||||
|
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
static INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
static void RunBenchmark();
|
||||||
|
|
||||||
|
public:
|
||||||
|
MainWindow(HINSTANCE hInstance, int nCmdShow) : _hInstance(hInstance), _nCmdShow(nCmdShow) { }
|
||||||
|
int Run();
|
||||||
|
};
|
||||||
|
}
|
282
GUI/Renderer.cpp
Normal file
282
GUI/Renderer.cpp
Normal file
|
@ -0,0 +1,282 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
#include "DirectXTK\SpriteBatch.h"
|
||||||
|
|
||||||
|
namespace NES
|
||||||
|
{
|
||||||
|
bool Renderer::Initialize(HINSTANCE hInstance, HWND hWnd) {
|
||||||
|
_hInst = hInstance;
|
||||||
|
_hWnd = hWnd;
|
||||||
|
|
||||||
|
if(FAILED(InitDevice())) {
|
||||||
|
CleanupDevice();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Helper for compiling shaders with D3DCompile
|
||||||
|
//
|
||||||
|
// With VS 11, we could load up prebuilt .cso files instead...
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT Renderer::CompileShaderFromFile(WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
|
||||||
|
#if defined( DEBUG ) || defined( _DEBUG )
|
||||||
|
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
|
||||||
|
// Setting this flag improves the shader debugging experience, but still allows
|
||||||
|
// the shaders to be optimized and to run exactly the way they will run in
|
||||||
|
// the release configuration of this program.
|
||||||
|
dwShaderFlags |= D3DCOMPILE_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ID3DBlob* pErrorBlob = nullptr;
|
||||||
|
hr = D3DCompileFromFile(szFileName, nullptr, nullptr, szEntryPoint, szShaderModel,
|
||||||
|
dwShaderFlags, 0, ppBlobOut, &pErrorBlob);
|
||||||
|
if(FAILED(hr)) {
|
||||||
|
if(pErrorBlob) {
|
||||||
|
OutputDebugStringA(reinterpret_cast<const char*>(pErrorBlob->GetBufferPointer()));
|
||||||
|
pErrorBlob->Release();
|
||||||
|
}
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
if(pErrorBlob) pErrorBlob->Release();
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Create Direct3D device and swap chain
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
HRESULT Renderer::InitDevice()
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
RECT rc;
|
||||||
|
GetClientRect(_hWnd, &rc);
|
||||||
|
UINT width = rc.right - rc.left;
|
||||||
|
UINT height = rc.bottom - rc.top;
|
||||||
|
|
||||||
|
UINT createDeviceFlags = 0;
|
||||||
|
#ifdef _DEBUG
|
||||||
|
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
D3D_DRIVER_TYPE driverTypes[] =
|
||||||
|
{
|
||||||
|
D3D_DRIVER_TYPE_HARDWARE,
|
||||||
|
D3D_DRIVER_TYPE_WARP,
|
||||||
|
D3D_DRIVER_TYPE_REFERENCE,
|
||||||
|
};
|
||||||
|
UINT numDriverTypes = ARRAYSIZE(driverTypes);
|
||||||
|
|
||||||
|
D3D_FEATURE_LEVEL featureLevels[] =
|
||||||
|
{
|
||||||
|
D3D_FEATURE_LEVEL_11_1,
|
||||||
|
D3D_FEATURE_LEVEL_11_0,
|
||||||
|
D3D_FEATURE_LEVEL_10_1,
|
||||||
|
D3D_FEATURE_LEVEL_10_0,
|
||||||
|
};
|
||||||
|
UINT numFeatureLevels = ARRAYSIZE(featureLevels);
|
||||||
|
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
|
sd.BufferCount = 1;
|
||||||
|
sd.BufferDesc.Width = width;
|
||||||
|
sd.BufferDesc.Height = height;
|
||||||
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
sd.BufferDesc.RefreshRate.Numerator = 60;
|
||||||
|
sd.BufferDesc.RefreshRate.Denominator = 1;
|
||||||
|
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd.OutputWindow = _hWnd;
|
||||||
|
sd.SampleDesc.Count = 1;
|
||||||
|
sd.SampleDesc.Quality = 0;
|
||||||
|
sd.Windowed = TRUE;
|
||||||
|
|
||||||
|
for(UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++) {
|
||||||
|
_driverType = driverTypes[driverTypeIndex];
|
||||||
|
hr = D3D11CreateDeviceAndSwapChain(nullptr, _driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels,
|
||||||
|
D3D11_SDK_VERSION, &sd, &_pSwapChain, &_pd3dDevice, &_featureLevel, &_pImmediateContext);
|
||||||
|
|
||||||
|
if(hr == E_INVALIDARG) {
|
||||||
|
// DirectX 11.0 platforms will not recognize D3D_FEATURE_LEVEL_11_1 so we need to retry without it
|
||||||
|
hr = D3D11CreateDeviceAndSwapChain(nullptr, _driverType, nullptr, createDeviceFlags, &featureLevels[1], numFeatureLevels - 1,
|
||||||
|
D3D11_SDK_VERSION, &sd, &_pSwapChain, &_pd3dDevice, &_featureLevel, &_pImmediateContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SUCCEEDED(hr)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(FAILED(hr)) {
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain the Direct3D 11.1 versions if available
|
||||||
|
hr = _pd3dDevice->QueryInterface(__uuidof(ID3D11Device1), reinterpret_cast<void**>(&_pd3dDevice1));
|
||||||
|
if(SUCCEEDED(hr)) {
|
||||||
|
(void)_pImmediateContext->QueryInterface(__uuidof(ID3D11DeviceContext1), reinterpret_cast<void**>(&_pImmediateContext1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a render target view
|
||||||
|
ID3D11Texture2D* pBackBuffer = nullptr;
|
||||||
|
hr = _pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
|
||||||
|
if(FAILED(hr)) {
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = _pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &_pRenderTargetView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
if(FAILED(hr)) {
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pImmediateContext->OMSetRenderTargets(1, &_pRenderTargetView, nullptr);
|
||||||
|
|
||||||
|
// Setup the viewport
|
||||||
|
UINT fred;
|
||||||
|
D3D11_VIEWPORT vp;
|
||||||
|
vp.Width = (FLOAT)width;
|
||||||
|
vp.Height = (FLOAT)height;
|
||||||
|
vp.MinDepth = 0.0f;
|
||||||
|
vp.MaxDepth = 1.0f;
|
||||||
|
vp.TopLeftX = 0;
|
||||||
|
vp.TopLeftY = 0;
|
||||||
|
_pImmediateContext->RSSetViewports(1, &vp);
|
||||||
|
|
||||||
|
_pd3dDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 16, &fred);
|
||||||
|
|
||||||
|
uint16_t screenwidth = 320;
|
||||||
|
uint16_t screenheight = 240;
|
||||||
|
|
||||||
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
|
ZeroMemory(&desc, sizeof(D3D11_TEXTURE2D_DESC));
|
||||||
|
desc.ArraySize = 1;
|
||||||
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
desc.MipLevels = 1;
|
||||||
|
desc.MiscFlags = 0;
|
||||||
|
desc.SampleDesc.Count = 1;
|
||||||
|
desc.SampleDesc.Quality = fred;
|
||||||
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
|
desc.Width = screenwidth;
|
||||||
|
desc.Height = screenheight;
|
||||||
|
desc.MiscFlags = 0;
|
||||||
|
|
||||||
|
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDescription;
|
||||||
|
ZeroMemory(&renderTargetViewDescription, sizeof(renderTargetViewDescription));
|
||||||
|
renderTargetViewDescription.Format = desc.Format;
|
||||||
|
renderTargetViewDescription.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; // MS;
|
||||||
|
|
||||||
|
_videoRAM = new byte[screenwidth*screenheight * 4];
|
||||||
|
memset(_videoRAM, 0xFF, screenwidth*screenheight);
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA tbsd;
|
||||||
|
tbsd.pSysMem = (void *)_videoRAM;
|
||||||
|
tbsd.SysMemPitch = screenwidth * 4;
|
||||||
|
tbsd.SysMemSlicePitch = screenwidth*screenheight * 4; // Not needed since this is a 2d texture
|
||||||
|
|
||||||
|
if(FAILED(_pd3dDevice->CreateTexture2D(&desc, &tbsd, &_pTexture))) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
_sprites.reset(new SpriteBatch(_pImmediateContext));
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Clean up the objects we've created
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
void Renderer::CleanupDevice()
|
||||||
|
{
|
||||||
|
if(_pImmediateContext) _pImmediateContext->ClearState();
|
||||||
|
|
||||||
|
if(_pVertexBuffer) _pVertexBuffer->Release();
|
||||||
|
if(_pVertexLayout) _pVertexLayout->Release();
|
||||||
|
if(_pVertexShader) _pVertexShader->Release();
|
||||||
|
if(_pPixelShader) _pPixelShader->Release();
|
||||||
|
if(_pRenderTargetView) _pRenderTargetView->Release();
|
||||||
|
if(_pSwapChain) _pSwapChain->Release();
|
||||||
|
if(_pImmediateContext1) _pImmediateContext1->Release();
|
||||||
|
if(_pImmediateContext) _pImmediateContext->Release();
|
||||||
|
if(_pd3dDevice1) _pd3dDevice1->Release();
|
||||||
|
if(_pd3dDevice) _pd3dDevice->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Render a frame
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
void Renderer::Render()
|
||||||
|
{
|
||||||
|
// Clear the back buffer
|
||||||
|
_pImmediateContext->ClearRenderTargetView(_pRenderTargetView, Colors::MidnightBlue);
|
||||||
|
|
||||||
|
// Render a triangle
|
||||||
|
/*_pImmediateContext->VSSetShader(_pVertexShader, nullptr, 0);
|
||||||
|
_pImmediateContext->PSSetShader(_pPixelShader, nullptr, 0);
|
||||||
|
_pImmediateContext->Draw(3, 0);*/
|
||||||
|
|
||||||
|
UINT screenwidth = 320, screenheight = 240;
|
||||||
|
|
||||||
|
if(rand() % 15 == 0) {
|
||||||
|
for(int i = 0; i < screenwidth*screenheight * 4; i++) {
|
||||||
|
_videoRAM[i] += rand() % 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
D3D11_MAPPED_SUBRESOURCE dd;
|
||||||
|
dd.pData = (void *)_videoRAM;
|
||||||
|
dd.RowPitch = screenwidth * 4;
|
||||||
|
dd.DepthPitch = screenwidth* screenheight * 4;
|
||||||
|
|
||||||
|
_pImmediateContext->Map(_pTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &dd);
|
||||||
|
|
||||||
|
memcpy(dd.pData, _videoRAM, screenwidth*screenheight * 4);
|
||||||
|
|
||||||
|
|
||||||
|
_pImmediateContext->Unmap(_pTexture, 0);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||||
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
|
D3D11_RESOURCE_DIMENSION type;
|
||||||
|
_pTexture->GetType(&type);
|
||||||
|
_pTexture->GetDesc(&desc);
|
||||||
|
srvDesc.Format = desc.Format;
|
||||||
|
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
|
srvDesc.Texture2D.MipLevels = desc.MipLevels;
|
||||||
|
srvDesc.Texture2D.MostDetailedMip = desc.MipLevels - 1;
|
||||||
|
|
||||||
|
ID3D11ShaderResourceView *pSRView = NULL;
|
||||||
|
_pd3dDevice->CreateShaderResourceView(_pTexture, &srvDesc, &pSRView);
|
||||||
|
|
||||||
|
|
||||||
|
D3D11_RENDER_TARGET_VIEW_DESC rtDesc;
|
||||||
|
rtDesc.Format = desc.Format;
|
||||||
|
rtDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||||
|
rtDesc.Texture2D.MipSlice = 0;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
_sprites->Begin();
|
||||||
|
RECT x;
|
||||||
|
x.left = 0;
|
||||||
|
x.right = 320;
|
||||||
|
x.bottom = 240;
|
||||||
|
x.top = 0;
|
||||||
|
_sprites->Draw(pSRView, x);
|
||||||
|
_sprites->End();
|
||||||
|
|
||||||
|
// Present the information rendered to the back buffer to the front buffer (the screen)
|
||||||
|
_pSwapChain->Present(0, 0);
|
||||||
|
}
|
||||||
|
}
|
44
GUI/Renderer.h
Normal file
44
GUI/Renderer.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "DirectXTK\SpriteBatch.h"
|
||||||
|
|
||||||
|
using namespace DirectX;
|
||||||
|
|
||||||
|
namespace NES {
|
||||||
|
struct SimpleVertex
|
||||||
|
{
|
||||||
|
XMFLOAT3 Pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Renderer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
HINSTANCE _hInst = nullptr;
|
||||||
|
HWND _hWnd = nullptr;
|
||||||
|
|
||||||
|
D3D_DRIVER_TYPE _driverType = D3D_DRIVER_TYPE_NULL;
|
||||||
|
D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0;
|
||||||
|
ID3D11Device* _pd3dDevice = nullptr;
|
||||||
|
ID3D11Device1* _pd3dDevice1 = nullptr;
|
||||||
|
ID3D11DeviceContext* _pImmediateContext = nullptr;
|
||||||
|
ID3D11DeviceContext1* _pImmediateContext1 = nullptr;
|
||||||
|
IDXGISwapChain* _pSwapChain = nullptr;
|
||||||
|
ID3D11RenderTargetView* _pRenderTargetView = nullptr;
|
||||||
|
ID3D11VertexShader* _pVertexShader = nullptr;
|
||||||
|
ID3D11PixelShader* _pPixelShader = nullptr;
|
||||||
|
ID3D11InputLayout* _pVertexLayout = nullptr;
|
||||||
|
ID3D11Buffer* _pVertexBuffer = nullptr;
|
||||||
|
ID3D11Texture2D* _pTexture = nullptr;
|
||||||
|
|
||||||
|
byte* _videoRAM;
|
||||||
|
//SpriteBatch* _sprites;
|
||||||
|
std::unique_ptr<SpriteBatch> _sprites;
|
||||||
|
|
||||||
|
HRESULT Renderer::CompileShaderFromFile(WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut);
|
||||||
|
HRESULT Renderer::InitDevice();
|
||||||
|
void Renderer::CleanupDevice();
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool Initialize(HINSTANCE hInst, HWND hWnd);
|
||||||
|
void Render();
|
||||||
|
};
|
||||||
|
}
|
22
GUI/Shader.fx
Normal file
22
GUI/Shader.fx
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// File: Tutorial02.fx
|
||||||
|
//
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Vertex Shader
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
float4 VS( float4 Pos : POSITION ) : SV_POSITION
|
||||||
|
{
|
||||||
|
return Pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Pixel Shader
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
float4 PS( float4 Pos : SV_POSITION ) : SV_Target
|
||||||
|
{
|
||||||
|
return float4( 1.0f, 1.0f, 0.0f, 1.0f ); // Yellow, with Alpha = 1
|
||||||
|
}
|
14
GUI/main.cpp
Normal file
14
GUI/main.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Entry point to the program. Initializes everything and goes into a message processing
|
||||||
|
// loop. Idle time is used to render the scene.
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
|
||||||
|
{
|
||||||
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
|
||||||
|
return NES::MainWindow(hInstance, nCmdShow).Run();
|
||||||
|
}
|
BIN
GUI/resource.h
Normal file
BIN
GUI/resource.h
Normal file
Binary file not shown.
BIN
GUI/small.ico
Normal file
BIN
GUI/small.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
8
GUI/stdafx.cpp
Normal file
8
GUI/stdafx.cpp
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
|
// GUI.pch will be the pre-compiled header
|
||||||
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: reference any additional headers you need in STDAFX.H
|
||||||
|
// and not in this file
|
25
GUI/stdafx.h
Normal file
25
GUI/stdafx.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently, but
|
||||||
|
// are changed infrequently
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
// Windows Header Files:
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
// C RunTime Header Files
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
#include <d3d11_1.h>
|
||||||
|
#include <d3dcompiler.h>
|
||||||
|
#include <directxmath.h>
|
||||||
|
#include <directxcolors.h>
|
||||||
|
|
||||||
|
// TODO: reference additional headers your program requires here
|
8
GUI/targetver.h
Normal file
8
GUI/targetver.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||||
|
|
||||||
|
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||||
|
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
11
NES.sln
11
NES.sln
|
@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 2013
|
# Visual Studio 2013
|
||||||
VisualStudioVersion = 12.0.30501.0
|
VisualStudioVersion = 12.0.30501.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core.vcxproj", "{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core\Core.vcxproj", "{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GUI", "GUI\GUI.vcxproj", "{6675D943-322A-4045-B16C-4756FD32CAF2}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0} = {78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -15,6 +20,10 @@ Global
|
||||||
{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}.Debug|Win32.Build.0 = Debug|Win32
|
{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}.Release|Win32.ActiveCfg = Release|Win32
|
{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}.Release|Win32.Build.0 = Release|Win32
|
{78FEF1A1-6DF1-4CBB-A373-AE6FA7CE5CE0}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{6675D943-322A-4045-B16C-4756FD32CAF2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{6675D943-322A-4045-B16C-4756FD32CAF2}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{6675D943-322A-4045-B16C-4756FD32CAF2}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{6675D943-322A-4045-B16C-4756FD32CAF2}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
40
ReadMe.txt
40
ReadMe.txt
|
@ -1,40 +0,0 @@
|
||||||
========================================================================
|
|
||||||
CONSOLE APPLICATION : ConsoleApplication1 Project Overview
|
|
||||||
========================================================================
|
|
||||||
|
|
||||||
AppWizard has created this ConsoleApplication1 application for you.
|
|
||||||
|
|
||||||
This file contains a summary of what you will find in each of the files that
|
|
||||||
make up your ConsoleApplication1 application.
|
|
||||||
|
|
||||||
|
|
||||||
ConsoleApplication1.vcxproj
|
|
||||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the version of Visual C++ that generated the file, and
|
|
||||||
information about the platforms, configurations, and project features selected with the
|
|
||||||
Application Wizard.
|
|
||||||
|
|
||||||
ConsoleApplication1.vcxproj.filters
|
|
||||||
This is the filters file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the association between the files in your project
|
|
||||||
and the filters. This association is used in the IDE to show grouping of files with
|
|
||||||
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
|
|
||||||
"Source Files" filter).
|
|
||||||
|
|
||||||
ConsoleApplication1.cpp
|
|
||||||
This is the main application source file.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Other standard files:
|
|
||||||
|
|
||||||
StdAfx.h, StdAfx.cpp
|
|
||||||
These files are used to build a precompiled header (PCH) file
|
|
||||||
named ConsoleApplication1.pch and a precompiled types file named StdAfx.obj.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Other notes:
|
|
||||||
|
|
||||||
AppWizard uses "TODO:" comments to indicate parts of the source code you
|
|
||||||
should add to or customize.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
|
@ -1 +0,0 @@
|
||||||
#include "stdafx.h"
|
|
Loading…
Add table
Reference in a new issue