Commit cefa68f1 authored by Clark Lin's avatar Clark Lin
Browse files

Merge branch 'study' into 'main'

merge up to "add bindables and drawables"

See merge request !1
parents 90937151 42c3decc
#pragma once
// HRESULT hr should exist in the local scope for these macros to work
#define GFX_EXCEPT_NOINFO(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_NOINFO(hrcall) if( FAILED( hr = (hrcall) ) ) throw Graphics::HrException( __LINE__,__FILE__,hr )
#ifndef NDEBUG
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO(hrcall) infoManager.Set(); if( FAILED( hr = (hrcall) ) ) throw GFX_EXCEPT(hr)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO_ONLY(call) infoManager.Set(); (call); {auto v = infoManager.GetMessages(); if(!v.empty()) {throw Graphics::InfoException( __LINE__,__FILE__,v);}}
#else
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO(hrcall) GFX_THROW_NOINFO(hrcall)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO_ONLY(call) (call)
#endif
// macro for importing infomanager into local scope
// this.GetInfoManager(Graphics gfx) must exist
#ifdef NDEBUG
#define INFOMAN(gfx) HRESULT hr
#else
#define INFOMAN(gfx) HRESULT hr; DxgiInfoManager& infoManager = GetInfoManager(gfx)
#endif
#include "IndexBuffer.h"
#include "GraphicsThrowMacros.h"
IndexBuffer::IndexBuffer( Graphics& gfx,const std::vector<unsigned short>& indices )
:
count( (UINT)indices.size() )
{
INFOMAN( gfx );
D3D11_BUFFER_DESC ibd = {};
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
ibd.Usage = D3D11_USAGE_DEFAULT;
ibd.CPUAccessFlags = 0u;
ibd.MiscFlags = 0u;
ibd.ByteWidth = UINT( count * sizeof( unsigned short ) );
ibd.StructureByteStride = sizeof( unsigned short );
D3D11_SUBRESOURCE_DATA isd = {};
isd.pSysMem = indices.data();
GFX_THROW_INFO( GetDevice( gfx )->CreateBuffer( &ibd,&isd,&pIndexBuffer ) );
}
void IndexBuffer::Bind( Graphics& gfx ) noexcept
{
GetContext( gfx )->IASetIndexBuffer( pIndexBuffer.Get(),DXGI_FORMAT_R16_UINT,0u );
}
UINT IndexBuffer::GetCount() const noexcept
{
return count;
}
#pragma once
#include "Bindable.h"
class IndexBuffer : public Bindable
{
public:
IndexBuffer( Graphics& gfx,const std::vector<unsigned short>& indices );
void Bind( Graphics& gfx ) noexcept override;
UINT GetCount() const noexcept;
protected:
UINT count;
Microsoft::WRL::ComPtr<ID3D11Buffer> pIndexBuffer;
};
\ No newline at end of file
#include "InputLayout.h"
#include "GraphicsThrowMacros.h"
InputLayout::InputLayout( Graphics& gfx,
const std::vector<D3D11_INPUT_ELEMENT_DESC>& layout,
ID3DBlob* pVertexShaderBytecode )
{
INFOMAN( gfx );
GFX_THROW_INFO( GetDevice( gfx )->CreateInputLayout(
layout.data(),(UINT)layout.size(),
pVertexShaderBytecode->GetBufferPointer(),
pVertexShaderBytecode->GetBufferSize(),
&pInputLayout
) );
}
void InputLayout::Bind( Graphics& gfx ) noexcept
{
GetContext( gfx )->IASetInputLayout( pInputLayout.Get() );
}
#pragma once
#include "Bindable.h"
class InputLayout : public Bindable
{
public:
InputLayout( Graphics& gfx,
const std::vector<D3D11_INPUT_ELEMENT_DESC>& layout,
ID3DBlob* pVertexShaderBytecode );
void Bind( Graphics& gfx ) noexcept override;
protected:
Microsoft::WRL::ComPtr<ID3D11InputLayout> pInputLayout;
};
\ No newline at end of file
/******************************************************************************************
* Chili Direct3D Engine *
* Copyright 2018 PlanetChili <http://www.planetchili.net> *
* *
* This file is part of Chili Direct3D Engine. *
* *
* Chili Direct3D Engine is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* The Chili Direct3D Engine is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with The Chili Direct3D Engine. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#include "Keyboard.h"
bool Keyboard::KeyIsPressed( unsigned char keycode ) const noexcept
{
return keystates[keycode];
}
Keyboard::Event Keyboard::ReadKey() noexcept
{
if( keybuffer.size() > 0u )
{
Keyboard::Event e = keybuffer.front();
keybuffer.pop();
return e;
}
else
{
return Keyboard::Event();
}
}
bool Keyboard::KeyIsEmpty() const noexcept
{
return keybuffer.empty();
}
char Keyboard::ReadChar() noexcept
{
if( charbuffer.size() > 0u )
{
unsigned char charcode = charbuffer.front();
charbuffer.pop();
return charcode;
}
else
{
return 0;
}
}
bool Keyboard::CharIsEmpty() const noexcept
{
return charbuffer.empty();
}
void Keyboard::FlushKey() noexcept
{
keybuffer = std::queue<Event>();
}
void Keyboard::FlushChar() noexcept
{
charbuffer = std::queue<char>();
}
void Keyboard::Flush() noexcept
{
FlushKey();
FlushChar();
}
void Keyboard::EnableAutorepeat() noexcept
{
autorepeatEnabled = true;
}
void Keyboard::DisableAutorepeat() noexcept
{
autorepeatEnabled = false;
}
bool Keyboard::AutorepeatIsEnabled() const noexcept
{
return autorepeatEnabled;
}
void Keyboard::OnKeyPressed( unsigned char keycode ) noexcept
{
keystates[keycode] = true;
keybuffer.push( Keyboard::Event( Keyboard::Event::Type::Press,keycode ) );
TrimBuffer( keybuffer );
}
void Keyboard::OnKeyReleased( unsigned char keycode ) noexcept
{
keystates[keycode] = false;
keybuffer.push( Keyboard::Event( Keyboard::Event::Type::Release,keycode ) );
TrimBuffer( keybuffer );
}
void Keyboard::OnChar( char character ) noexcept
{
charbuffer.push( character );
TrimBuffer( charbuffer );
}
void Keyboard::ClearState() noexcept
{
keystates.reset();
}
template<typename T>
void Keyboard::TrimBuffer( std::queue<T>& buffer ) noexcept
{
while( buffer.size() > bufferSize )
{
buffer.pop();
}
}
/******************************************************************************************
* Chili Direct3D Engine *
* Copyright 2018 PlanetChili <http://www.planetchili.net> *
* *
* This file is part of Chili Direct3D Engine. *
* *
* Chili Direct3D Engine is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* The Chili Direct3D Engine is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with The Chili Direct3D Engine. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#pragma once
#include <queue>
#include <bitset>
class Keyboard
{
friend class Window;
public:
class Event
{
public:
enum class Type
{
Press,
Release,
Invalid
};
private:
Type type;
unsigned char code;
public:
Event() noexcept
:
type( Type::Invalid ),
code( 0u )
{}
Event( Type type,unsigned char code ) noexcept
:
type( type ),
code( code )
{}
bool IsPress() const noexcept
{
return type == Type::Press;
}
bool IsRelease() const noexcept
{
return type == Type::Release;
}
bool IsValid() const noexcept
{
return type != Type::Invalid;
}
unsigned char GetCode() const noexcept
{
return code;
}
};
public:
Keyboard() = default;
// 单例设计
Keyboard( const Keyboard& ) = delete;
// 单例设计
Keyboard& operator=( const Keyboard& ) = delete;
// key event stuff
// 根据bitset keystates中指定Key的状态
bool KeyIsPressed( unsigned char keycode ) const noexcept;
// 从keyBuffer队列中找到最前面的Event,取出并移出队列
Event ReadKey() noexcept;
// 检查keyBuffer队列是否为空
bool KeyIsEmpty() const noexcept;
// 重置keyBuffer队列
void FlushKey() noexcept;
// char event stuff
// 从charBuff队列中找到最前面的Event,取出并移出队列
char ReadChar() noexcept;
// 检查charBuffer队列是否为空
bool CharIsEmpty() const noexcept;
// 重置charBuffer队列
void FlushChar() noexcept;
// 重置keyBuffer和charBuffer队列
void Flush() noexcept;
// autorepeat control
void EnableAutorepeat() noexcept;
void DisableAutorepeat() noexcept;
bool AutorepeatIsEnabled() const noexcept;
private:
void OnKeyPressed( unsigned char keycode ) noexcept;
void OnKeyReleased( unsigned char keycode ) noexcept;
void OnChar( char character ) noexcept;
void ClearState() noexcept;
template<typename T>
static void TrimBuffer( std::queue<T>& buffer ) noexcept;
private:
// Key的数量,Unsigned 256足够对应所有的Key
static constexpr unsigned int nKeys = 256u;
// 队列长度
static constexpr unsigned int bufferSize = 16u;
// Todo
bool autorepeatEnabled = false;
// 用于存放每个Key的状态,每个bit的值对应一个Key的状态
std::bitset<nKeys> keystates;
// 用于存放Key事件的队列
std::queue<Event> keybuffer;
// 用于存放Char的队列
std::queue<char> charbuffer;
};
\ No newline at end of file
/******************************************************************************************
* Chili DirectX Framework Version 16.07.20 *
* Mouse.cpp *
* Copyright 2016 PlanetChili <http://www.planetchili.net> *
* *
* This file is part of The Chili DirectX Framework. *
* *
* The Chili DirectX Framework is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* The Chili DirectX Framework is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with The Chili DirectX Framework. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#include "Mouse.h"
#include "Window.h"
std::pair<int,int> Mouse::GetPos() const noexcept
{
return { x,y };
}
int Mouse::GetPosX() const noexcept
{
return x;
}
int Mouse::GetPosY() const noexcept
{
return y;
}
bool Mouse::IsInWindow() const noexcept
{
return isInWindow;
}
bool Mouse::LeftIsPressed() const noexcept
{
return leftIsPressed;
}
bool Mouse::RightIsPressed() const noexcept
{
return rightIsPressed;
}
Mouse::Event Mouse::Read() noexcept
{
if( buffer.size() > 0u )
{
Mouse::Event e = buffer.front();
buffer.pop();
return e;
}
else
{
return Mouse::Event();
}
}
void Mouse::Flush() noexcept
{
buffer = std::queue<Event>();
}
void Mouse::OnMouseMove( int newx,int newy ) noexcept
{
x = newx;
y = newy;
buffer.push( Mouse::Event( Mouse::Event::Type::Move,*this ) );
TrimBuffer();
}
void Mouse::OnMouseEnter() noexcept
{
isInWindow = true;
buffer.push(Mouse::Event(Mouse::Event::Type::Enter, *this));
TrimBuffer();
}
void Mouse::OnMouseLeave() noexcept
{
isInWindow = false;
buffer.push(Mouse::Event(Mouse::Event::Type::Leave, *this));
TrimBuffer();
}
void Mouse::OnLeftPressed( int x,int y ) noexcept
{
leftIsPressed = true;
buffer.push( Mouse::Event( Mouse::Event::Type::LPress,*this ) );
TrimBuffer();
}
void Mouse::OnLeftReleased( int x,int y ) noexcept
{
leftIsPressed = false;
buffer.push( Mouse::Event( Mouse::Event::Type::LRelease,*this ) );
TrimBuffer();
}
void Mouse::OnRightPressed( int x,int y ) noexcept
{
rightIsPressed = true;
buffer.push( Mouse::Event( Mouse::Event::Type::RPress,*this ) );
TrimBuffer();
}
void Mouse::OnRightReleased( int x,int y ) noexcept
{
rightIsPressed = false;
buffer.push( Mouse::Event( Mouse::Event::Type::RRelease,*this ) );
TrimBuffer();
}
void Mouse::OnWheelUp( int x,int y ) noexcept
{
buffer.push( Mouse::Event( Mouse::Event::Type::WheelUp,*this ) );
TrimBuffer();
}
void Mouse::OnWheelDown( int x,int y ) noexcept
{
buffer.push( Mouse::Event( Mouse::Event::Type::WheelDown,*this ) );
TrimBuffer();
}
void Mouse::TrimBuffer() noexcept
{
while( buffer.size() > bufferSize )
{
buffer.pop();
}
}
void Mouse::OnWheelDelta(int x, int y, int delta) noexcept
{
wheelDeltaCarry += delta;
// generate events for every 120
// 默认每次达到120,执行一次滚轮事件。如果数字够大,可以执行复数次
while (wheelDeltaCarry >= WHEEL_DELTA)
{
wheelDeltaCarry -= WHEEL_DELTA;
OnWheelUp(x, y);
}
while (wheelDeltaCarry <= -WHEEL_DELTA)
{
wheelDeltaCarry += WHEEL_DELTA;
OnWheelDown(x, y);
}
}
\ No newline at end of file
/******************************************************************************************
* Chili DirectX Framework Version 16.07.20 *
* Mouse.h *
* Copyright 2016 PlanetChili <http://www.planetchili.net> *
* *
* This file is part of The Chili DirectX Framework. *
* *
* The Chili DirectX Framework is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* The Chili DirectX Framework is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with The Chili DirectX Framework. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#pragma once
#include <queue>
class Mouse
{
friend class Window;
public:
class Event
{
public:
enum class Type
{
LPress,
LRelease,
RPress,
RRelease,
WheelUp,
WheelDown,
Move,
Enter,
Leave,
Invalid
};
private:
Type type;
bool leftIsPressed;
bool rightIsPressed;
int x;
int y;
public:
Event() noexcept
:
type( Type::Invalid ),
leftIsPressed( false ),
rightIsPressed( false ),
x( 0 ),
y( 0 )
{}
Event( Type type,const Mouse& parent ) noexcept
:
type( type ),
leftIsPressed( parent.leftIsPressed ),
rightIsPressed( parent.rightIsPressed ),
x( parent.x ),
y( parent.y )
{}
bool IsValid() const noexcept
{
return type != Type::Invalid;
}
Type GetType() const noexcept
{
return type;
}
std::pair<int,int> GetPos() const noexcept
{
return{ x,y };
}
int GetPosX() const noexcept
{
return x;
}
int GetPosY() const noexcept
{
return y;
}
bool LeftIsPressed() const noexcept
{
return leftIsPressed;
}
bool RightIsPressed() const noexcept
{
return rightIsPressed;
}
};
public:
Mouse() = default;
Mouse( const Mouse& ) = delete;
Mouse& operator=( const Mouse& ) = delete;
std::pair<int,int> GetPos() const noexcept;
int GetPosX() const noexcept;
int GetPosY() const noexcept;
bool IsInWindow() const noexcept;
bool LeftIsPressed() const noexcept;
bool RightIsPressed() const noexcept;
Mouse::Event Read() noexcept;
bool IsEmpty() const noexcept
{
return buffer.empty();
}
void Flush() noexcept;
private:
void OnMouseMove( int x,int y ) noexcept;
void OnMouseEnter() noexcept;
void OnMouseLeave() noexcept;
void OnLeftPressed( int x,int y ) noexcept;
void OnLeftReleased( int x,int y ) noexcept;
void OnRightPressed( int x,int y ) noexcept;
void OnRightReleased( int x,int y ) noexcept;
void OnWheelUp( int x,int y ) noexcept;
void OnWheelDown( int x,int y ) noexcept;
void OnWheelDelta(int x, int y, int delta) noexcept;
void TrimBuffer() noexcept;
private:
static constexpr unsigned int bufferSize = 16u;
int x;
int y;
bool leftIsPressed = false;
bool rightIsPressed = false;
bool isInWindow = false;
// 执行滚轮事件的次数,正数表示向上滚动,负数表示向下滚动
int wheelDeltaCarry = 0;
std::queue<Event> buffer;
};
\ No newline at end of file
#include "PixelShader.h"
#include "GraphicsThrowMacros.h"
PixelShader::PixelShader( Graphics& gfx,const std::wstring& path )
{
INFOMAN( gfx );
Microsoft::WRL::ComPtr<ID3DBlob> pBlob;
GFX_THROW_INFO( D3DReadFileToBlob( path.c_str(),&pBlob ) );
GFX_THROW_INFO( GetDevice( gfx )->CreatePixelShader( pBlob->GetBufferPointer(),pBlob->GetBufferSize(),nullptr,&pPixelShader ) );
}
void PixelShader::Bind( Graphics& gfx ) noexcept
{
GetContext( gfx )->PSSetShader( pPixelShader.Get(),nullptr,0u );
}
#pragma once
#include "Bindable.h"
class PixelShader : public Bindable
{
public:
PixelShader( Graphics& gfx,const std::wstring& path );
void Bind( Graphics& gfx ) noexcept override;
protected:
Microsoft::WRL::ComPtr<ID3D11PixelShader> pPixelShader;
};
\ No newline at end of file
cbuffer CBuf
{
float4 face_color[6];
};
//float4 main( float3 color : Color) : SV_Target
float4 main(uint tid: SV_PrimitiveID) : SV_Target
{
//return float4(color, 1.0f);
return face_color[tid/2];
}
\ No newline at end of file
B// Microsoft Visual C++ generated resource script. B// Microsoft Visual C++ generated resource script.
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions); IS_DEBUG=true</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
...@@ -137,16 +137,82 @@ ...@@ -137,16 +137,82 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="App.cpp" />
<ClCompile Include="Bindable.cpp" />
<ClCompile Include="Box.cpp" />
<ClCompile Include="ChiliException.cpp" /> <ClCompile Include="ChiliException.cpp" />
<ClCompile Include="ChiliTimer.cpp" />
<ClCompile Include="Drawable.cpp" />
<ClCompile Include="dxerr.cpp" />
<ClCompile Include="DxgiInfoManager.cpp" />
<ClCompile Include="Graphics.cpp" />
<ClCompile Include="IndexBuffer.cpp" />
<ClCompile Include="InputLayout.cpp" />
<ClCompile Include="Keyboard.cpp" />
<ClCompile Include="Mouse.cpp" />
<ClCompile Include="PixelShader.cpp" />
<ClCompile Include="Topology.cpp" />
<ClCompile Include="TransformCbuf.cpp" />
<ClCompile Include="VertexBuffer.cpp" />
<ClCompile Include="VertexShader.cpp" />
<ClCompile Include="Window.cpp" /> <ClCompile Include="Window.cpp" />
<ClCompile Include="WindowsMessageMap.cpp" /> <ClCompile Include="WindowsMessageMap.cpp" />
<ClCompile Include="WinMain.cpp" /> <ClCompile Include="WinMain.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="App.h" />
<ClInclude Include="Bindable.h" />
<ClInclude Include="BindableBase.h" />
<ClInclude Include="Box.h" />
<ClInclude Include="ChiliException.h" /> <ClInclude Include="ChiliException.h" />
<ClInclude Include="ChiliTimer.h" />
<ClInclude Include="ChiliWin.h" /> <ClInclude Include="ChiliWin.h" />
<ClInclude Include="ConstantBuffers.h" />
<ClInclude Include="Drawable.h" />
<ClInclude Include="dxerr.h" />
<ClInclude Include="DxgiInfoManager.h" />
<ClInclude Include="Graphics.h" />
<ClInclude Include="GraphicsThrowMacros.h" />
<ClInclude Include="IndexBuffer.h" />
<ClInclude Include="InputLayout.h" />
<ClInclude Include="Keyboard.h" />
<ClInclude Include="Mouse.h" />
<ClInclude Include="PixelShader.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Topology.h" />
<ClInclude Include="TransformCbuf.h" />
<ClInclude Include="VertexBuffer.h" />
<ClInclude Include="VertexShader.h" />
<ClInclude Include="Window.h" /> <ClInclude Include="Window.h" />
<ClInclude Include="WindowsMessageMap.h" /> <ClInclude Include="WindowsMessageMap.h" />
<ClInclude Include="WindowsThrowMacros.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="StudyDx.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="oasis.ico" />
</ItemGroup>
<ItemGroup>
<None Include="DXGetErrorDescription.inl" />
<None Include="DXGetErrorString.inl" />
<None Include="DXTrace.inl" />
</ItemGroup>
<ItemGroup>
<FxCompile Include="PixelShader.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="VertexShader.hlsl">
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
......
...@@ -13,6 +13,27 @@ ...@@ -13,6 +13,27 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> <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> <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter> </Filter>
<Filter Include="Inline FIles">
<UniqueIdentifier>{4ea6ad36-f6fa-4bd0-a3a7-f0e7c18bdeac}</UniqueIdentifier>
</Filter>
<Filter Include="Shader">
<UniqueIdentifier>{a93d4d3c-0eaa-43f3-b67b-4145e2090bfc}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Bindables">
<UniqueIdentifier>{2374654f-f5e0-4773-8e27-d57494ccf53f}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Drawables">
<UniqueIdentifier>{1f8add8b-4a35-4fbc-824e-4bc57b68bf3e}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Macros">
<UniqueIdentifier>{43a71e8b-5cbf-4369-a0fc-c4aebba17560}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Bindables">
<UniqueIdentifier>{50b4eb78-a8fd-4068-b158-623ca539d711}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Drawables">
<UniqueIdentifier>{ec1eb5eb-ddd0-47dc-b917-51d4324dc100}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="WinMain.cpp"> <ClCompile Include="WinMain.cpp">
...@@ -27,6 +48,57 @@ ...@@ -27,6 +48,57 @@
<ClCompile Include="WindowsMessageMap.cpp"> <ClCompile Include="WindowsMessageMap.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Keyboard.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Mouse.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="App.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ChiliTimer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Graphics.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dxerr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DxgiInfoManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Bindable.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="IndexBuffer.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="InputLayout.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="PixelShader.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="Topology.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="TransformCbuf.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="VertexBuffer.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="VertexShader.cpp">
<Filter>Source Files\Bindables</Filter>
</ClCompile>
<ClCompile Include="Box.cpp">
<Filter>Source Files\Drawables</Filter>
</ClCompile>
<ClCompile Include="Drawable.cpp">
<Filter>Source Files\Drawables</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="ChiliException.h"> <ClInclude Include="ChiliException.h">
...@@ -41,5 +113,100 @@ ...@@ -41,5 +113,100 @@
<ClInclude Include="WindowsMessageMap.h"> <ClInclude Include="WindowsMessageMap.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Keyboard.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Mouse.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="App.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ChiliTimer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Graphics.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dxerr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DxgiInfoManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Bindable.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="BindableBase.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="ConstantBuffers.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="IndexBuffer.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="InputLayout.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="PixelShader.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="Topology.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="TransformCbuf.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="VertexBuffer.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="VertexShader.h">
<Filter>Header Files\Bindables</Filter>
</ClInclude>
<ClInclude Include="Box.h">
<Filter>Header Files\Drawables</Filter>
</ClInclude>
<ClInclude Include="Drawable.h">
<Filter>Header Files\Drawables</Filter>
</ClInclude>
<ClInclude Include="GraphicsThrowMacros.h">
<Filter>Header Files\Macros</Filter>
</ClInclude>
<ClInclude Include="WindowsThrowMacros.h">
<Filter>Header Files\Macros</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="StudyDx.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="oasis.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<None Include="DXGetErrorDescription.inl">
<Filter>Inline FIles</Filter>
</None>
<None Include="DXGetErrorString.inl">
<Filter>Inline FIles</Filter>
</None>
<None Include="DXTrace.inl">
<Filter>Inline FIles</Filter>
</None>
</ItemGroup>
<ItemGroup>
<FxCompile Include="VertexShader.hlsl">
<Filter>Shader</Filter>
</FxCompile>
<FxCompile Include="PixelShader.hlsl">
<Filter>Shader</Filter>
</FxCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
#include "Topology.h"
Topology::Topology( Graphics& gfx,D3D11_PRIMITIVE_TOPOLOGY type )
:
type( type )
{}
void Topology::Bind( Graphics& gfx ) noexcept
{
GetContext( gfx )->IASetPrimitiveTopology( type );
}
#pragma once
#include "Bindable.h"
class Topology : public Bindable
{
public:
Topology( Graphics& gfx,D3D11_PRIMITIVE_TOPOLOGY type );
void Bind( Graphics& gfx ) noexcept override;
protected:
D3D11_PRIMITIVE_TOPOLOGY type;
};
\ No newline at end of file
#include "TransformCbuf.h"
TransformCbuf::TransformCbuf( Graphics& gfx,const Drawable& parent )
:
vcbuf( gfx ),
parent( parent )
{}
void TransformCbuf::Bind( Graphics& gfx ) noexcept
{
vcbuf.Update( gfx,
DirectX::XMMatrixTranspose(
parent.GetTransformXM() * gfx.GetProjection()
)
);
vcbuf.Bind( gfx );
}
#pragma once
#include "ConstantBuffers.h"
#include "Drawable.h"
#include <DirectXMath.h>
class TransformCbuf : public Bindable
{
public:
TransformCbuf( Graphics& gfx,const Drawable& parent );
void Bind( Graphics& gfx ) noexcept override;
private:
VertexConstantBuffer<DirectX::XMMATRIX> vcbuf;
const Drawable& parent;
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment