metaforce/Runtime/Graphics/Shaders/CMapSurfaceShader.cpp

43 lines
1.4 KiB
C++
Raw Normal View History

2017-04-22 06:42:32 +00:00
#include "CMapSurfaceShader.hpp"
2018-10-07 02:59:17 +00:00
#include "hecl/Pipeline.hpp"
#include "Graphics/CGraphics.hpp"
2017-04-22 06:42:32 +00:00
namespace urde
{
2018-10-07 02:59:17 +00:00
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
void CMapSurfaceShader::Initialize()
{
s_Pipeline = hecl::conv->convert(Shader_CMapSurfaceShader{});
}
void CMapSurfaceShader::Shutdown()
{
s_Pipeline.reset();
}
2017-04-22 06:42:32 +00:00
CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx,
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
2017-04-22 06:42:32 +00:00
: m_vbo(vbo), m_ibo(ibo)
{
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
2018-10-07 02:59:17 +00:00
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, m_ibo.get(),
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
2017-04-22 06:42:32 +00:00
}
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count)
{
Uniform uniform = {
CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), color
};
2017-11-20 17:33:21 +00:00
m_uniBuf->load(&uniform, sizeof(Uniform));
2017-04-22 06:42:32 +00:00
CGraphics::SetShaderDataBinding(m_dataBind);
CGraphics::DrawArrayIndexed(start, count);
}
}