Tweaking the example text renderer

This commit is contained in:
Brad Davis 2015-02-02 09:26:09 -08:00
parent e71b61a256
commit 8d81607e28
3 changed files with 6 additions and 4 deletions

View file

@ -380,7 +380,7 @@ glm::vec2 Font::drawString(
//}
// Stores how far we've moved from the start of the string, in DTP units
static const float SPACE_ADVANCE = getGlyph(' ').d;
static const float SPACE_ADVANCE = getGlyph('J').d;
glm::vec2 advance(0, -_ascent);
MatrixStack::withGlMatrices([&] {
// Fetch the matrices out of GL
@ -397,7 +397,7 @@ glm::vec2 Font::drawString(
MatrixStack & pr = MatrixStack::projection();
// scale the modelview into font units
mv.translate(glm::vec2(x, y)).scale(glm::vec3(scale, -scale, scale));
//mv.translate(glm::vec3(0, _ascent, 0));
foreach(QString token, str.split(" ")) {
// float tokenWidth = measureWidth(token, fontSize);
// if (wrap && 0 != advance.x && (advance.x + tokenWidth) > maxWidth) {

View file

@ -3,6 +3,7 @@ set(TARGET_NAME render-utils-tests)
setup_hifi_project(Quick)
include_glm()
#include_oglplus()
# link in the shared libraries

View file

@ -139,7 +139,7 @@ void QTestWindow::makeCurrent() {
m_context->makeCurrent(this);
}
static const char * EXAMPLE_TEXT = "Hello 1.0\nline 2";
static const wchar_t * EXAMPLE_TEXT = L"Hello 1.0\nline 2\ndescent ggg\nascent ÁÁÁ";
static const glm::uvec2 QUAD_OFFSET(10, 20);
static const glm::vec3 COLORS[4] = {
{ 1, 1, 1 },
@ -181,8 +181,9 @@ void QTestWindow::draw() {
glVertex2f(size.x, _size.height());
glEnd();
}
QString str = QString::fromWCharArray(EXAMPLE_TEXT);
for (int i = 0; i < 4; ++i) {
_textRenderer[i]->draw(offsets[i].x, offsets[i].y, EXAMPLE_TEXT, glm::vec4(COLORS[i], 1.0f));
_textRenderer[i]->drawString(offsets[i].x, offsets[i].y, str, glm::vec4(COLORS[i], 1.0f));
}
m_context->swapBuffers(this);
}