Changeset 1625


Ignore:
Timestamp:
Jul 11, 2012, 6:28:16 PM (11 years ago)
Author:
rez
Message:

updated border autoresize + canvas resize

Location:
trunk/tools/neercs
Files:
3 edited

Legend:

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

    r1622 r1625  
    4747Neercs::Neercs()
    4848  : m_ready(false),
    49     m_caca(caca_create_canvas(47, 32)),
     49    m_caca(caca_create_canvas(10, 10)),
    5050    m_render(new Render(m_caca)),
    5151    m_time(0.f)
  • trunk/tools/neercs/video/render.cpp

    r1624 r1625  
    8282float beat_speed = 2.0f;   // speed
    8383/* window variable */
    84 ivec2 border;            // margin
    85 int window_vtx[8];         // vertex array
     84ivec2 border;              // border width
    8685/* text variable */
    8786ivec2 ratio_2d(2,2);       // 2d ratio
    8887ivec2 map_size(256,256);   // texture map size
    8988ivec2 font_size(8,8);      // font size
    90 ivec2 text_size(0,0);      // text size
    91 ivec2 blit_top(0,0);       // text blit top position
    92 ivec2 blit_bottom(0,0);    // text blit bottom position
     89ivec2 canvas_char(0,0);    // canvas char number
     90ivec2 canvas_size(0,0);    // caca size
    9391/* common variable */
    9492float value, angle, radius, scale, speed;
     
    175173    glCullFace(GL_BACK);      // don't draw front face
    176174
    177     /* Initialise framebuffer objects */
    178     fbo_back = new FrameBuffer(screen_size);
    179     fbo_front = new FrameBuffer(screen_size);
    180     fbo_blur_h = new FrameBuffer(screen_size / glow_fbo_size);
    181     fbo_blur_v = new FrameBuffer(screen_size / glow_fbo_size);
    182     fbo_ping = new FrameBuffer(screen_size);
    183     fbo_pong = new FrameBuffer(screen_size);
    184     // shader simple
    185     shader_simple = Shader::Create(lolfx_simple);
    186     shader_simple_texture = shader_simple->GetUniformLocation("texture");
    187     // shader blur horizontal
    188     shader_blur_h = Shader::Create(lolfx_blurh);
    189     shader_blur_h_texture = shader_blur_h->GetUniformLocation("texture");
    190     shader_blur_h_screen_size = shader_blur_h->GetUniformLocation("screen_size");
    191     shader_blur_h_time = shader_blur_h->GetUniformLocation("time");
    192     shader_blur_h_value = shader_blur_h->GetUniformLocation("value");
    193     // shader blur vertical
    194     shader_blur_v = Shader::Create(lolfx_blurv);
    195     shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
    196     shader_blur_v_screen_size = shader_blur_v->GetUniformLocation("screen_size");
    197     shader_blur_v_time = shader_blur_v->GetUniformLocation("time");
    198     shader_blur_v_value = shader_blur_v->GetUniformLocation("value");
    199     // shader glow
    200     shader_glow = Shader::Create(lolfx_glow);
    201     shader_glow_texture = shader_glow->GetUniformLocation("texture");
    202     shader_glow_texture_prv = shader_glow->GetUniformLocation("texture_prv");
    203     shader_glow_screen_size = shader_glow->GetUniformLocation("screen_size");
    204     shader_glow_time = shader_glow->GetUniformLocation("time");
    205     shader_glow_step = shader_glow->GetUniformLocation("step");
    206     shader_glow_value1 = shader_glow->GetUniformLocation("value1");
    207     shader_glow_value2 = shader_glow->GetUniformLocation("value2");
    208     // shader radial
    209     shader_radial = Shader::Create(lolfx_radial);
    210     shader_radial_texture = shader_radial->GetUniformLocation("texture");
    211     shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
    212     shader_radial_time = shader_radial->GetUniformLocation("time");
    213     shader_radial_value1 = shader_radial->GetUniformLocation("value1");
    214     shader_radial_value2 = shader_radial->GetUniformLocation("value2");
    215     shader_radial_color = shader_radial->GetUniformLocation("color");
    216     // shader postfx
    217     shader_postfx = Shader::Create(lolfx_postfx);
    218     shader_postfx_texture = shader_postfx->GetUniformLocation("texture");
    219     shader_postfx_texture_2d = shader_postfx->GetUniformLocation("texture_2d");
    220     shader_postfx_screen_size = shader_postfx->GetUniformLocation("screen_size");
    221     shader_postfx_time = shader_postfx->GetUniformLocation("time");
    222     shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
    223     shader_postfx_value = shader_postfx->GetUniformLocation("value");
    224     shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
    225     shader_postfx_scanline = shader_postfx->GetUniformLocation("scanline");
    226     shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
     175    if (m_shader)
     176    {
     177        /* Initialise framebuffer objects */
     178        fbo_back = new FrameBuffer(screen_size);
     179        fbo_front = new FrameBuffer(screen_size);
     180        fbo_blur_h = new FrameBuffer(screen_size / glow_fbo_size);
     181        fbo_blur_v = new FrameBuffer(screen_size / glow_fbo_size);
     182        fbo_ping = new FrameBuffer(screen_size);
     183        fbo_pong = new FrameBuffer(screen_size);
     184        // shader simple
     185        shader_simple = Shader::Create(lolfx_simple);
     186        shader_simple_texture = shader_simple->GetUniformLocation("texture");
     187        // shader blur horizontal
     188        shader_blur_h = Shader::Create(lolfx_blurh);
     189        shader_blur_h_texture = shader_blur_h->GetUniformLocation("texture");
     190        shader_blur_h_screen_size = shader_blur_h->GetUniformLocation("screen_size");
     191        shader_blur_h_time = shader_blur_h->GetUniformLocation("time");
     192        shader_blur_h_value = shader_blur_h->GetUniformLocation("value");
     193        // shader blur vertical
     194        shader_blur_v = Shader::Create(lolfx_blurv);
     195        shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
     196        shader_blur_v_screen_size = shader_blur_v->GetUniformLocation("screen_size");
     197        shader_blur_v_time = shader_blur_v->GetUniformLocation("time");
     198        shader_blur_v_value = shader_blur_v->GetUniformLocation("value");
     199        // shader glow
     200        shader_glow = Shader::Create(lolfx_glow);
     201        shader_glow_texture = shader_glow->GetUniformLocation("texture");
     202        shader_glow_texture_prv = shader_glow->GetUniformLocation("texture_prv");
     203        shader_glow_screen_size = shader_glow->GetUniformLocation("screen_size");
     204        shader_glow_time = shader_glow->GetUniformLocation("time");
     205        shader_glow_step = shader_glow->GetUniformLocation("step");
     206        shader_glow_value1 = shader_glow->GetUniformLocation("value1");
     207        shader_glow_value2 = shader_glow->GetUniformLocation("value2");
     208        // shader radial
     209        shader_radial = Shader::Create(lolfx_radial);
     210        shader_radial_texture = shader_radial->GetUniformLocation("texture");
     211        shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
     212        shader_radial_time = shader_radial->GetUniformLocation("time");
     213        shader_radial_value1 = shader_radial->GetUniformLocation("value1");
     214        shader_radial_value2 = shader_radial->GetUniformLocation("value2");
     215        shader_radial_color = shader_radial->GetUniformLocation("color");
     216        // shader postfx
     217        shader_postfx = Shader::Create(lolfx_postfx);
     218        shader_postfx_texture = shader_postfx->GetUniformLocation("texture");
     219        shader_postfx_texture_2d = shader_postfx->GetUniformLocation("texture_2d");
     220        shader_postfx_screen_size = shader_postfx->GetUniformLocation("screen_size");
     221        shader_postfx_time = shader_postfx->GetUniformLocation("time");
     222        shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
     223        shader_postfx_value = shader_postfx->GetUniformLocation("value");
     224        shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
     225        shader_postfx_scanline = shader_postfx->GetUniformLocation("scanline");
     226        shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
     227    }
    227228
    228229    return true;
    229230}
    230231
    231 int Render::CreateGLWindow(caca_canvas_t *caca)
     232int Render::CreateGLWindow()
    232233{
    233234    screen_size = Video::GetSize();
    234 
    235235    border = 12 * ratio_2d;
    236     window_vtx[0] = font_size.x * ratio_2d.x / 2.0f;
    237     window_vtx[1] = font_size.y * ratio_2d.y / 2.0f;
    238     window_vtx[2] = font_size.x * ratio_2d.x / 2.0f;
    239     window_vtx[3] = -font_size.y * ratio_2d.y / 2.0f;
    240     window_vtx[4] = -font_size.x * ratio_2d.x / 2.0f;
    241     window_vtx[5] = -font_size.y * ratio_2d.y / 2.0f;
    242     window_vtx[6] = -font_size.x * ratio_2d.x / 2.0f;
    243     window_vtx[7] = font_size.y * ratio_2d.y / 2.0f;
    244 
    245     ivec2 current_size = (screen_size - border * 2);
    246     text_size = current_size / (font_size * ratio_2d);
    247 
    248     //border
    249 
    250     blit_top = border;
    251     blit_bottom = screen_size - border * 2;
    252 
    253     caca_set_canvas_size(caca,text_size.x,text_size.y);
     236    canvas_char = (screen_size - border * 2) / (font_size * ratio_2d);
     237    canvas_size = canvas_char * font_size * ratio_2d;
     238
     239    border = (screen_size - canvas_size) / 2;
     240
     241    caca_set_canvas_size(m_caca, canvas_char.x, canvas_char.y);
    254242
    255243    InitDraw();
     
    287275        Ticker::Shutdown();
    288276    //if (Input::GetButtonState(282/*SDLK_F1*/))
    289     //    Pause();
     277    //    LEAULE();
    290278    if (Input::GetButtonState(283/*SDLK_F2*/))
    291279        {
     
    308296    if (!m_ready)
    309297    {
    310         CreateGLWindow(m_caca);
     298        CreateGLWindow();
    311299        text_render->Init();
    312300        m_ready = true;
     
    378366    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    379367
    380     text_render->Blit(blit_top, blit_bottom);
     368    text_render->Blit(border, canvas_size);
    381369
    382370    //if(m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
     
    389377    glLoadMatrixf(&m[0][0]);
    390378    glMatrixMode(GL_MODELVIEW);
    391     // draw window
     379    // draw border
    392380    glDisable(GL_TEXTURE_2D);
    393381    glDisable(GL_BLEND);
    394382    glColor3f(1.0f,1.0f,1.0f);
    395     rectangle(border.x+ratio_2d.x,border.y,screen_size.x-2*ratio_2d.x-border.x*2,ratio_2d.y);//(font_size.y+2)*ratio_2d.y);
    396     rectangle(border.x,border.y+ratio_2d.y,ratio_2d.x,screen_size.y-ratio_2d.y*2-border.y*2);
    397     rectangle(screen_size.x-ratio_2d.x-border.x,border.y+ratio_2d.y,ratio_2d.x,screen_size.y-2*ratio_2d.y-border.y*2);
    398     rectangle(border.x+ratio_2d.x,screen_size.y-ratio_2d.y-border.y,screen_size.x-2*ratio_2d.x-border.x*2,ratio_2d.y);
     383    rectangle(border.x - ratio_2d.x, border.y - ratio_2d.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
     384    rectangle(border.x - ratio_2d.x, border.y, ratio_2d.x, canvas_size.y);
     385    rectangle(border.x + canvas_size.x, border.y, ratio_2d.x, canvas_size.y);
     386    rectangle(border.x - ratio_2d.x, border.y + canvas_size.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
    399387    glEnable(GL_BLEND);
    400388}
  • trunk/tools/neercs/video/render.h

    r1623 r1625  
    2121
    2222private:
    23     int CreateGLWindow(caca_canvas_t *m_caca);
     23    int CreateGLWindow();
    2424    int InitDraw();
    2525    void Pause();
Note: See TracChangeset for help on using the changeset viewer.