Changeset 1497


Ignore:
Timestamp:
Jun 18, 2012, 9:29:57 PM (8 years ago)
Author:
sam
Message:

neercs: get rid of useless stuff.

File:
1 edited

Legend:

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

    r1493 r1497  
    4040
    4141#define DEBUG 1            // debug flag //#if defined(_DEBUG)
    42 #define SHADER 1           // shader flag
    4342#define PID M_PI/180.0f    // pi ratio
    4443#define CR 1.0f/256.0f     // color ratio
     
    6160ivec2 screen_size;         // screen size
    6261int window_color = 32;     // color depth
    63 vec3 screen_color;        // screen color
     62vec3 screen_color = CR * vec3(48, 56, 64); // screen color
    6463/* object variable */
    65 float main_angle;          // main angle
    66 float part_angle;          // part angle
     64float main_angle = 0.0f;   // main angle
     65float part_angle = 0.0f;   // part angle
    6766float fx_angle;            // current angle
    6867/* text variable */
     
    7574float flash_angle = 0;     // angle
    7675float flash_value = 0;     // value
    77 float flash_speed;         // speed
     76float flash_speed = 1.5f;  // speed
    7877/* fade variable */
    7978bool fade_flag = false;    // flag
    8079float fade_angle = 0;      // angle
    8180float fade_value = 0;      // value
    82 float fade_speed;          // speed
     81float fade_speed = 0.2f;   // speed
    8382/* sync variable */
    8483bool sync_flag = false;    // flag
    8584float sync_angle = 0;      // angle
    86 float sync_value = 0;      // value
    87 float sync_speed;          // speed
     85float sync_value = 1.0f;   // value
     86float sync_speed = 1.0f;   // speed
    8887/* beat variable */
    8988bool beat_flag = false;    // flag
    9089float beat_angle = 0;      // angle
    9190float beat_value = 0;      // value
    92 float beat_speed;          // speed
     91float beat_speed = 2.0f;   // speed
    9392/* corner variable */
    9493const int corner_n = 10;   // polygon number
     
    9695int corner_vtx[corner_n*6];// vertex array
    9796/* dos variable */
    98 bool dos_flag = false;     // flag
     97bool dos_flag = true;      // flag
    9998int dos_m;                 // margin
    100 vec3 dos_color;            // color value
     99vec3 dos_color = CR * vec3(48, 56, 64); // color value
    101100int dos_vtx[8];            // vertex array
    102101ivec2 ratio_2d(2,4);       // 2d ratio
     
    112111TileSet *tex_map;
    113112/* shader variable */
    114 bool shader_flag = SHADER?true:false;
    115 bool shader_blur_flag = SHADER?true:false;
    116 bool shader_effect_flag = SHADER?true:false;
     113bool shader_flag = true;
     114bool shader_blur_flag = true;
     115bool shader_effect_flag = true;
    117116bool shader_glow_flag = true;
    118 int glow_fbo_size = 2;     // glow fbo size
    119 int glow_color;            // 0 = color / 1 = alpha
    120 float glow_smoothstep;     // glow smoothstep value
    121 float glow_mix_ratio1;     // glow mixing ratio
    122 float glow_mix_ratio2;     // source mixing ratio
     117bool shader_postfx_flag = true;
    123118bool shader_radial_flag = false;
    124 float radial_value1;
    125 float radial_value2;
    126 float radial_color;        // color
    127 bool shader_postfx_flag = SHADER?true:false;
     119
     120int glow_fbo_size = 2;        // glow fbo size
     121float glow_smoothstep = 0.0f; // glow smoothstep value (try 0.025f)
     122float glow_mix_ratio1 = 0.5f; // glow mixing ratio
     123float glow_mix_ratio2 = 0.5f; // source mixing ratio
     124
     125float radial_value1 = 2.0f;
     126float radial_value2 = 0.8f;
     127float radial_color = 0;       // color
     128
    128129bool postfx_scanline = true;
    129 float postfx_deform;       // deformation ratio
    130 #if SHADER
     130float postfx_deform = 0.5f;   // deformation ratio
     131
    131132Shader *shader_simple, *shader_blur_h, *shader_blur_v;
    132133Shader *shader_glow, *shader_radial, *shader_postfx;
     
    166167FrameBuffer *fbo_back, *fbo_front;
    167168FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_ping, *fbo_pong;
    168 #endif
    169169
    170170/*
     
    305305TextRender *text_render;
    306306
    307 void init_viewport(int type)
    308 {
    309     glViewport(0, 0, screen_size.x, screen_size.y);
    310     glMatrixMode(GL_PROJECTION);
    311     glLoadIdentity();
    312     mat4 m;
    313     if (type == 0)
    314         m = mat4::perspective(70, (float)screen_size.x, (float)screen_size.y,
    315                               nearplane, farplane);
    316     else
    317         m = mat4::ortho(0, screen_size.x, screen_size.y, 0, -1.f, 1.f);
    318     glLoadMatrixf(&m[0][0]);
    319     glMatrixMode(GL_MODELVIEW);
    320 }
    321 
    322 #if SHADER
    323 void init_shader()
    324 {
    325     glDisable(GL_BLEND);
    326     glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx);
    327     glTexCoordPointer(2, GL_FLOAT, 0, fs_quad_tex);
    328 }
    329 
    330307void fs_quad()
    331308{
     
    341318    shader_simple->Unbind();
    342319}
    343 #endif
    344320
    345321void rectangle(int x, int y, int w, int h)
     
    379355}
    380356
    381 void screen()
    382 {
    383     part_angle = main_angle;
    384     dos_flag = true;
    385     dos_color = CR * vec3(48, 56, 64);
    386     screen_color = dos_color;
    387     /*-------------------------*/
    388     shader_effect_flag = true;
    389     shader_glow_flag = true;
    390     glow_color = 1;
    391     glow_smoothstep = 0;//.025f;
    392     glow_mix_ratio1 = 0.5f;
    393     glow_mix_ratio2 = 0.5f;
    394     shader_radial_flag = false;
    395     radial_value1 = 2.0f;
    396     radial_value2 = 0.8f;
    397     radial_color = 0;
    398     postfx_deform = 0.5f;
    399     /*-------------------------*/
    400     flash_speed = 1.5f;
    401     fade_speed = 0.2f;
    402     sync_flag = false;
    403     sync_value = 1.0f;
    404     sync_speed = 1.0f;
    405     beat_speed = 2.0f;
    406     /*-------------------------*/
    407 }
    408 
    409357int InitGL(void)
    410358{
    411     glDepthMask(GL_TRUE);                            // do not write z-buffer
    412     glEnable(GL_CULL_FACE);                        // disable cull face
    413     glCullFace(GL_BACK);                            // don't draw front face
     359    glDepthMask(GL_TRUE);     // do not write z-buffer
     360    glEnable(GL_CULL_FACE);   // disable cull face
     361    glCullFace(GL_BACK);      // don't draw front face
     362
    414363    // load texture
    415     tex_map = new TileSet("neercs/video/resource/map.png", ivec2(256, 256), ivec2(1));
    416     // initialize some variable
    417     screen();
    418 
    419 #if SHADER
     364    tex_map = new TileSet("neercs/video/resource/map.png",
     365                          ivec2(256, 256), ivec2(1));
     366
    420367    if (shader_flag)
    421368    {
     
    471418        shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
    472419    }
    473 #endif
     420
    474421    return true;
    475422}
     
    578525    text_render->Render(screen_size);
    579526
    580 #if SHADER
    581527    if(shader_flag)
    582528        fbo_back->Bind();
    583 #endif
    584529
    585530    /* Clear the back buffer */
     
    594539    text_render->Blit(screen_size, border_top, screen_size - border_bottom);
    595540
    596     glEnableClientState(GL_VERTEX_ARRAY);
    597     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    598 
    599541    glEnable(GL_BLEND);
    600542    //if(polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
     
    603545    if(polygon) glEnable(GL_TEXTURE_2D);
    604546
    605     init_viewport(1);
     547    glViewport(0, 0, screen_size.x, screen_size.y);
     548    glMatrixMode(GL_PROJECTION);
     549    mat4 m = mat4::ortho(0, screen_size.x, screen_size.y, 0, -1.f, 1.f);
     550    glLoadMatrixf(&m[0][0]);
     551    glMatrixMode(GL_MODELVIEW);
    606552
    607553    tex_map->Bind();
     
    667613    glEnable(GL_BLEND);
    668614    tex_map->Unbind();
    669 
    670     glDisableClientState(GL_VERTEX_ARRAY);
    671     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    672615}
    673616
    674617void Render::Draw3D()
    675618{
    676     //init_viewport(0);
    677     glDisable(GL_DEPTH_TEST);
    678 
    679 #if SHADER
    680619    if (!shader_flag)
    681620        return;
    682621
     622    glDisable(GL_DEPTH_TEST);
     623    glDisable(GL_BLEND);
     624
    683625    glEnableClientState(GL_VERTEX_ARRAY);
     626    glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx);
     627
    684628    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    685 
    686     init_shader();
     629    glTexCoordPointer(2, GL_FLOAT, 0, fs_quad_tex);
     630
    687631    fbo_back->Unbind();
    688632    if (shader_effect_flag && shader_blur_flag)
     
    716660    fbo_front->Unbind();
    717661    // shader glow
    718     if(shader_effect_flag&&shader_glow_flag)
     662    if(shader_effect_flag && shader_glow_flag)
    719663    {
    720664        // shader blur horizontal
     
    801745    glDisableClientState(GL_VERTEX_ARRAY);
    802746    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    803 #endif
    804747}
    805748
Note: See TracChangeset for help on using the changeset viewer.