mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-13 21:51:22 +00:00
Now, with all of the headers normalized, we can safely convert some headers into forward declarations without needing to worry about potentially breaking code in other headers or source files.
35 lines
1.4 KiB
C++
35 lines
1.4 KiB
C++
#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp"
|
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
|
|
|
#include <hecl/Pipeline.hpp>
|
|
|
|
namespace urde {
|
|
|
|
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
|
|
|
void CMapSurfaceShader::Initialize() { s_Pipeline = hecl::conv->convert(Shader_CMapSurfaceShader{}); }
|
|
|
|
void CMapSurfaceShader::Shutdown() { s_Pipeline.reset(); }
|
|
|
|
CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx,
|
|
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
|
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
|
: m_vbo(vbo), m_ibo(ibo) {
|
|
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
|
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);
|
|
}
|
|
|
|
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) {
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CMapSurfaceShader::draw", zeus::skMagenta);
|
|
Uniform uniform = {CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), color};
|
|
m_uniBuf->load(&uniform, sizeof(Uniform));
|
|
CGraphics::SetShaderDataBinding(m_dataBind);
|
|
CGraphics::DrawArrayIndexed(start, count);
|
|
}
|
|
|
|
} // namespace urde
|