mirror of https://github.com/AxioDL/metaforce.git
CTextRenderBuffer: Remove use of const_cast in Render()
Makes for much less casting.
This commit is contained in:
parent
387e6a5733
commit
603942daaf
|
@ -160,26 +160,26 @@ void CTextRenderBuffer::SetPrimitiveOpacity(int idx, float opacity) {
|
||||||
|
|
||||||
u32 CTextRenderBuffer::GetPrimitiveCount() const { return m_primitiveMarks.size(); }
|
u32 CTextRenderBuffer::GetPrimitiveCount() const { return m_primitiveMarks.size(); }
|
||||||
|
|
||||||
void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const {
|
void CTextRenderBuffer::Render(const zeus::CColor& col, float time) {
|
||||||
const_cast<CTextRenderBuffer*>(this)->CommitResources();
|
CommitResources();
|
||||||
|
|
||||||
zeus::CMatrix4f mv = CGraphics::g_GXModelView.toMatrix4f();
|
const zeus::CMatrix4f mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||||
zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
const zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
zeus::CMatrix4f mat = proj * mv;
|
const zeus::CMatrix4f mat = proj * mv;
|
||||||
|
|
||||||
const_cast<CTextRenderBuffer*>(this)->m_uniBuf.access() = CTextSupportShader::Uniform{mat, col};
|
m_uniBuf.access() = CTextSupportShader::Uniform{mat, col};
|
||||||
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw) {
|
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw) {
|
||||||
zeus::CColor colPremul = col * col.a();
|
zeus::CColor colPremul = col * col.a();
|
||||||
colPremul.a() = col.a();
|
colPremul.a() = col.a();
|
||||||
const_cast<CTextRenderBuffer*>(this)->m_uniBuf2.access() = CTextSupportShader::Uniform{mat, colPremul};
|
m_uniBuf2.access() = CTextSupportShader::Uniform{mat, colPremul};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const BooFontCharacters& chs : m_fontCharacters) {
|
for (BooFontCharacters& chs : m_fontCharacters) {
|
||||||
if (chs.m_charData.size()) {
|
if (chs.m_charData.size()) {
|
||||||
if (chs.m_dirty) {
|
if (chs.m_dirty) {
|
||||||
memmove(const_cast<BooFontCharacters&>(chs).m_instBuf.access(), chs.m_charData.data(),
|
std::memmove(chs.m_instBuf.access(), chs.m_charData.data(),
|
||||||
sizeof(CTextSupportShader::CharacterInstance) * chs.m_charData.size());
|
sizeof(CTextSupportShader::CharacterInstance) * chs.m_charData.size());
|
||||||
const_cast<BooFontCharacters&>(chs).m_dirty = false;
|
chs.m_dirty = false;
|
||||||
}
|
}
|
||||||
CGraphics::SetShaderDataBinding(chs.m_dataBinding);
|
CGraphics::SetShaderDataBinding(chs.m_dataBinding);
|
||||||
CGraphics::DrawInstances(0, 4, chs.m_charData.size());
|
CGraphics::DrawInstances(0, 4, chs.m_charData.size());
|
||||||
|
@ -190,12 +190,12 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const BooImage& img : m_images) {
|
for (BooImage& img : m_images) {
|
||||||
if (img.m_dirty) {
|
if (img.m_dirty) {
|
||||||
*const_cast<BooImage&>(img).m_instBuf.access() = img.m_imageData;
|
*img.m_instBuf.access() = img.m_imageData;
|
||||||
const_cast<BooImage&>(img).m_dirty = false;
|
img.m_dirty = false;
|
||||||
}
|
}
|
||||||
int idx = int(img.m_imageDef.x0_fps * time) % img.m_dataBinding.size();
|
const int idx = int(img.m_imageDef.x0_fps * time) % img.m_dataBinding.size();
|
||||||
CGraphics::SetShaderDataBinding(img.m_dataBinding[idx]);
|
CGraphics::SetShaderDataBinding(img.m_dataBinding[idx]);
|
||||||
CGraphics::DrawInstances(0, 4, 1);
|
CGraphics::DrawInstances(0, 4, 1);
|
||||||
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw) {
|
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw) {
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
u32 GetPrimitiveCount() const;
|
u32 GetPrimitiveCount() const;
|
||||||
#endif
|
#endif
|
||||||
void SetMode(EMode mode);
|
void SetMode(EMode mode);
|
||||||
void Render(const zeus::CColor& col, float) const;
|
void Render(const zeus::CColor& col, float time);
|
||||||
void AddImage(const zeus::CVector2i& offset, const CFontImageDef& image);
|
void AddImage(const zeus::CVector2i& offset, const CFontImageDef& image);
|
||||||
void AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color);
|
void AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color);
|
||||||
void AddPaletteChange(const zeus::CColor& main, const zeus::CColor& outline);
|
void AddPaletteChange(const zeus::CColor& main, const zeus::CColor& outline);
|
||||||
|
|
Loading…
Reference in New Issue