Danbias/Code/OysterGraphics/Render/Rendering/BasicRender.cpp

63 lines
1.5 KiB
C++
Raw Normal View History

#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"
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-21 23:54:12 +01:00
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,1));
2013-11-21 13:50:43 +01:00
Core::ShaderManager::SetShaderEffect(Graphics::Render::Resources::obj);
2013-11-21 18:31:16 +01:00
Preparations::Basic::BindBackBufferRTV(nullptr);
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-21 18:31:16 +01:00
void Basic::RenderScene(Model* models, int count)
{
2013-11-21 13:50:43 +01:00
for(int i = 0; i < count; ++i)
{
if(models[i].Visible)
{
void* data = Resources::ModelData.Map();
memcpy(data,&(models[i].World),64);
Resources::ModelData.Unmap();
//Set Materials :: NONE
2013-11-21 23:54:12 +01:00
models[i].info->Vertices->Apply();
2013-11-21 13:50:43 +01:00
if(models[i].info->Indexed)
{
2013-11-21 23:54:12 +01:00
models[i].info->Indecies->Apply();
2013-11-21 13:50:43 +01:00
Oyster::Graphics::Core::deviceContext->DrawIndexed(models[i].info->VertexCount,0,0);
}
else
{
Oyster::Graphics::Core::deviceContext->Draw(models[i].info->VertexCount,0);
}
}
}
}
void Basic::EndFrame()
{
2013-11-21 13:50:43 +01:00
Core::swapChain->Present(0,0);
}
}
}
}
}