示例#1
0
文件: qcn_cube.cpp 项目: happyj/qcn
void CCube::RenderText()
{   // this draws the necessary text for the cube view
    // draw text on top

    if (! bIsQCNLive) {
        char buf[256];
        // left of window informative text
        if (!qcn_graphics::g_bFullScreen)  { // don't show the button press text in fullscreen/screensaver mode
            mode_unshaded();
            qcn_graphics::mode_ortho_qcn();
            sprintf(buf, "Press 'Q' to return to");
            TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .32, 0, MSG_SIZE_NORMAL, yellow, TTF_ARIAL, buf);
            sprintf(buf, "seismic sensor view");
            TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .30, 0, MSG_SIZE_NORMAL, yellow, TTF_ARIAL, buf);
            ortho_done();
        }

        // print a "legend"
        mode_unshaded();
        qcn_graphics::mode_ortho_qcn();
        TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .27, 0, MSG_SIZE_NORMAL, red, TTF_ARIAL, "Red is Significance");
        TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .25, 0, MSG_SIZE_NORMAL, blue, TTF_ARIAL, "Blue is Z-axis");
        TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .23, 0, MSG_SIZE_NORMAL, yellow, TTF_ARIAL, "Yellow is Y-axis");
        TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .21, 0, MSG_SIZE_NORMAL, green, TTF_ARIAL, "Green is X-axis");
        TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .19, 0, MSG_SIZE_NORMAL, cyan, TTF_ARIAL, "Cyan is Magnitude");
        TTFont::ttf_render_string(qcn_graphics::cfTextAlpha, 0, .17, 0, MSG_SIZE_NORMAL, magenta, TTF_ARIAL, "Magenta is Variance");
        ortho_done();
    }
    // NB: draw_text_user called automatically from qcn_graphics to show BOINC username, CPU time etc
}
示例#2
0
// draw a rectangle of the given color in the XY plane
// and draw the given test in it
//
void MOVING_TEXT_PANEL::draw() {
    COLOR side_color = color;
    GLfloat pos0[3], pos1[3], pos2[3], pos3[3];
    memcpy(pos0, pos, sizeof(pos0));
    memcpy(pos1, pos, sizeof(pos0));
    pos1[0] += size[0];
    memcpy(pos2, pos1, sizeof(pos0));
    pos2[1] += size[1];
    memcpy(pos3, pos2, sizeof(pos0));
    pos3[0] -= size[0];
    mode_unshaded();
    glColor4fv(&color.r);
    glBegin(GL_QUADS);
    glVertex3fv(pos0);
    glVertex3fv(pos1);
    glVertex3fv(pos2);
    glVertex3fv(pos3);

    // draw flanges
    //
    side_color.r /= 2;
    side_color.g /= 2;
    side_color.b /= 2;
    glColor4fv(&side_color.r);
    GLfloat posa0[3], posa1[3], posa2[3], posa3[3];
    memcpy(posa0, pos0, sizeof(pos0));
    memcpy(posa1, pos1, sizeof(pos0));
    memcpy(posa2, pos2, sizeof(pos0));
    memcpy(posa3, pos3, sizeof(pos0));
    posa0[2] -= .2;
    posa1[2] -= .2;
    posa2[2] -= .2;
    posa3[2] -= .2;
    glVertex3fv(pos0);
    glVertex3fv(pos1);
    glVertex3fv(posa1);
    glVertex3fv(posa0);
    glVertex3fv(pos1);
    glVertex3fv(pos2);
    glVertex3fv(posa2);
    glVertex3fv(posa1);
    glVertex3fv(pos2);
    glVertex3fv(pos3);
    glVertex3fv(posa3);
    glVertex3fv(posa2);
    glVertex3fv(pos3);
    glVertex3fv(pos0);
    glVertex3fv(posa0);
    glVertex3fv(posa3);
    glEnd();

    pos3[0] += margin;
    pos3[1] -= (margin+char_height);
    pos3[2] += 0.01;
    glColor3f(1, 1, 1);
    for (int i=0; i<PANEL_MAX_LINES; i++) {
        if (strlen(text[i])) {
            draw_text(pos3, char_height, line_width, line_spacing, text[i]);
        }
        pos3[1] -= line_spacing;
    }
}