Exemple #1
0
GSOsdManager::GSOsdManager() : m_atlas_h(0)
                             , m_atlas_w(0)
                             , m_max_width(0)
                             , m_onscreen_messages(0)
                             , m_texture_dirty(true)
{
	m_log_enabled = theApp.GetConfigB("osd_log_enabled");
	m_log_timeout = std::max(2, std::min(theApp.GetConfigI("osd_log_timeout"), 10));
	m_monitor_enabled = theApp.GetConfigB("osd_monitor_enabled");
	m_opacity = std::max(0, std::min(theApp.GetConfigI("osd_color_opacity"), 100));
	m_max_onscreen_messages = theApp.GetConfigI("osd_max_log_messages");
	m_size = theApp.GetConfigI("osd_fontsize");

	int r = theApp.GetConfigI("osd_color_r");
	int g = theApp.GetConfigI("osd_color_g");
	int b = theApp.GetConfigI("osd_color_b");

	m_color = r | (g << 8) | (b << 16) | (255 << 24);

	if (FT_Init_FreeType(&m_library)) {
		m_face = NULL;
		fprintf(stderr, "Failed to init the freetype library\n");
		return;
	}

	LoadFont();

	/* The space character's width is used in GeneratePrimitives() */
	AddGlyph(' ');
}
Exemple #2
0
//
// Draw
//
void CFraps::Draw()
{
    // Make sure that ortho matrix is correct
    assert(m_Width);
    assert(m_Height);

    unsigned NumGlyphs = 0;
    int x = m_Width - (FRAPS_GLYPH_WIDTH + 2);
    int y = m_Height - (FRAPS_GLYPH_HEIGHT + 2);

    HUD_VERTEX *pData = new HUD_VERTEX[4 * FRAPS_MAX_STRING];
    HUD_VERTEX *pVertices = pData;

    if (pVertices)
    {
        const float du = 1.0f / FRAPS_NUM_GLYPHS; // We have 10 digits (0..9) in UV range 0..1
        float u;
        unsigned fps = m_fps;

        while (fps)
        {
            // "Eat" new digit
            unsigned Digit = fps % 10;
            fps /= 10;
            u = Digit * du;

            AddGlyph(pVertices, (float)x, (float)y, FRAPS_GLYPH_WIDTH, FRAPS_GLYPH_HEIGHT, u, 0.0f, u + du, 1.0f);
            ++NumGlyphs;

            pVertices += 4;
            x -= FRAPS_GLYPH_PITCH;
        }

        glBindBuffer(GL_ARRAY_BUFFER, m_VB);
        glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(HUD_VERTEX) * 4 * NumGlyphs, pData);
        delete[] pData;
    }

    BeginDraw();
    {
        glDrawElements(GL_TRIANGLES, NumGlyphs * 6, GL_UNSIGNED_SHORT, 0);
    }
    EndDraw();
}