Changeset 1966


Ignore:
Timestamp:
Oct 3, 2012, 12:40:24 AM (5 years ago)
Author:
sam
Message:

neercs: use two different text rendering objects for the screen and
the setup.

Location:
trunk/tools/neercs/video
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/video/render.cpp

    r1962 r1966  
    130130int setup_item_p = 0;           // item position
    131131int setup_item_key = 0;         // item array key
    132 ivec2 setup_p(1,1);             // position [x,y]
    133132ivec3 setup_size(29,9,12);      // size [w,h,split]
    134133ivec2 setup_color(0xaaa,0x222); // color [foreground,background] 0x678,0x234
     
    395394    border = (screen_size - canvas_size) / 2;
    396395
    397     caca_set_canvas_size(m_caca, canvas_char.x, canvas_char.y);
    398 
    399     setup_p = (canvas_char - setup_size.xy) / 2;
     396    caca_set_canvas_size(m_cv_screen, canvas_char.x, canvas_char.y);
    400397}
    401398
     
    462459FrameBuffer *fbo_back, *fbo_front, *fbo_buffer;
    463460FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_tmp;
    464 
    465 TextRender *text_render;
    466461
    467462void Render::TraceQuad()
     
    566561
    567562Render::Render(caca_canvas_t *caca)
    568   : m_caca(caca),
     563  : m_cv_screen(caca),
     564    m_cv_setup(caca_create_canvas(1, 1)),
    569565    m_ready(false),
    570566    m_pause(false),
     
    580576    m_shader_postfx(true)
    581577{
    582     text_render = new TextRender(m_caca, font_size);
     578    m_txt_screen = new TextRender(m_cv_screen, font_size);
     579    m_txt_setup = new TextRender(m_cv_setup, font_size);
    583580}
    584581
     
    588585
    589586    /* draw LOLCUBE */
    590     caca_set_color_argb(m_caca, 0xfff, 0x000);
    591     caca_put_str(m_caca, canvas_char.x -  8, canvas_char.y - 6, "_______");
    592     caca_put_str(m_caca, canvas_char.x -  9, canvas_char.y - 5, "/      /|");
    593     caca_put_str(m_caca, canvas_char.x - 10, canvas_char.y - 4, "/______/ |");
    594     caca_put_str(m_caca, canvas_char.x - 10, canvas_char.y - 3, "|      | |");
    595     caca_put_str(m_caca, canvas_char.x - 10, canvas_char.y - 2, "|  :D  | /");
    596     caca_put_str(m_caca, canvas_char.x - 10, canvas_char.y - 1, "|______|/");
     587    caca_set_color_argb(m_cv_screen, 0xfff, 0x000);
     588    caca_put_str(m_cv_screen, canvas_char.x -  8, canvas_char.y - 6, "_______");
     589    caca_put_str(m_cv_screen, canvas_char.x -  9, canvas_char.y - 5, "/      /|");
     590    caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 4, "/______/ |");
     591    caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 3, "|      | |");
     592    caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 2, "|  :D  | /");
     593    caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 1, "|______|/");
    597594
    598595    /* draw setup */
    599596    if (m_setup)
    600597    {
     598        caca_set_canvas_size(m_cv_setup, setup_size.x, setup_size.y);
     599
    601600        /* background */
    602         caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
    603         caca_fill_box(m_caca, setup_p.x, setup_p.y, setup_size.x + 1, setup_size.y,' ');
    604         caca_draw_line(m_caca, setup_p.x + setup_size.z - 1, setup_p.y + 1, setup_p.x + setup_size.z - 1, setup_p.y + setup_size.y - 1,'|');
     601        caca_set_color_argb(m_cv_setup, setup_color.x, setup_color.y);
     602        caca_fill_box(m_cv_setup, 0, 0, setup_size.x + 1, setup_size.y,' ');
     603        caca_draw_line(m_cv_setup, setup_size.z - 1, 1, setup_size.z - 1, setup_size.y - 1,'|');
    605604        /* title */
    606         caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
    607         caca_draw_line(m_caca, setup_p.x, setup_p.y, setup_p.x + setup_size.x, setup_p.y,' ');
    608         caca_put_str(m_caca, setup_p.x + setup_size.x / 2 - 3, setup_p.y, "SETUP");
     605        caca_set_color_argb(m_cv_setup, setup_color.y, setup_color.x);
     606        caca_draw_line(m_cv_setup, 0, 0, setup_size.x, 0, ' ');
     607        caca_put_str(m_cv_setup, setup_size.x / 2 - 3, 0, "SETUP");
    609608        /* display option */
    610609        for (int i = 0; i < setup_h; i++)
    611610        {
    612             int y = setup_p.y + 1 + i;
     611            int y = 1 + i;
    613612            int k = (setup_option_p + i) * (setup_item_n + 1);
    614613            if (setup_option_i != setup_option_p + i || setup_switch)
    615614            {
    616                 caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
    617                 caca_put_str(m_caca, setup_p.x + 1, y, setup_text[k]);
     615                caca_set_color_argb(m_cv_setup, setup_color.x, setup_color.y);
     616                caca_put_str(m_cv_setup, 1, y, setup_text[k]);
    618617            }
    619618            else
    620619            {
    621                 caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
    622                 caca_draw_line(m_caca, setup_p.x, y, setup_p.x + setup_size.z - 2, y,' ');
    623                 caca_put_str(m_caca, setup_p.x + 1, y, setup_text[k]);
     620                caca_set_color_argb(m_cv_setup, setup_color.y, setup_color.x);
     621                caca_draw_line(m_cv_setup, 0, y, setup_size.z - 2, y,' ');
     622                caca_put_str(m_cv_setup, 1, y, setup_text[k]);
    624623            }
    625624        }
     
    627626        for (int i = 0; i < setup_h; i++)
    628627        {
    629             int y = setup_p.y + 1 + i;
     628            int y = 1 + i;
    630629            int k = setup_option_i * (setup_item_n + 1) + 1 + setup_item_p + i;
    631630            if (setup_item_i != setup_item_p + i || !setup_switch)
    632631            {
    633                 caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
    634                 caca_put_str(m_caca, setup_p.x + setup_size.z + 1, y, setup_text[k]);
     632                caca_set_color_argb(m_cv_setup, setup_color.x, setup_color.y);
     633                caca_put_str(m_cv_setup, setup_size.z + 1, y, setup_text[k]);
    635634            }
    636635            else
    637636            {
    638                 caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
    639                 caca_draw_line(m_caca, setup_p.x + setup_size.z, y, setup_p.x + setup_size.x, y,' ');
    640                 caca_put_str(m_caca, setup_p.x + setup_size.z + 1, y, setup_text[k]);
     637                caca_set_color_argb(m_cv_setup, setup_color.y, setup_color.x);
     638                caca_draw_line(m_cv_setup, setup_size.z, y, setup_size.x, y,' ');
     639                caca_put_str(m_cv_setup, setup_size.z + 1, y, setup_text[k]);
    641640            }
    642641        }
    643642        /* display variable */
    644         int y = setup_p.y + setup_size.y;
     643        int y = setup_size.y;
    645644        setup_item_key = setup_option_i * (setup_item_n + 1) + 1 + setup_item_i;
    646         caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
    647         caca_draw_line(m_caca, setup_p.x, y, setup_p.x + setup_size.x, y,' ');
     645        caca_set_color_argb(m_cv_setup, setup_color.y, setup_color.x);
     646        caca_draw_line(m_cv_setup, 0, y, setup_size.x, y,' ');
    648647        if (setup_switch)
    649648        {
    650             int x = setup_p.x + 1;
     649            int x = 1;
    651650            int w = setup_size.x - 3 - 4;
    652651            float bar_w = w / (setup_var[setup_item_key].y - setup_var[setup_item_key].x);
     
    655654            {
    656655                /* Work around a bug in libcaca */
    657                 if (setup_p.x + setup_size.x - 4 < caca_get_canvas_width(m_caca)) caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w);
    658                 caca_draw_line(m_caca, x, y, x - bar_x + int(bar_w * setup_var[setup_item_key].y), y,'.');
    659                 if (setup_var[setup_item_key].w != setup_var[setup_item_key].x) caca_draw_line(m_caca, x, y, x - bar_x + int(bar_w * setup_var[setup_item_key].w), y, 'x');
     656                if (setup_size.x - 4 < caca_get_canvas_width(m_cv_setup)) caca_printf(m_cv_setup, setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w);
     657                caca_draw_line(m_cv_setup, x, y, x - bar_x + int(bar_w * setup_var[setup_item_key].y), y,'.');
     658                if (setup_var[setup_item_key].w != setup_var[setup_item_key].x) caca_draw_line(m_cv_setup, x, y, x - bar_x + int(bar_w * setup_var[setup_item_key].w), y, 'x');
    660659            }
    661660            else
     
    663662                if (setup_var[setup_item_key] != vec4(0))
    664663                {
    665                     caca_put_str(m_caca, setup_p.x + setup_size.x - 3, y, (setup_var[setup_item_key].w == setup_var[setup_item_key].y)?"YES":" NO");
     664                    caca_put_str(m_cv_setup, setup_size.x - 3, y, (setup_var[setup_item_key].w == setup_var[setup_item_key].y)?"YES":" NO");
    666665                }
    667666            }
     
    669668        else
    670669        {
    671             caca_printf(m_caca, setup_p.x + 1, y, "%d/%d", setup_option_i, setup_n);
     670            caca_printf(m_cv_setup, 1, y, "%d/%d", setup_option_i, setup_n);
    672671        }
    673672
    674673        /* informations */
    675         int w = caca_get_canvas_width(m_caca);
    676         int h = caca_get_canvas_height(m_caca);
    677         caca_set_color_argb(m_caca, 0xfff, 0x000);
    678         caca_printf(m_caca, 0, 0, "%i*%i", w, h);
     674        int w = caca_get_canvas_width(m_cv_setup);
     675        int h = caca_get_canvas_height(m_cv_setup);
     676        caca_set_color_argb(m_cv_setup, 0xfff, 0x000);
     677        caca_printf(m_cv_setup, 0, 0, "%i*%i", w, h);
    679678    }
    680679
     
    967966    {
    968967        CreateGLWindow();
    969         text_render->Init();
     968        m_txt_screen->Init();
     969        m_txt_setup->Init();
    970970        m_ready = true;
    971971    }
     
    10251025{
    10261026    /* Draw text in an offline buffer */
    1027     text_render->Render();
     1027    m_txt_screen->Render();
     1028
     1029    if (m_setup)
     1030        m_txt_setup->Render();
    10281031
    10291032    if (m_shader)
     
    10401043    Video::Clear(ClearMask::Color | ClearMask::Depth);
    10411044
    1042     text_render->Blit(border, canvas_size);
     1045    m_txt_screen->Blit(border, canvas_size);
     1046    if (m_setup)
     1047        m_txt_setup->Blit(border, canvas_size);
    10431048
    10441049    //if (m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
  • trunk/tools/neercs/video/render.h

    r1874 r1966  
    3131    void UpdateSize();
    3232
    33     caca_canvas_t *m_caca;
     33    caca_canvas_t *m_cv_screen, *m_cv_setup;
     34    class TextRender *m_txt_screen, *m_txt_setup;
     35
    3436    bool m_ready;
    3537    bool m_pause;
Note: See TracChangeset for help on using the changeset viewer.