101 lines
2.0 KiB
C++
101 lines
2.0 KiB
C++
/*
|
|
ZSolidFontRenderer.hpp
|
|
Author: Patrick Baggett <ptbaggett@762studios.com>
|
|
|
|
Purpose: TODO
|
|
|
|
Changelog
|
|
2011/09/18 - creation (ptbaggett)
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifndef _ZSOLIDFONTRENDERER_H
|
|
#define _ZSOLIDFONTRENDERER_H
|
|
|
|
#include <SST/SST_Mat44.h>
|
|
|
|
#include <ZRenderer/ZRenderer.hpp>
|
|
#include <ZRenderer/ZDataBuffer.hpp>
|
|
#include <ZRendererUtil/ZFontRendererBase.hpp>
|
|
#include <ZRendererUtil/ZSolidFontFace.hpp>
|
|
|
|
#include <ft2build.h>
|
|
#include FT_FREETYPE_H
|
|
|
|
#define TRICACHE_SIZE (8*1024) //Cache up to 8K polygons before drawing
|
|
|
|
class ZSolidFontRenderer : public ZFontRendererBase
|
|
{
|
|
protected:
|
|
ZRenderer* renderer;
|
|
ZPtr<ZDataBuffer> tricache;
|
|
|
|
const ZDataBufferStream* posstream;
|
|
const ZDataBufferStream* colorstream;
|
|
const ZDataBufferBlock* matrixBlock;
|
|
const ZDataBufferBlock* indexBlock;
|
|
|
|
ZPtr<ZShaderProgram> shaderprogram;
|
|
ZPtr<ZShaderParams> shaderparams;
|
|
ZPtr<ZIndexParams> indexparams;
|
|
ZPtr<ZVertexParams> vertexparams;
|
|
|
|
ZPtr<ZDataBuffer> uniforms;
|
|
ZPtr<ZDataBuffer> indexes;
|
|
|
|
ZFrameContext ctx;
|
|
SST_Mat44f xform;
|
|
|
|
//Internal used struct for vertex / color pairing
|
|
struct SolidVertex
|
|
{
|
|
float x, y;
|
|
float rgba[4];
|
|
};
|
|
|
|
SolidVertex* vtx_dma;
|
|
FT_Library library;
|
|
float color[4];
|
|
size_t nrTrisWritten;
|
|
bool inRendering;
|
|
|
|
void flushTriCache();
|
|
|
|
public:
|
|
|
|
/*
|
|
Constructor.
|
|
|
|
@param _renderer - the current renderer instance.
|
|
*/
|
|
ZSolidFontRenderer(ZRenderer* _renderer);
|
|
|
|
/*
|
|
Destructor.
|
|
*/
|
|
virtual ~ZSolidFontRenderer();
|
|
|
|
//Subclass Implementation
|
|
virtual ZFontFace CreateFontFace(int pixelSize, const void* fontData, unsigned int dataSize);
|
|
|
|
//Subclass Implementation
|
|
virtual void DeleteFontFace(ZFontFace face);
|
|
|
|
//Subclass Implementation
|
|
virtual void BeginText(ZFrameContext _ctx, const SST_Mat44f& _xform);
|
|
|
|
//Subclass Implementation
|
|
virtual void EndText();
|
|
|
|
//Subclass Implementation
|
|
virtual void RenderText(int x, int y, const char* text);
|
|
|
|
//Subclass Implementation
|
|
virtual void ComputeBounds(const char* text, ZFontBounds* bounds);
|
|
|
|
//Subclass Implementation
|
|
virtual void SetColor(float r, float g, float b, float a);
|
|
};
|
|
|
|
#endif |