metaforce/Runtime/GuiSys/CTextRenderBuffer.hpp

114 lines
3.2 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-03-19 00:07:31 +00:00
#include <utility>
#include <vector>
#include "Runtime/CToken.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/Shaders/CTextSupportShader.hpp"
#include "Runtime/GuiSys/CFontImageDef.hpp"
#include "Runtime/GuiSys/CGuiWidget.hpp"
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CVector2f.hpp>
#include <zeus/CVector2i.hpp>
2016-03-22 08:15:00 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
class CGlyph;
2016-03-19 00:07:31 +00:00
class CGraphicsPalette;
class CRasterFont;
2016-12-30 06:37:01 +00:00
class CTextExecuteBuffer;
2016-03-19 00:07:31 +00:00
2016-03-21 22:01:19 +00:00
using CTextColor = zeus::CColor;
2018-12-08 05:30:43 +00:00
class CTextRenderBuffer {
friend class CGuiTextSupport;
friend class CTextSupportShader;
2016-03-19 00:07:31 +00:00
public:
2018-12-08 05:30:43 +00:00
enum class Command { CharacterRender, ImageRender, FontChange, PaletteChange };
2016-12-31 00:51:51 +00:00
#if 0
2016-03-19 00:07:31 +00:00
struct Primitive
{
2016-03-21 22:01:19 +00:00
CTextColor x0_color1;
2016-03-22 08:15:00 +00:00
Command x4_command;
u16 x8_xPos;
u16 xa_zPos;
char16_t xc_glyph;
2016-03-22 08:15:00 +00:00
u8 xe_imageIndex;
2016-03-19 00:07:31 +00:00
};
2016-12-31 00:51:51 +00:00
#endif
2018-12-08 05:30:43 +00:00
enum class EMode { AllocTally, BufferFill };
2016-03-22 08:15:00 +00:00
2016-03-19 00:07:31 +00:00
private:
2018-12-08 05:30:43 +00:00
EMode x0_mode;
2016-03-22 08:15:00 +00:00
#if 0
2016-03-19 00:07:31 +00:00
std::vector<TToken<CRasterFont>> x4_fonts;
std::vector<CFontImageDef> x14_images;
std::vector<int> x24_primOffsets;
2016-03-22 08:15:00 +00:00
std::vector<char> x34_bytecode;
2016-03-19 00:07:31 +00:00
u32 x44_blobSize = 0;
2016-03-22 08:15:00 +00:00
u32 x48_curBytecodeOffset = 0;
2016-12-31 00:51:51 +00:00
u8 x4c_activeFont;
2016-03-19 00:07:31 +00:00
u32 x50_paletteCount = 0;
2016-03-22 08:15:00 +00:00
std::array<std::unique_ptr<CGraphicsPalette>, 64> x54_palettes;
2016-03-19 00:07:31 +00:00
u32 x254_nextPalette = 0;
2016-03-22 08:15:00 +00:00
#else
2018-12-08 05:30:43 +00:00
/* Boo-specific text-rendering functionality */
2022-02-01 00:06:54 +00:00
// hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf;
// hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf2;
2018-12-08 05:30:43 +00:00
struct BooFontCharacters;
2018-12-08 05:30:43 +00:00
std::vector<BooFontCharacters> m_fontCharacters;
struct BooImage;
2018-12-08 05:30:43 +00:00
std::vector<BooImage> m_images;
struct BooPrimitiveMark;
2018-12-08 05:30:43 +00:00
std::vector<BooPrimitiveMark> m_primitiveMarks;
u32 m_imagesCount = 0;
u32 m_activeFontCh = UINT32_MAX;
2018-12-08 05:30:43 +00:00
zeus::CColor m_main;
zeus::CColor m_outline = zeus::skBlack;
2018-12-08 05:30:43 +00:00
CGuiWidget::EGuiModelDrawFlags m_drawFlags;
bool m_committed = false;
void CommitResources();
2016-03-22 08:15:00 +00:00
#endif
2016-03-19 00:07:31 +00:00
public:
CTextRenderBuffer(CTextRenderBuffer&& other) noexcept;
2018-12-08 05:30:43 +00:00
CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df);
~CTextRenderBuffer();
CTextRenderBuffer& operator=(CTextRenderBuffer&& other) noexcept;
2016-03-22 08:15:00 +00:00
#if 0
2016-03-19 00:07:31 +00:00
void SetPrimitive(const Primitive&, int);
Primitive GetPrimitive(int) const;
void GetOutStream();
void VerifyBuffer();
int GetMatchingPaletteIndex(const CGraphicsPalette& palette);
CGraphicsPalette* GetNextAvailablePalette();
2016-03-22 08:15:00 +00:00
void AddPaletteChange(const CGraphicsPalette& palette);
#else
2018-12-08 05:30:43 +00:00
void SetPrimitiveOpacity(int idx, float opacity);
u32 GetPrimitiveCount() const;
2016-03-22 08:15:00 +00:00
#endif
2018-12-08 05:30:43 +00:00
void SetMode(EMode mode);
void Render(const zeus::CColor& col, float time);
2018-12-08 05:30:43 +00:00
void AddImage(const zeus::CVector2i& offset, const CFontImageDef& image);
void AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color);
void AddPaletteChange(const zeus::CColor& main, const zeus::CColor& outline);
void AddFontChange(const TToken<CRasterFont>& font);
bool HasSpaceAvailable(const zeus::CVector2i& origin, const zeus::CVector2i& extent) const;
std::pair<zeus::CVector2i, zeus::CVector2i> AccumulateTextBounds() const;
2016-12-30 06:37:01 +00:00
};
2021-04-10 08:42:06 +00:00
} // namespace metaforce