2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-06-06 13:13:28 +00:00

CFogVolumeFilter: Make use of std::array where applicable

Makes data strongly typed and also allows for the removal of some
hardcoded array sizes.
This commit is contained in:
Lioncash 2020-03-17 18:46:41 -04:00
parent 7039232a95
commit b1e5bf72b6

View File

@ -1,5 +1,7 @@
#include "Runtime/Graphics/Shaders/CFogVolumeFilter.hpp" #include "Runtime/Graphics/Shaders/CFogVolumeFilter.hpp"
#include <array>
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Graphics/CBooRenderer.hpp" #include "Runtime/Graphics/CBooRenderer.hpp"
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
@ -28,24 +30,30 @@ CFogVolumeFilter::CFogVolumeFilter() {
struct Vert { struct Vert {
zeus::CVector2f m_pos; zeus::CVector2f m_pos;
zeus::CVector2f m_uv; zeus::CVector2f m_uv;
} verts[4] = { };
constexpr std::array<Vert, 4> verts{{
{{-1.0, -1.0}, {0.0, 0.0}}, {{-1.0, -1.0}, {0.0, 0.0}},
{{-1.0, 1.0}, {0.0, 1.0}}, {{-1.0, 1.0}, {0.0, 1.0}},
{{1.0, -1.0}, {1.0, 0.0}}, {{1.0, -1.0}, {1.0, 0.0}},
{{1.0, 1.0}, {1.0, 1.0}}, {{1.0, 1.0}, {1.0, 1.0}},
}; }};
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4); m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(Vert), verts.size());
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CColor), 1); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CColor), 1);
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(), const std::array<boo::ObjToken<boo::ITexture>, 3> texs{
g_Renderer->GetFogRampTex().get()}; CGraphics::g_SpareTexture.get(),
int bindIdxs[] = {0, 1, 0}; CGraphics::g_SpareTexture.get(),
bool bindDepth[] = {true, true, false}; g_Renderer->GetFogRampTex().get(),
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {m_uniBuf.get()}; };
constexpr std::array bindIdxs{0, 1, 0};
constexpr std::array bindDepth{true, true, false};
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> ubufs{m_uniBuf.get()};
m_dataBind1Way = ctx.newShaderDataBinding(s_1WayPipeline, m_vbo.get(), nullptr, nullptr, 1, ubufs, nullptr, nullptr, m_dataBind1Way =
nullptr, 3, texs, bindIdxs, bindDepth); ctx.newShaderDataBinding(s_1WayPipeline, m_vbo.get(), nullptr, nullptr, ubufs.size(), ubufs.data(), nullptr,
m_dataBind2Way = ctx.newShaderDataBinding(s_2WayPipeline, m_vbo.get(), nullptr, nullptr, 1, ubufs, nullptr, nullptr, nullptr, nullptr, texs.size(), texs.data(), bindIdxs.data(), bindDepth.data());
nullptr, 3, texs, bindIdxs, bindDepth); m_dataBind2Way =
ctx.newShaderDataBinding(s_2WayPipeline, m_vbo.get(), nullptr, nullptr, ubufs.size(), ubufs.data(), nullptr,
nullptr, nullptr, texs.size(), texs.data(), bindIdxs.data(), bindDepth.data());
return true; return true;
} BooTrace); } BooTrace);
} }