2015-11-21 23:45:02 +00:00
|
|
|
#ifndef SPECTER_TEXTVIEW_HPP
|
|
|
|
#define SPECTER_TEXTVIEW_HPP
|
|
|
|
|
|
|
|
#include "View.hpp"
|
2015-11-25 01:46:30 +00:00
|
|
|
#include <boo/graphicsdev/GL.hpp>
|
|
|
|
#include <boo/graphicsdev/D3D.hpp>
|
|
|
|
#include <boo/graphicsdev/Metal.hpp>
|
|
|
|
|
|
|
|
#include "FontCache.hpp"
|
2015-11-21 23:45:02 +00:00
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
2015-11-26 00:24:01 +00:00
|
|
|
class ViewSystem;
|
2015-11-21 23:45:02 +00:00
|
|
|
|
|
|
|
class TextView : public View
|
|
|
|
{
|
2015-11-25 01:46:30 +00:00
|
|
|
boo::IGraphicsBufferD* m_glyphBuf;
|
|
|
|
const FontAtlas& m_fontAtlas;
|
2015-11-26 00:24:01 +00:00
|
|
|
boo::IVertexFormat* m_bgVtxFmt = nullptr; /* OpenGL only */
|
2015-11-25 01:46:30 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
class System
|
|
|
|
{
|
2015-11-26 00:24:01 +00:00
|
|
|
friend class ViewSystem;
|
2015-11-25 01:46:30 +00:00
|
|
|
friend class TextView;
|
2015-11-26 00:24:01 +00:00
|
|
|
FontCache* m_fcache = nullptr;
|
|
|
|
boo::IShaderPipeline* m_regular = nullptr;
|
|
|
|
boo::IShaderPipeline* m_subpixel = nullptr;
|
2015-11-25 01:46:30 +00:00
|
|
|
boo::IVertexFormat* m_vtxFmt = nullptr; /* Not OpenGL */
|
|
|
|
|
2015-11-26 00:24:01 +00:00
|
|
|
void init(boo::GLDataFactory* factory, FontCache* fcache);
|
2015-11-25 01:46:30 +00:00
|
|
|
#if _WIN32
|
2015-11-26 00:24:01 +00:00
|
|
|
void init(boo::ID3DDataFactory* factory, FontCache* fcache);
|
2015-11-25 01:46:30 +00:00
|
|
|
#elif BOO_HAS_METAL
|
2015-11-26 00:24:01 +00:00
|
|
|
void init(boo::MetalDataFactory* factory, FontCache* fcache);
|
2015-11-25 01:46:30 +00:00
|
|
|
#endif
|
2015-11-26 00:24:01 +00:00
|
|
|
};
|
2015-11-25 01:46:30 +00:00
|
|
|
|
2015-11-26 00:24:01 +00:00
|
|
|
TextView(ViewSystem& system, FontTag font, size_t initGlyphCapacity=256);
|
2015-11-25 01:46:30 +00:00
|
|
|
|
|
|
|
struct RenderGlyph
|
|
|
|
{
|
2015-11-26 00:24:01 +00:00
|
|
|
Zeus::CVector3f m_pos[4];
|
|
|
|
Zeus::CMatrix4f m_mv;
|
2015-11-25 01:46:30 +00:00
|
|
|
Zeus::CVector3f m_uv[4];
|
|
|
|
Zeus::CColor m_color;
|
2015-11-26 00:24:01 +00:00
|
|
|
|
|
|
|
RenderGlyph(int& adv, const FontAtlas::Glyph& glyph, Zeus::CColor defaultColor);
|
2015-11-25 01:46:30 +00:00
|
|
|
};
|
|
|
|
std::vector<RenderGlyph>& accessGlyphs() {return m_glyphs;}
|
|
|
|
void updateGlyphs() {m_validDynamicSlots = 0;}
|
|
|
|
|
|
|
|
void typesetGlyphs(const std::string& str,
|
|
|
|
Zeus::CColor defaultColor=Zeus::CColor::skWhite);
|
|
|
|
void typesetGlyphs(const std::wstring& str,
|
|
|
|
Zeus::CColor defaultColor=Zeus::CColor::skWhite);
|
|
|
|
|
|
|
|
void colorGlyphs(Zeus::CColor newColor);
|
|
|
|
void colorGlyphsTypeOn(Zeus::CColor newColor, float startInterval=0.2, float fadeTime=0.5);
|
|
|
|
void think();
|
2015-11-21 23:45:02 +00:00
|
|
|
|
2015-11-25 01:46:30 +00:00
|
|
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
2015-11-21 23:45:02 +00:00
|
|
|
|
2015-11-25 01:46:30 +00:00
|
|
|
private:
|
|
|
|
std::vector<RenderGlyph> m_glyphs;
|
2015-11-21 23:45:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SPECTER_TEXTVIEW_HPP
|