Changeset 1588


Ignore:
Timestamp:
Jul 6, 2012, 4:24:38 PM (7 years ago)
Author:
rez
Message:

debug shortcuts added

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

Legend:

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

    r1585 r1588  
    4848
    4949int active = true;         // window active flag
    50 bool fullscreen = DEBUG?false:true; // fullscreen flag
    51 bool m_paused = false;       // pause flag
    5250float nearplane = 0.1f;    // nearplane
    5351float farplane = 1000.0f;  // farplane
    54 bool polygon = true;       // polygon mode
    5552int polygon_fillmode = GL_FILL; // fill mode
     53bool key_state = 0;      // key state
    5654/* window variable */
    5755ivec2 screen_size;         // screen size
    58 int window_color = 32;     // color depth
    5956vec3 screen_color = CR * vec3(48, 56, 64); // screen color
    6057/* object variable */
     
    6259float part_angle = 0.0f;   // part angle
    6360float fx_angle;            // current angle
    64 /* text variable */
    65 char const *name = "cacaShell";
    6661/* fs_quad variable */
    6762float fs_quad_vtx[] = {-1.0f, 1.0f, 0, 1.0f, -1.0f, -1.0f, 0, 1.0f, 1.0f, -1.0f, 0, 1.0f, 1.0f, 1.0f, 0, 1.0f};
     
    8883float beat_speed = 2.0f;   // speed
    8984/* corner variable */
    90 const int corner_n = 10;   // polygon number
     85const int corner_n = 10;   // m_polygon number
    9186int corner_w = 24;         // radius
    9287int corner_vtx[corner_n*6];// vertex array
    93 /* dos variable */
    94 bool dos_flag = true;      // flag
    95 int dos_m;                 // margin
    96 vec3 dos_color = CR * vec3(48, 56, 64); // color value
    97 int dos_vtx[8];            // vertex array
     88/* window variable */
     89int window_m;              // margin
     90int window_vtx[8];         // vertex array
    9891ivec2 ratio_2d(2,4);       // 2d ratio
    9992ivec2 map_size(256,256);   // texture map size
     
    10295int shell_vtx[8];          // vertex array
    10396float shell_tex[] = {1.0f, 0.96875f, 1.0f, 1.0f, 0.78125f, 1.0f, 0.78125f, 0.96875f};
    104 /* keyboard variable */
    105 int key_code = 0;          // keyboard code
    10697/* common variable */
    10798float value, angle, radius, scale, speed;
    10899/* shader variable */
    109 bool m_shader = true;      /* TO DELETE */
    110 bool shader_blur_flag = true;
    111 bool shader_glow_flag = true;
    112 bool shader_effect_flag = true;
    113 bool shader_postfx_flag = true;
    114 
    115100int glow_fbo_size = 2;        // glow fbo size
    116101float glow_smoothstep = 0.0f; // glow smoothstep value (try 0.025f)
    117102float glow_mix_ratio1 = 0.5f; // glow mixing ratio
    118103float glow_mix_ratio2 = 0.5f; // source mixing ratio
    119 
    120104float radial_value1 = 2.0f;
    121105float radial_value2 = 0.8f;
    122106float radial_color = 0;       // color
    123 
    124107bool postfx_scanline = true;
    125108float postfx_deform = 0.5f;   // deformation ratio
     
    215198}
    216199
    217 int InitGL(void)
     200int Render::InitDraw(void)
    218201{
    219202    glDepthMask(GL_TRUE);     // do not write z-buffer
     
    278261}
    279262
    280 int CreateGLWindow()
     263int Render::CreateGLWindow()
    281264{
    282265    screen_size = Video::GetSize();
    283266    corner_w = 16*ratio_2d.x;
    284267    corner();
    285     dos_m=12*ratio_2d.x;
    286     dos_vtx[0]=font_size.x*ratio_2d.x/2.0f;
    287     dos_vtx[1]=font_size.y*ratio_2d.y/2.0f;
    288     dos_vtx[2]=font_size.x*ratio_2d.x/2.0f;
    289     dos_vtx[3]=-font_size.y*ratio_2d.y/2.0f;
    290     dos_vtx[4]=-font_size.x*ratio_2d.x/2.0f;
    291     dos_vtx[5]=-font_size.y*ratio_2d.y/2.0f;
    292     dos_vtx[6]=-font_size.x*ratio_2d.x/2.0f;
    293     dos_vtx[7]=font_size.y*ratio_2d.y/2.0f;
    294     shell_vtx[0]=dos_m+58*ratio_2d.x;
    295     shell_vtx[1]=dos_m+(font_size.y+1)*ratio_2d.y;
    296     shell_vtx[2]=dos_m+58*ratio_2d.x;
    297     shell_vtx[3]=dos_m+ratio_2d.y;
    298     shell_vtx[4]=dos_m+2*ratio_2d.x;
    299     shell_vtx[5]=dos_m+ratio_2d.y;
    300     shell_vtx[6]=dos_m+2*ratio_2d.x;
    301     shell_vtx[7]=dos_m+(font_size.y+1)*ratio_2d.y;
    302     InitGL();
     268    window_m=12*ratio_2d.x;
     269    window_vtx[0]=font_size.x*ratio_2d.x/2.0f;
     270    window_vtx[1]=font_size.y*ratio_2d.y/2.0f;
     271    window_vtx[2]=font_size.x*ratio_2d.x/2.0f;
     272    window_vtx[3]=-font_size.y*ratio_2d.y/2.0f;
     273    window_vtx[4]=-font_size.x*ratio_2d.x/2.0f;
     274    window_vtx[5]=-font_size.y*ratio_2d.y/2.0f;
     275    window_vtx[6]=-font_size.x*ratio_2d.x/2.0f;
     276    window_vtx[7]=font_size.y*ratio_2d.y/2.0f;
     277    shell_vtx[0]=window_m+58*ratio_2d.x;
     278    shell_vtx[1]=window_m+(font_size.y+1)*ratio_2d.y;
     279    shell_vtx[2]=window_m+58*ratio_2d.x;
     280    shell_vtx[3]=window_m+ratio_2d.y;
     281    shell_vtx[4]=window_m+2*ratio_2d.x;
     282    shell_vtx[5]=window_m+ratio_2d.y;
     283    shell_vtx[6]=window_m+2*ratio_2d.x;
     284    shell_vtx[7]=window_m+(font_size.y+1)*ratio_2d.y;
     285    InitDraw();
    303286    return true;
    304287}
     
    307290  : m_caca(caca),
    308291    m_ready(false),
    309     m_shader(true)
     292    m_pause(false),
     293    m_polygon(true),
     294    m_shader(true),
     295    m_shader_blur(true),
     296    m_shader_glow(true),
     297    m_shader_fx(true),
     298    m_shader_postfx(true)
    310299{
    311300    text_render = new TextRender(m_caca, font_size);
     
    315304{
    316305    Entity::TickGame(seconds);
     306}
     307
     308void Render::Pause()
     309{
     310    m_pause=!m_pause;
    317311}
    318312
     
    322316    if (Input::GetButtonState(27/*SDLK_ESCAPE*/))
    323317        Ticker::Shutdown();
    324     if (Input::GetButtonState(8 /*SDLK_BACKSPACE*/))
    325         m_paused=!m_paused;
    326     if (Input::GetButtonState(112 /*SDLK_F1*/))
     318    //if (Input::GetButtonState(282/*SDLK_F1*/))
     319    //    Pause();
     320    if (Input::GetButtonState(283/*SDLK_F2*/))
     321        {
     322        m_polygon=!m_polygon;
     323        polygon_fillmode=(m_polygon)?GL_FILL:GL_LINE;
     324        glPolygonMode(GL_FRONT,polygon_fillmode);
     325        }
     326    if (Input::GetButtonState(284/*SDLK_F3*/)&&key_state!=284)
     327        {
    327328        m_shader=!m_shader;
     329        key_state=284;
     330        }
     331    if (Input::GetButtonState(285/*SDLK_F4*/))
     332        m_shader_postfx=!m_shader_postfx;
     333    if (Input::GetButtonState(286/*SDLK_F5*/))
     334        Pause();
    328335
    329336    Entity::TickDraw(seconds);
     
    333340        CreateGLWindow();
    334341        text_render->Init();
    335 
    336342        m_ready = true;
    337343    }
    338344
    339345    // timer
    340     if(!m_paused)
     346    if(!m_pause)
    341347        main_angle += seconds * 100.0f * PID;
    342348    if(sync_flag)
     
    398404    glEnable(GL_BLEND);
    399405    glBlendFunc(GL_SRC_COLOR,GL_DST_ALPHA);
    400     glClearColor(screen_color.r, screen_color.g, screen_color.b, 0.5f);
     406    glClearColor(screen_color.r, screen_color.g, screen_color.b, 1.0f);
    401407    glClearDepth(1.0f); // set depth buffer
    402408    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    403409
    404     ivec2 border_top = ivec2(dos_m, dos_m + font_size.y * ratio_2d.y)
     410    ivec2 border_top = ivec2(window_m, window_m + font_size.y * ratio_2d.y)
    405411                     + ratio_2d * 2;
    406     ivec2 border_bottom = ivec2(dos_m * 2, dos_m * 2 + font_size.y * ratio_2d.y)
     412    ivec2 border_bottom = ivec2(window_m * 2, window_m * 2 + font_size.y * ratio_2d.y)
    407413                        + ratio_2d * 2;
    408414    text_render->Blit(border_top, screen_size - border_bottom);
    409415
    410     //if(polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
    411     glLineWidth((polygon)?2.0f:1.0f);
     416    //if(m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
     417    glLineWidth((m_polygon)?2.0f:1.0f);
    412418    fx_angle=main_angle-part_angle;
    413     if(polygon) glEnable(GL_TEXTURE_2D);
     419    if(m_polygon) glEnable(GL_TEXTURE_2D);
    414420
    415421    glMatrixMode(GL_PROJECTION);
     
    417423    glLoadMatrixf(&m[0][0]);
    418424    glMatrixMode(GL_MODELVIEW);
    419     // draw dos
    420     if(dos_flag)
    421     {
    422         glDisable(GL_TEXTURE_2D);
    423         glDisable(GL_BLEND);
    424         glColor3f(1.0f,1.0f,1.0f);
    425         rectangle(dos_m,dos_m,screen_size.x-53*ratio_2d.x-dos_m*2,(font_size.y+2)*ratio_2d.y);
    426         rectangle(screen_size.x-51*ratio_2d.x-dos_m,dos_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
    427         rectangle(screen_size.x-27*ratio_2d.x-dos_m,dos_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
    428         rectangle(screen_size.x-3*ratio_2d.x-dos_m,dos_m,3*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
    429         rectangle(dos_m,dos_m+(font_size.y+2)*ratio_2d.y,2*ratio_2d.x,screen_size.y-(font_size.y+2)*ratio_2d.y-dos_m*2);
    430         rectangle(screen_size.x-2*ratio_2d.x-dos_m,dos_m+(font_size.y+2)*ratio_2d.y,2*ratio_2d.x,screen_size.y-(font_size.y+2)*ratio_2d.y-dos_m*2);
    431         rectangle(dos_m+2*ratio_2d.x,screen_size.y-ratio_2d.y-dos_m,screen_size.x-4*ratio_2d.x-dos_m*2,ratio_2d.y);
    432         glColor3f(dos_color.x,dos_color.y,dos_color.z);
    433         rectangle(dos_m+2*ratio_2d.x,dos_m+ratio_2d.y,56*ratio_2d.x,font_size.y*ratio_2d.y);
    434         rectangle(dos_m+60*ratio_2d.x,dos_m+2*ratio_2d.y,screen_size.x-115*ratio_2d.x-dos_m*2,2*ratio_2d.y);
    435         rectangle(dos_m+60*ratio_2d.x,dos_m+6*ratio_2d.y,screen_size.x-115*ratio_2d.x-dos_m*2,2*ratio_2d.y);
    436         rectangle(screen_size.x-49*ratio_2d.x-dos_m,dos_m+ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
    437         glColor3f(1.0f,1.0f,1.0f);
    438         rectangle(screen_size.x-47*ratio_2d.x-dos_m,dos_m+2*ratio_2d.y,10*ratio_2d.x,4*ratio_2d.y);
    439         glColor3f(0,0,0);
    440         rectangle(screen_size.x-45*ratio_2d.x-dos_m,dos_m+3*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
    441         rectangle(screen_size.x-25*ratio_2d.x-dos_m,dos_m+1*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
    442         glColor3f(dos_color.x,dos_color.y,dos_color.z);
    443         rectangle(screen_size.x-21*ratio_2d.x-dos_m,dos_m+2*ratio_2d.y,14*ratio_2d.x,7*ratio_2d.y);
    444         glColor3f(1.0f,1.0f,1.0f);
    445         rectangle(screen_size.x-19*ratio_2d.x-dos_m,dos_m+3*ratio_2d.y,10*ratio_2d.x,5*ratio_2d.y);
    446         rectangle(screen_size.x-16*ratio_2d.x-dos_m,screen_size.y-9*ratio_2d.y-dos_m,14*ratio_2d.x,8*ratio_2d.y);
    447         glColor3f(dos_color.x,dos_color.y,dos_color.z);
    448         rectangle(screen_size.x-14*ratio_2d.x-dos_m,screen_size.y-8*ratio_2d.y-dos_m,12*ratio_2d.x,7*ratio_2d.y);
    449         glColor3f(1.0f,1.0f,1.0f);
    450         rectangle(screen_size.x-8*ratio_2d.x-dos_m,screen_size.y-8*ratio_2d.y-dos_m,8*ratio_2d.x,2*ratio_2d.y);
    451         rectangle(screen_size.x-14*ratio_2d.x-dos_m,screen_size.y-5*ratio_2d.y-dos_m,4*ratio_2d.x,5*ratio_2d.y);
    452         rectangle(screen_size.x-12*ratio_2d.x-dos_m,screen_size.y-7*ratio_2d.y-dos_m,2*ratio_2d.x,1*ratio_2d.y);
    453         rectangle(screen_size.x-8*ratio_2d.x-dos_m,screen_size.y-5*ratio_2d.y-dos_m,4*ratio_2d.x,3*ratio_2d.y);
    454         glEnable(GL_BLEND);
    455         if(polygon) glEnable(GL_TEXTURE_2D);
    456         glBlendFunc(GL_ONE, GL_ONE);
    457         glVertexPointer(2, GL_INT, 0, shell_vtx);
    458         glTexCoordPointer(2, GL_FLOAT, 0, shell_tex);
    459         glDrawArrays(GL_QUADS, 0, 4);
    460     }
     425    // draw window
     426    glDisable(GL_TEXTURE_2D);
     427    glDisable(GL_BLEND);
     428    glColor3f(1.0f,1.0f,1.0f);
     429    rectangle(window_m,window_m,screen_size.x-53*ratio_2d.x-window_m*2,(font_size.y+2)*ratio_2d.y);
     430    rectangle(screen_size.x-51*ratio_2d.x-window_m,window_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
     431    rectangle(screen_size.x-27*ratio_2d.x-window_m,window_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
     432    rectangle(screen_size.x-3*ratio_2d.x-window_m,window_m,3*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
     433    rectangle(window_m,window_m+(font_size.y+2)*ratio_2d.y,2*ratio_2d.x,screen_size.y-(font_size.y+2)*ratio_2d.y-window_m*2);
     434    rectangle(screen_size.x-2*ratio_2d.x-window_m,window_m+(font_size.y+2)*ratio_2d.y,2*ratio_2d.x,screen_size.y-(font_size.y+2)*ratio_2d.y-window_m*2);
     435    rectangle(window_m+2*ratio_2d.x,screen_size.y-ratio_2d.y-window_m,screen_size.x-4*ratio_2d.x-window_m*2,ratio_2d.y);
     436    glColor3f(screen_color.x,screen_color.y,screen_color.z);
     437    rectangle(window_m+2*ratio_2d.x,window_m+ratio_2d.y,56*ratio_2d.x,font_size.y*ratio_2d.y);
     438    rectangle(window_m+60*ratio_2d.x,window_m+2*ratio_2d.y,screen_size.x-115*ratio_2d.x-window_m*2,2*ratio_2d.y);
     439    rectangle(window_m+60*ratio_2d.x,window_m+6*ratio_2d.y,screen_size.x-115*ratio_2d.x-window_m*2,2*ratio_2d.y);
     440    rectangle(screen_size.x-49*ratio_2d.x-window_m,window_m+ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
     441    glColor3f(1.0f,1.0f,1.0f);
     442    rectangle(screen_size.x-47*ratio_2d.x-window_m,window_m+2*ratio_2d.y,10*ratio_2d.x,4*ratio_2d.y);
     443    glColor3f(0,0,0);
     444    rectangle(screen_size.x-45*ratio_2d.x-window_m,window_m+3*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
     445    rectangle(screen_size.x-25*ratio_2d.x-window_m,window_m+1*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
     446    glColor3f(screen_color.x,screen_color.y,screen_color.z);
     447    rectangle(screen_size.x-21*ratio_2d.x-window_m,window_m+2*ratio_2d.y,14*ratio_2d.x,7*ratio_2d.y);
     448    glColor3f(1.0f,1.0f,1.0f);
     449    rectangle(screen_size.x-19*ratio_2d.x-window_m,window_m+3*ratio_2d.y,10*ratio_2d.x,5*ratio_2d.y);
     450    rectangle(screen_size.x-16*ratio_2d.x-window_m,screen_size.y-9*ratio_2d.y-window_m,14*ratio_2d.x,8*ratio_2d.y);
     451    glColor3f(screen_color.x,screen_color.y,screen_color.z);
     452    rectangle(screen_size.x-14*ratio_2d.x-window_m,screen_size.y-8*ratio_2d.y-window_m,12*ratio_2d.x,7*ratio_2d.y);
     453    glColor3f(1.0f,1.0f,1.0f);
     454    rectangle(screen_size.x-8*ratio_2d.x-window_m,screen_size.y-8*ratio_2d.y-window_m,8*ratio_2d.x,2*ratio_2d.y);
     455    rectangle(screen_size.x-14*ratio_2d.x-window_m,screen_size.y-5*ratio_2d.y-window_m,4*ratio_2d.x,5*ratio_2d.y);
     456    rectangle(screen_size.x-12*ratio_2d.x-window_m,screen_size.y-7*ratio_2d.y-window_m,2*ratio_2d.x,1*ratio_2d.y);
     457    rectangle(screen_size.x-8*ratio_2d.x-window_m,screen_size.y-5*ratio_2d.y-window_m,4*ratio_2d.x,3*ratio_2d.y);
     458    glEnable(GL_BLEND);
     459    if(m_polygon) glEnable(GL_TEXTURE_2D);
     460    glBlendFunc(GL_ONE, GL_ONE);
     461    glVertexPointer(2, GL_INT, 0, shell_vtx);
     462    glTexCoordPointer(2, GL_FLOAT, 0, shell_tex);
     463    glDrawArrays(GL_QUADS, 0, 4);
    461464    // draw corner
    462465    glDisable(GL_TEXTURE_2D);
    463466    glDisable(GL_BLEND);
    464     glColor3f(0, 1.0f, 0);
    465467    glVertexPointer(2, GL_INT, 0, corner_vtx);
    466468    glLoadIdentity();
    467     glColor3f(0, 0, 0);
     469    glColor3f(1.0f, 1.0f, 1.0f);
    468470    glDrawArrays(GL_TRIANGLES, 0, corner_n*3);
    469471    glTranslated(screen_size.x, 0, 0);
     
    494496
    495497    fbo_back->Unbind();
    496     if (shader_effect_flag && shader_blur_flag)
     498    if (m_shader_fx && m_shader_blur)
    497499    {
    498500        // shader blur horizontal
     
    524526    fbo_front->Unbind();
    525527    // shader glow
    526     if(shader_effect_flag && shader_glow_flag)
     528    if(m_shader_fx && m_shader_glow)
    527529    {
    528530        // shader blur horizontal
     
    579581        shader_glow->Unbind();
    580582    }
    581     if(!shader_effect_flag)
     583    if(!m_shader_fx)
    582584    {
    583585        // shader simple
     
    586588    }
    587589    fbo_pong->Unbind();
    588     if(shader_postfx_flag)
     590    if(m_shader_postfx)
    589591    {
    590592        // shader postfx
     
    614616{
    615617}
    616 
  • trunk/tools/neercs/video/render.h

    r1585 r1588  
    2121
    2222private:
     23    int CreateGLWindow();
     24    int InitDraw();
     25    void Pause();
     26    void Shader();
     27
    2328    caca_canvas_t *m_caca;
    2429    bool m_ready;
     30    bool m_pause;
     31    bool m_polygon;
    2532    bool m_shader;
     33    bool m_shader_blur;
     34    bool m_shader_glow;
     35    bool m_shader_fx;
     36    bool m_shader_postfx;
    2637};
    2738
  • trunk/tools/neercs/video/text.lolfx

    r1585 r1588  
    3030    pass_Background = vec4(B, C, D, 1.0 - A);
    3131    pass_Foreground = vec4(F, G, H, 1.0 - E);
     32    if (B + C + D < 0.01) A = 1.0;
     33    if (F + G + H < 0.01) E = 1.0;
    3234
    3335    // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
Note: See TracChangeset for help on using the changeset viewer.