2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-10 07:47:42 +00:00

Graphics/Shaders: Use std::array where applicable

Makes the arrays strongly typed and impervious to array->pointer decay.
This also allows simplifying some operations (such as being able to call
fill() instead of needing to use std::fill, etc).
This commit is contained in:
Lioncash
2019-09-28 22:22:12 -04:00
parent 417506572c
commit 136a229a1a
36 changed files with 530 additions and 347 deletions

View File

@@ -1,5 +1,7 @@
#include "Runtime/Graphics/Shaders/CEnergyBarShader.hpp"
#include <cstring>
#include "Runtime/Graphics/CGraphics.hpp"
#include "Runtime/Graphics/CTexture.hpp"
@@ -31,15 +33,19 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
m_tex = tex;
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ObjToken<boo::ITexture> texs[] = {m_tex->GetBooTexture()};
for (int i = 0; i < 3; ++i) {
std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs;
constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
const std::array<boo::ObjToken<boo::ITexture>, 1> texs{m_tex->GetBooTexture()};
for (size_t i = 0; i < m_uniBuf.size(); ++i) {
m_uniBuf[i] = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
bufs[0] = m_uniBuf[i].get();
m_dataBind[i] = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr,
nullptr, 1, texs, nullptr, nullptr);
m_dataBind[i] =
ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), stages.data(),
nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
}
return true;
} BooTrace);
}