2013-11-20 16:51:53 +01:00
|
|
|
#include "Render.h"
|
2013-11-21 13:50:43 +01:00
|
|
|
#include "../Resources/Resources.h"
|
2013-11-21 18:31:16 +01:00
|
|
|
#include "../../Definitions/GraphicalDefinition.h"
|
2013-11-26 09:09:35 +01:00
|
|
|
#include "../../Model/ModelInfo.h"
|
2013-11-20 16:51:53 +01:00
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Graphics
|
|
|
|
{
|
|
|
|
namespace Render
|
|
|
|
{
|
|
|
|
namespace Rendering
|
|
|
|
{
|
|
|
|
|
2013-11-21 18:31:16 +01:00
|
|
|
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
|
2013-11-20 16:51:53 +01:00
|
|
|
{
|
2013-11-28 14:34:52 +01:00
|
|
|
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1));
|
2013-11-21 13:50:43 +01:00
|
|
|
Core::ShaderManager::SetShaderEffect(Graphics::Render::Resources::obj);
|
2013-11-28 14:34:52 +01:00
|
|
|
Preparations::Basic::BindBackBufferRTV();
|
2013-11-21 18:31:16 +01:00
|
|
|
|
|
|
|
Definitions::VP vp;
|
|
|
|
vp.V = View;
|
|
|
|
vp.P = Projection;
|
|
|
|
|
|
|
|
void* data = Resources::VPData.Map();
|
|
|
|
memcpy(data, &vp, sizeof(Definitions::VP));
|
|
|
|
Resources::VPData.Unmap();
|
|
|
|
|
|
|
|
Resources::VPData.Apply();
|
2013-11-20 16:51:53 +01:00
|
|
|
}
|
2013-11-21 18:31:16 +01:00
|
|
|
|
2013-11-26 09:09:35 +01:00
|
|
|
void Basic::RenderScene(Model::Model* models, int count)
|
2013-11-20 16:51:53 +01:00
|
|
|
{
|
2013-11-21 13:50:43 +01:00
|
|
|
for(int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
if(models[i].Visible)
|
|
|
|
{
|
|
|
|
void* data = Resources::ModelData.Map();
|
2013-11-26 13:44:58 +01:00
|
|
|
memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4));
|
2013-11-21 13:50:43 +01:00
|
|
|
Resources::ModelData.Unmap();
|
|
|
|
|
2013-11-28 14:34:52 +01:00
|
|
|
|
|
|
|
Model::ModelInfo* info = (Model::ModelInfo*)models[i].info;
|
|
|
|
|
|
|
|
Core::deviceContext->PSSetShaderResources(0,info->Material.size(),&(info->Material[0]));
|
2013-11-21 13:50:43 +01:00
|
|
|
|
2013-11-26 09:09:35 +01:00
|
|
|
|
|
|
|
info->Vertices->Apply();
|
|
|
|
if(info->Indexed)
|
2013-11-21 13:50:43 +01:00
|
|
|
{
|
2013-11-26 09:09:35 +01:00
|
|
|
info->Indecies->Apply();
|
|
|
|
Oyster::Graphics::Core::deviceContext->DrawIndexed(info->VertexCount,0,0);
|
2013-11-21 13:50:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-26 09:09:35 +01:00
|
|
|
Oyster::Graphics::Core::deviceContext->Draw(info->VertexCount,0);
|
2013-11-21 13:50:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-20 16:51:53 +01:00
|
|
|
}
|
|
|
|
void Basic::EndFrame()
|
|
|
|
{
|
2013-12-04 09:36:43 +01:00
|
|
|
IDXGISwapChain* chain = Core::swapChain;
|
|
|
|
chain->Present(0,0);
|
2013-11-20 16:51:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|