Fixing Render Namespace, See, todo in Resources.cpp

This commit is contained in:
lanariel 2013-11-20 16:51:53 +01:00
parent 3512121f52
commit adfec528bf
20 changed files with 295 additions and 31 deletions

View File

@ -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);
};
}
}
}
}

View File

@ -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);
}
}
}
}
}

View File

@ -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();
};
}
}
}
}

View File

@ -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()
{
}
}
}
}
}

View File

@ -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();
};
}
}
}
}

View File

@ -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
}
}
}
}

View File

@ -0,0 +1,21 @@
#pragma once
#include <map>
#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();
};
}
}
}

View File

@ -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);
}

View File

@ -7,7 +7,8 @@
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#define NOMINMAX #define NOMINMAX
#include <Windows.h> #include <Windows.h>
#include "Engine.h" #include "Core/Core.h"
#include "Render\Preparations\Preparations.h"
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Global Variables // Global Variables
@ -142,9 +143,9 @@ HRESULT InitDirect3D()
std::wstring EffectPath = L"SimpleDebug\\"; 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"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")); Oyster::Graphics::Core::ShaderManager::Set::Pixel(Oyster::Graphics::Core::ShaderManager::Get::Pixel(L"Debug"));
D3D11_INPUT_ELEMENT_DESC inputDesc[] = D3D11_INPUT_ELEMENT_DESC inputDesc[] =
@ -154,14 +155,14 @@ HRESULT InitDirect3D()
ID3D11InputLayout* layout; 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->IASetInputLayout(layout);
Oyster::Graphics::Core::deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); 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 struct float4
{ {
@ -196,8 +197,7 @@ HRESULT Update(float deltaTime)
HRESULT Render(float deltaTime) HRESULT Render(float deltaTime)
{ {
Oyster::Graphics::Core::deviceContext->ClearRenderTargetView(Oyster::Graphics::Core::backBufferRTV, Oyster::Math::Float4(0,0,1,1)); Oyster::Graphics::Render::Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1));
Oyster::Graphics::Core::deviceContext->ClearDepthStencilView(Oyster::Graphics::Core::depthStencil,1,1,0);
Oyster::Graphics::Core::deviceContext->Draw(3,0); Oyster::Graphics::Core::deviceContext->Draw(3,0);