metaforce/Runtime/Graphics/Shaders/CTextSupportShader.hpp

101 lines
3.0 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2017-01-29 03:58:16 +00:00
#include <array>
#include "Runtime/GuiSys/CGuiWidget.hpp"
#include <hecl/UniformBufferPool.hpp>
#include <hecl/VertexBufferPool.hpp>
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CVector2f.hpp>
#include <zeus/CVector2i.hpp>
#include <zeus/CVector3f.hpp>
2017-01-29 03:58:16 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2017-01-29 03:58:16 +00:00
class CGlyph;
2017-01-30 06:58:59 +00:00
class CFontImageDef;
class CTextRenderBuffer;
2017-01-29 03:58:16 +00:00
2018-12-08 05:30:43 +00:00
class CTextSupportShader {
friend class CTextRenderBuffer;
static boo::ObjToken<boo::IShaderPipeline> s_TextAlphaPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_TextAddPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_TextAddOverdrawPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_ImageAlphaPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_ImageAddPipeline;
static boo::ObjToken<boo::IShaderPipeline> s_ImageAddOverdrawPipeline;
struct Uniform {
zeus::CMatrix4f m_mvp;
zeus::CColor m_uniformColor;
};
struct CharacterInstance {
std::array<zeus::CVector3f, 4> m_pos;
std::array<zeus::CVector3f, 4> m_uv;
2018-12-08 05:30:43 +00:00
zeus::CColor m_fontColor;
zeus::CColor m_outlineColor;
zeus::CColor m_mulColor;
void SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset);
};
struct ImageInstance {
std::array<zeus::CVector3f, 4> m_pos;
std::array<zeus::CVector2f, 4> m_uv;
2018-12-08 05:30:43 +00:00
zeus::CColor m_color;
void SetMetrics(const CFontImageDef& imgDef, const zeus::CVector2i& offset);
};
static hecl::VertexBufferPool<CharacterInstance> s_CharInsts;
static hecl::VertexBufferPool<ImageInstance> s_ImgInsts;
static hecl::UniformBufferPool<Uniform> s_Uniforms;
2017-01-29 03:58:16 +00:00
public:
2018-12-08 05:30:43 +00:00
static boo::ObjToken<boo::IShaderPipeline> SelectTextPipeline(CGuiWidget::EGuiModelDrawFlags df) {
switch (df) {
case CGuiWidget::EGuiModelDrawFlags::Shadeless:
case CGuiWidget::EGuiModelDrawFlags::Opaque:
case CGuiWidget::EGuiModelDrawFlags::Alpha:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_TextAlphaPipeline;
case CGuiWidget::EGuiModelDrawFlags::Additive:
return s_TextAddPipeline;
default:
return {};
2017-01-29 03:58:16 +00:00
}
2018-12-08 05:30:43 +00:00
}
static boo::ObjToken<boo::IShaderPipeline> SelectImagePipeline(CGuiWidget::EGuiModelDrawFlags df) {
switch (df) {
case CGuiWidget::EGuiModelDrawFlags::Shadeless:
case CGuiWidget::EGuiModelDrawFlags::Opaque:
case CGuiWidget::EGuiModelDrawFlags::Alpha:
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
return s_ImageAlphaPipeline;
case CGuiWidget::EGuiModelDrawFlags::Additive:
return s_ImageAddPipeline;
default:
return {};
2017-01-29 03:58:16 +00:00
}
2018-12-08 05:30:43 +00:00
}
2017-01-29 03:58:16 +00:00
2018-12-08 05:30:43 +00:00
static boo::ObjToken<boo::IShaderPipeline> GetTextAdditiveOverdrawPipeline() { return s_TextAddOverdrawPipeline; }
2018-12-08 05:30:43 +00:00
static boo::ObjToken<boo::IShaderPipeline> GetImageAdditiveOverdrawPipeline() { return s_ImageAddOverdrawPipeline; }
2018-12-08 05:30:43 +00:00
static void UpdateBuffers() {
s_CharInsts.updateBuffers();
s_ImgInsts.updateBuffers();
s_Uniforms.updateBuffers();
}
2018-12-08 05:30:43 +00:00
static void Initialize();
static void Shutdown();
2017-01-29 03:58:16 +00:00
};
2021-04-10 08:42:06 +00:00
} // namespace metaforce