diff --git a/Code/OysterGraphics/OldRender/Model.h b/Code/OysterGraphics/Model/Model.h similarity index 100% rename from Code/OysterGraphics/OldRender/Model.h rename to Code/OysterGraphics/Model/Model.h diff --git a/Code/OysterGraphics/OldRender/ModelInfo.h b/Code/OysterGraphics/Model/ModelInfo.h similarity index 100% rename from Code/OysterGraphics/OldRender/ModelInfo.h rename to Code/OysterGraphics/Model/ModelInfo.h diff --git a/Code/OysterGraphics/Resourses/Buffers.cpp b/Code/OysterGraphics/OldResourses/Buffers.cpp similarity index 100% rename from Code/OysterGraphics/Resourses/Buffers.cpp rename to Code/OysterGraphics/OldResourses/Buffers.cpp diff --git a/Code/OysterGraphics/Resourses/Buffers.h b/Code/OysterGraphics/OldResourses/Buffers.h similarity index 100% rename from Code/OysterGraphics/Resourses/Buffers.h rename to Code/OysterGraphics/OldResourses/Buffers.h diff --git a/Code/OysterGraphics/Resourses/GraphicsDefinitions.h b/Code/OysterGraphics/OldResourses/GraphicsDefinitions.h similarity index 100% rename from Code/OysterGraphics/Resourses/GraphicsDefinitions.h rename to Code/OysterGraphics/OldResourses/GraphicsDefinitions.h diff --git a/Code/OysterGraphics/Resourses/Manager.cpp b/Code/OysterGraphics/OldResourses/Manager.cpp similarity index 100% rename from Code/OysterGraphics/Resourses/Manager.cpp rename to Code/OysterGraphics/OldResourses/Manager.cpp diff --git a/Code/OysterGraphics/Resourses/Manager.h b/Code/OysterGraphics/OldResourses/Manager.h similarity index 100% rename from Code/OysterGraphics/Resourses/Manager.h rename to Code/OysterGraphics/OldResourses/Manager.h diff --git a/Code/OysterGraphics/Resourses/PipelineResources.cpp b/Code/OysterGraphics/OldResourses/PipelineResources.cpp similarity index 100% rename from Code/OysterGraphics/Resourses/PipelineResources.cpp rename to Code/OysterGraphics/OldResourses/PipelineResources.cpp diff --git a/Code/OysterGraphics/Resourses/PipelineResources.h b/Code/OysterGraphics/OldResourses/PipelineResources.h similarity index 100% rename from Code/OysterGraphics/Resourses/PipelineResources.h rename to Code/OysterGraphics/OldResourses/PipelineResources.h diff --git a/Code/OysterGraphics/Resourses/ShaderEffects.cpp b/Code/OysterGraphics/OldResourses/ShaderEffects.cpp similarity index 100% rename from Code/OysterGraphics/Resourses/ShaderEffects.cpp rename to Code/OysterGraphics/OldResourses/ShaderEffects.cpp diff --git a/Code/OysterGraphics/Resourses/ShaderEffects.h b/Code/OysterGraphics/OldResourses/ShaderEffects.h similarity index 100% rename from Code/OysterGraphics/Resourses/ShaderEffects.h rename to Code/OysterGraphics/OldResourses/ShaderEffects.h diff --git a/Code/OysterGraphics/Render/Preparations.h b/Code/OysterGraphics/Render/Preparations.h deleted file mode 100644 index c00947b0..00000000 --- a/Code/OysterGraphics/Render/Preparations.h +++ /dev/null @@ -1,23 +0,0 @@ -#include "..\Core\Core.h" - -namespace Oyster -{ - namespace Graphics - { - namespace Render - { - namespace Preparations - { - class Basic - { - void BindBackBufferRTV(bool UseDepthStencil = true); - void BindBackBufferRTV(ID3D11DepthStencilView* depthStencil); - - void BindBackBufferUAV(); - - void ClearBackBuffer(Oyster::Math::Float4 Color, bool ClearDepthStencil); - }; - } - } - } -} \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Preparations/Basic.cpp b/Code/OysterGraphics/Render/Preparations/Basic.cpp new file mode 100644 index 00000000..e6857664 --- /dev/null +++ b/Code/OysterGraphics/Render/Preparations/Basic.cpp @@ -0,0 +1,84 @@ +#include "Preparations.h" + +namespace Oyster +{ + namespace Graphics + { + namespace Render + { + namespace Preparations + { + void Basic::BindBackBufferRTV(bool DepthStencil) + { + if(DepthStencil) + { + Core::deviceContext->OMSetRenderTargets(1,&Core::backBufferRTV,Core::depthStencil); + } + else + { + Core::deviceContext->OMSetRenderTargets(1,&Core::backBufferRTV,NULL); + } + } + + void Basic::BindBackBufferRTV(ID3D11DepthStencilView& depthStencil) + { + Core::deviceContext->OMSetRenderTargets(1,&Core::backBufferRTV,&depthStencil); + } + + void Basic::BindBackBufferUAV() + { + Core::deviceContext->CSSetUnorderedAccessViews(0,1,&Core::backBufferUAV,0); + } + + void Basic::BindRTV(ID3D11RenderTargetView* RTVs[], int size, bool UseDepthStencil) + { + if(UseDepthStencil) + { + BindRTV(RTVs, size, Core::depthStencil); + } + else + { + Core::deviceContext->OMSetRenderTargets(size,RTVs,NULL); + } + } + + void Basic::BindRTV(ID3D11RenderTargetView* RTVs[], int size,ID3D11DepthStencilView& depthStencil) + { + Core::deviceContext->OMSetRenderTargets(size,RTVs,&depthStencil); + } + + void Basic::BindUAV(ID3D11UnorderedAccessView* UAVs[], int size) + { + Core::deviceContext->CSSetUnorderedAccessViews(0,size,UAVs,0); + } + + void Basic::ClearBackBuffer(Oyster::Math::Float4 Color, bool ClearDefaultDepthStencil) + { + Core::deviceContext->ClearRenderTargetView(Core::backBufferRTV,Color); + if(ClearDefaultDepthStencil) + { + Core::deviceContext->ClearDepthStencilView(Core::depthStencil,1,1,0); + } + } + + void Basic::ClearRTV(ID3D11RenderTargetView* RTVs[], int size,Oyster::Math::Float4 Color) + { + for(int i = 0; i < size; ++i) + { + Core::deviceContext->ClearRenderTargetView(RTVs[i],Color); + } + } + + void Basic::ClearDepthStencil(ID3D11DepthStencilView &depthStencil) + { + Core::deviceContext->ClearDepthStencilView(&depthStencil,1,1,0); + } + + void Basic::SetViewPort() + { + Core::deviceContext->RSSetViewports(1,Core::viewPort); + } + } + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Preparations/Preparations.h b/Code/OysterGraphics/Render/Preparations/Preparations.h new file mode 100644 index 00000000..cea28590 --- /dev/null +++ b/Code/OysterGraphics/Render/Preparations/Preparations.h @@ -0,0 +1,47 @@ +#pragma once + +#include "..\..\Core\Core.h" + +namespace Oyster +{ + namespace Graphics + { + namespace Render + { + namespace Preparations + { + static class Basic + { + public: + /** @brief Binds the backbuffer as a RenderTargetView with the specified DepthStencil*/ + static void BindBackBufferRTV(ID3D11DepthStencilView& depthStencil); + /** @brief Binds the backbuffer as a RenderTargetView with or without the default DepthStencil*/ + static void BindBackBufferRTV(bool UseDefaultDepthStencil = true); + + + /** @brief Binds the backbuffer as a UnorderedAccessView*/ + static void BindBackBufferUAV(); + + /** @brief Binds the specified RenderTargetViews with or without the default DepthStencil*/ + static void BindRTV(ID3D11RenderTargetView* RTVs[], int size, bool UseDepthStencil = true); + /** @brief Binds the specified RenderTargetViews with the specified DepthStencil*/ + static void BindRTV(ID3D11RenderTargetView* RTVs[], int size,ID3D11DepthStencilView& depthStencil); + + /** @brief Binds the specified UnorderedAccessViews*/ + static void BindUAV(ID3D11UnorderedAccessView* UAVs[], int size); + + /** @brief Clear the BackBuffer and if true the default DepthStencil*/ + static void ClearBackBuffer(Oyster::Math::Float4 Color, bool ClearDefaultDepthStencil = true); + + /** @brief Clear the specified RenderTargetViews*/ + static void ClearRTV(ID3D11RenderTargetView* RTVs[], int size,Oyster::Math::Float4 Color); + /** @brief Clear the specified DepthStencil*/ + static void ClearDepthStencil(ID3D11DepthStencilView &depthStencil); + + /** @brief Binds the default ViewPort*/ + static void SetViewPort(); + }; + } + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Rendering/Basic.cpp b/Code/OysterGraphics/Render/Rendering/Basic.cpp new file mode 100644 index 00000000..272a2a7c --- /dev/null +++ b/Code/OysterGraphics/Render/Rendering/Basic.cpp @@ -0,0 +1,33 @@ +#include "Render.h" + +namespace Oyster +{ + namespace Graphics + { + namespace Render + { + namespace Rendering + { + Core::ShaderManager::ShaderEffect Basic::Resources::se = Core::ShaderManager::ShaderEffect(); + + void Basic::Resources::Init() + { + se.Shaders.Vertex = Core::ShaderManager::Get::Vertex(L"DebugCamera"); + se.Shaders.Pixel = Core::ShaderManager::Get::Pixel(L"Debug"); + + } + + void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4 Projection) + { + Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,1)); + } + void Basic::RenderScene(Model* models, int count) + { + } + void Basic::EndFrame() + { + } + } + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Rendering/Render.h b/Code/OysterGraphics/Render/Rendering/Render.h new file mode 100644 index 00000000..22229078 --- /dev/null +++ b/Code/OysterGraphics/Render/Rendering/Render.h @@ -0,0 +1,33 @@ +#pragma once + +#include "..\..\Core\Core.h" +#include "..\Preparations\Preparations.h" +#include "..\..\Model\Model.h" + +namespace Oyster +{ + namespace Graphics + { + namespace Render + { + namespace Rendering + { + static class Basic + { + public: + class Resources + { + static Core::ShaderManager::ShaderEffect se; + + static void Init(); + }; + + + static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4 Projection); + static void RenderScene(Model* models, int count); + static void EndFrame(); + }; + } + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/Resources/Resources.cpp b/Code/OysterGraphics/Resources/Resources.cpp new file mode 100644 index 00000000..5eed0468 --- /dev/null +++ b/Code/OysterGraphics/Resources/Resources.cpp @@ -0,0 +1,52 @@ +#include "Resources.h" + +const std::wstring PathFromExeToHlsl = L""; +const std::wstring VertexTransformDebug = L"TransformDebugVertex"; +const std::wstring VertexDebug = L"DebugVertex"; +const std::wstring PixelRed = L"DebugPixel"; + +typedef Oyster::Graphics::Core::ShaderManager::ShaderType Shader; + +namespace Oyster +{ + namespace Graphics + { + namespace Render + { + Core::Init::State Resources::Init() + { + +#pragma region LoadShaders + +#ifdef _DEBUG + + /** Load Vertex Shader for d3dcompile*/ + Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugCameraVertex",Shader::Vertex, VertexTransformDebug, false); + Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" +L"DebugVertex",Shader::Vertex, VertexDebug, false); + + /** Load Pixel Shader for d3dcompile */ + Core::ShaderManager::Init(PathFromExeToHlsl + L"SimpleDebug\\" + L"DebugPixel", Shader::Pixel, PixelRed, false); + +#else + /** Load Vertex Shader with Precompiled */ +#endif + +#pragma endregion + +#pragma region CreateBuffers + /** @todo Create Buffers */ +#pragma endregion + +#pragma region Setup Render States + /** @todo Create DX States */ +#pragma endregion + + +#pragma region Create Shader Effects + /** @todo Create ShaderEffects */ +#pragma endregion + + } + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/Resources/Resources.h b/Code/OysterGraphics/Resources/Resources.h new file mode 100644 index 00000000..5dac3c5e --- /dev/null +++ b/Code/OysterGraphics/Resources/Resources.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include "..\Core\Core.h" + +namespace Oyster +{ + namespace Graphics + { + namespace Render + { + static class Resources + { + const Core::ShaderManager::ShaderEffect basic; + const Buffer ModelData; + + Core::Init::State Init(); + }; + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/SimpleDebug/DebugCameraVertex.hlsl b/Code/OysterGraphics/Shader/HLSL/SimpleDebug/DebugCameraVertex.hlsl new file mode 100644 index 00000000..e2123062 --- /dev/null +++ b/Code/OysterGraphics/Shader/HLSL/SimpleDebug/DebugCameraVertex.hlsl @@ -0,0 +1,17 @@ +cbuffer PerFrame : register(b0) +{ + matrix View; + float4x4 Projection; +} + +cbuffer PerModel : register(b1) +{ + matrix World; +} + +float4 main( float4 pos : POSITION ) : SV_POSITION +{ + matrix VP = mul(View, Projection); + matrix WVP = mul(World, VP); + return mul(WVP, pos); +} \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index c227191e..53b19782 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -7,7 +7,8 @@ //-------------------------------------------------------------------------------------- #define NOMINMAX #include -#include "Engine.h" +#include "Core/Core.h" +#include "Render\Preparations\Preparations.h" //-------------------------------------------------------------------------------------- // Global Variables @@ -142,9 +143,9 @@ HRESULT InitDirect3D() std::wstring EffectPath = L"SimpleDebug\\"; Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugPixel.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Pixel,L"Debug",false); - Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Vertex,L"Debug",false); + Oyster::Graphics::Core::ShaderManager::Init(ShaderPath + EffectPath + L"DebugVertex.hlsl",Oyster::Graphics::Core::ShaderManager::ShaderType::Vertex,L"PassThroughFloat4",false); - Oyster::Graphics::Core::ShaderManager::Set::Vertex(Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"Debug")); + Oyster::Graphics::Core::ShaderManager::Set::Vertex(Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4")); Oyster::Graphics::Core::ShaderManager::Set::Pixel(Oyster::Graphics::Core::ShaderManager::Get::Pixel(L"Debug")); D3D11_INPUT_ELEMENT_DESC inputDesc[] = @@ -154,14 +155,14 @@ HRESULT InitDirect3D() ID3D11InputLayout* layout; - Oyster::Graphics::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"Debug"), layout); + Oyster::Graphics::Core::ShaderManager::CreateInputLayout( inputDesc, 1, Oyster::Graphics::Core::ShaderManager::Get::Vertex(L"PassThroughFloat4"), layout); Oyster::Graphics::Core::deviceContext->IASetInputLayout(layout); Oyster::Graphics::Core::deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - Oyster::Graphics::Core::deviceContext->OMSetRenderTargets(1,&Oyster::Graphics::Core::backBufferRTV,Oyster::Graphics::Core::depthStencil); + Oyster::Graphics::Render::Preparations::Basic::BindBackBufferRTV(); - Oyster::Graphics::Core::deviceContext->RSSetViewports(1,Oyster::Graphics::Core::viewPort); + Oyster::Graphics::Render::Preparations::Basic::SetViewPort(); struct float4 { @@ -196,8 +197,7 @@ HRESULT Update(float deltaTime) HRESULT Render(float deltaTime) { - Oyster::Graphics::Core::deviceContext->ClearRenderTargetView(Oyster::Graphics::Core::backBufferRTV, Oyster::Math::Float4(0,0,1,1)); - Oyster::Graphics::Core::deviceContext->ClearDepthStencilView(Oyster::Graphics::Core::depthStencil,1,1,0); + Oyster::Graphics::Render::Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1)); Oyster::Graphics::Core::deviceContext->Draw(3,0);