16 char const* texels,
float const* characterData,
unsigned int maxMessageLength)
18 mMaxMessageLength(maxMessageLength)
30 mVertexBuffer = std::make_shared<VertexBuffer>(vformat, numVertices);
40 memset(vertices, 0, numVertices *
sizeof(Vertex));
43 Vertex&
v0 = vertices[4 * i + 0];
44 Vertex&
v1 = vertices[4 * i + 1];
45 Vertex&
v2 = vertices[4 * i + 2];
46 Vertex&
v3 = vertices[4 * i + 3];
48 v0.position[1] = 0.0f;
51 v2.position[1] = 0.0f;
58 vertices[0].position[0] = 0.0f;
59 vertices[1].position[0] = 0.0f;
68 sizeof(
unsigned int));
73 ibuf[6 * i + 0] = 4 * i;
74 ibuf[6 * i + 1] = 4 * i + 3;
75 ibuf[6 * i + 2] = 4 * i + 1;
78 ibuf[6 * i + 3] = 4 * i;
79 ibuf[6 * i + 4] = 4 * i + 2;
80 ibuf[6 * i + 5] = 4 * i + 3;
96 float const vdx = 1.0f /
static_cast<float>(viewportWidth);
97 float const vdy = 1.0f /
static_cast<float>(viewportHeight);
100 float tw =
static_cast<float>(
mTexture->GetWidth());
101 float th =
static_cast<float>(
mTexture->GetHeight());
104 unsigned int vertexSize =
mVertexBuffer->GetFormat().GetVertexSize();
108 unsigned int const length = std::min(
110 for (
unsigned int i = 0; i <
length; ++i)
113 int c =
static_cast<int>(message[i]);
116 float charWidthM1 = (tx1 - tx0)*tw - 1.0
f;
122 float*
v0 =
reinterpret_cast<float*
>(data + (4 * i + 0)*vertexSize);
123 float*
v1 =
reinterpret_cast<float*
>(data + (4 * i + 1)*vertexSize);
124 float*
v2 =
reinterpret_cast<float*
>(data + (4 * i + 2)*vertexSize);
125 float*
v3 =
reinterpret_cast<float*
>(data + (4 * i + 3)*vertexSize);
131 float x1 = x0 + charWidthM1*vdx;
156 float trnX = vdx*
static_cast<float>(
x);
157 float trnY = 1.0f - vdy*
static_cast<float>(
y);
GLsizei const GLchar *const * string
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
GLuint GLsizei const GLchar * message
GLfloat GLfloat GLfloat GLfloat v3
GLint GLsizei GLsizei height
void Typeset(int viewportWidth, int viewportHeight, int x, int y, Vector4< float > const &color, std::string const &message) const
GLuint GLsizei GLsizei * length
std::shared_ptr< IndexBuffer > mIndexBuffer
GLuint GLfloat GLfloat GLfloat x1
GLfloat GLfloat GLfloat v2
void Memcpy(void *target, void const *source, size_t count)
float mCharacterData[257]
std::shared_ptr< Texture2 > mTexture
Font(std::shared_ptr< ProgramFactory > const &factory, unsigned int width, unsigned int height, char const *texels, float const *characterData, unsigned int maxMessageLength)
std::shared_ptr< VertexBuffer > mVertexBuffer
std::shared_ptr< TextEffect > mTextEffect
unsigned int mMaxMessageLength