/* * Copyright © 2011 Linaro Limited * * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark. * * glmark2 is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * glmark2. If not, see <http://www.gnu.org/licenses/>. * * Authors: * Alexandros Frantzis (glmark2) */ #include "text-renderer.h" #include "gl-headers.h" #include "options.h" #include "scene.h" #include "shader-source.h" #include "vec.h" #include "mat.h" #include "texture.h" vec2; mat4; /* These are specific to the glyph texture atlas we are using */ static const unsigned int texture_size(512); static const vec2 glyph_size_pixels(29.0, 57.0); static const vec2 glyph_size(glyph_size_pixels/texture_size); /****************** * Public methods * ******************/ /** * TextRenderer default constructor. */ TextRenderer::TextRenderer(Canvas& canvas) : … { … } TextRenderer::~TextRenderer() { … } /** * Sets the text string to render. * * @param t the text string */ void TextRenderer::text(const std::string& t) { … } /** * Sets the screen position to render at. * * @param t the position */ void TextRenderer::position(const LibMatrix::vec2& p) { … } /** * Sets the size of each rendered glyph. * * The size corresponds to the width of each glyph * in normalized screen coordinates. * * @param s the size of each glyph */ void TextRenderer::size(float s) { … } /** * Renders the text. */ void TextRenderer::render() { … } /******************* * Private methods * *******************/ /** * Creates the geometry needed to render the text. * * This method assumes that the text VBOs are properly bound. */ void TextRenderer::create_geometry() { … } /** * Gets the texcoords of a glyph in the glyph texture atlas. * * @param c the character to get the glyph texcoords of * * @return the texcoords */ vec2 TextRenderer::get_glyph_coords(char c) { … }