mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 11: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:
@@ -1,5 +1,7 @@
|
||||
#include "Runtime/Graphics/Shaders/CAABoxShader.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
#include <hecl/Pipeline.hpp>
|
||||
@@ -24,16 +26,17 @@ 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);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
m_dataBind = ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
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) {
|
||||
zeus::CVector3f vboData[] = {
|
||||
const std::array<zeus::CVector3f, 34> vboData{{
|
||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()}, {aabb.max.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.max.z()}, {aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||
@@ -57,9 +60,9 @@ void CAABoxShader::setAABB(const zeus::CAABox& aabb) {
|
||||
{aabb.min.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.min.z()}, {aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
||||
};
|
||||
}};
|
||||
|
||||
m_vbo->load(vboData, sizeof(zeus::CVector3f) * 34);
|
||||
m_vbo->load(vboData.data(), sizeof(vboData));
|
||||
}
|
||||
|
||||
void CAABoxShader::draw(const zeus::CColor& color) {
|
||||
|
||||
Reference in New Issue
Block a user