2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-14 08:46:09 +00:00

Start wiring up wgpu+winit

This commit is contained in:
2022-01-31 19:06:54 -05:00
parent 5491fd75cf
commit e48435f11e
209 changed files with 24234 additions and 8085 deletions

View File

@@ -4,35 +4,35 @@
#include "Runtime/Graphics/CGraphics.hpp"
#include <hecl/Pipeline.hpp>
//#include <hecl/Pipeline.hpp>
#include <zeus/CAABox.hpp>
namespace metaforce {
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
//static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
//static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
void CAABoxShader::Initialize() {
s_Pipeline = hecl::conv->convert(Shader_CAABoxShader{});
s_zOnlyPipeline = hecl::conv->convert(Shader_CAABoxShaderZOnly{});
// s_Pipeline = hecl::conv->convert(Shader_CAABoxShader{});
// s_zOnlyPipeline = hecl::conv->convert(Shader_CAABoxShaderZOnly{});
}
void CAABoxShader::Shutdown() {
s_Pipeline.reset();
s_zOnlyPipeline.reset();
// s_Pipeline.reset();
// s_zOnlyPipeline.reset();
}
CAABoxShader::CAABoxShader(bool zOnly) {
CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
m_dataBind =
ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(),
bufs.data(), stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return true;
} BooTrace);
// CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx) {
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
// constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
// m_dataBind =
// ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(),
// bufs.data(), stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
// return true;
// } BooTrace);
}
void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
@@ -62,7 +62,7 @@ void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
}};
m_vbo->load(vboData.data(), sizeof(vboData));
// m_vbo->load(vboData.data(), sizeof(vboData));
}
void CAABoxShader::draw(const zeus::CColor& color) {
@@ -70,10 +70,10 @@ void CAABoxShader::draw(const zeus::CColor& color) {
m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniform.m_color = color;
m_uniBuf->load(&m_uniform, sizeof(Uniform));
CGraphics::SetShaderDataBinding(m_dataBind);
CGraphics::DrawArray(0, 34);
// m_uniBuf->load(&m_uniform, sizeof(Uniform));
//
// CGraphics::SetShaderDataBinding(m_dataBind);
// CGraphics::DrawArray(0, 34);
}
} // namespace metaforce