Changeset 1703


Ignore:
Timestamp:
Aug 7, 2012, 7:11:21 PM (8 years ago)
Author:
rez
Message:

setup menu improved, now you can change (some) variable

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

Legend:

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

    r1701 r1703  
    9494ivec2 canvas_size(0,0);    // caca size
    9595/* setup variable */
     96bool setup_switch=false;        // switch [option/item]
    9697int setup_option=0;             // selected option
    9798int setup_option_n=6;           // option number
    98 int setup_item=-1;              // selected item
     99int setup_item=0;               // selected item
    99100int setup_item_n=8;             // item number
    100101ivec2 setup_p(1,1);             // position [x,y]
     
    103104char const *setup_text[] = {
    104105    "remanency",
     106        "enable",
    105107        "buffer new frame",
    106108        "buffer old frame",
     
    110112        "",
    111113        "",
    112         "",
    113     "blur/glow",
    114         "blur center",
    115         "blur corner",
     114    "glow/blur",
     115        "glow enable",
    116116        "glow large center",
    117117        "glow large corner",
    118118        "glow small center",
    119119        "glow small corner",
    120         "",
    121         "",
     120        "blur enable",
     121        "blur center",
     122        "blur corner",
    122123    "color",
    123124        "filter red",
     
    162163vec2 buffer(0.75f,0.25f);       // [new frame mix,old frame mix]
    163164vec2 remanency(0.25f,0.75f);    // remanency [source mix,buffer mix]
    164 vec2 blur(0.25f,0.75f);         // glow radius [center,corner]
    165165vec2 glow_mix(0.5f,0.5f);       // glow mix [source mix,glow mix]
    166166vec2 glow_large(2.0f,2.0f);     // large glow radius [center,corner]
    167167vec2 glow_small(1.0f,1.0f);     // small glow radius [center,corner]
     168vec2 blur(0.25f,0.75f);         // glow radius [center,corner]
    168169//vec3 radial(2.0f,0.8f,0);     // radial [mix,strength,color mode]
    169170//------------------------------// [IDEAS] http://www.youtube.com/watch?v=d1qEP2vMe-I
     
    181182vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f);// vertical scanline [base,variable,repeat x,repeat y]
    182183vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f);// horizontal scanline [base,variable,repeat x,repeat y]
     184//------------------------------//
     185//00:29 <@sam> Array<vec4> toto;
     186//00:29 <@sam> toto << vec4(1.f, 2.f, 3.f, 4.f);
     187vec4 setup_var[]={
     188    vec4(0), /* remanency */
     189        vec4(0, 1, 1, 1),
     190        vec4(0.0f, 1.0f, 0.1f, buffer.x),
     191        vec4(0.0f, 1.0f, 0.1f, buffer.y),
     192        vec4(0.0f, 1.0f, 0.1f, remanency.x),
     193        vec4(0.0f, 1.0f, 0.1f, remanency.y),
     194        vec4(0),
     195        vec4(0),
     196        vec4(0),
     197    vec4(0), /* glow/blur */
     198        vec4(0, 1, 1, 0),
     199        vec4(0.0f, 8.0f, 0.1f, glow_large.x),
     200        vec4(0.0f, 8.0f, 0.1f, glow_large.y),
     201        vec4(0.0f, 4.0f, 0.1f, glow_small.x),
     202        vec4(0.0f, 4.0f, 0.1f, glow_small.y),
     203        vec4(0, 1, 1, 0),
     204        vec4(0.0f, 2.0f, 0.1f, blur.x),
     205        vec4(0.0f, 2.0f, 0.1f, blur.y),
     206    vec4(0) /* color */
     207    };
    183208
    184209Shader *shader_simple;
     
    187212// shader variables
    188213ShaderUniform shader_simple_texture;
    189 ShaderUniform shader_blur_h_texture,
    190               shader_blur_h_radius,
    191               shader_blur_v_texture,
    192               shader_blur_v_radius;
    193214ShaderUniform shader_remanency_source,
    194215              shader_remanency_buffer,
     
    197218              shader_glow_source,
    198219              shader_glow_mix;
     220ShaderUniform shader_blur_h_texture,
     221              shader_blur_h_radius,
     222              shader_blur_v_texture,
     223              shader_blur_v_radius;
    199224ShaderUniform shader_radial_texture,
    200225              shader_radial_screen_size,
     
    270295    shader_simple = Shader::Create(lolfx_simple);
    271296    shader_simple_texture = shader_simple->GetUniformLocation("texture");
    272     // shader blur horizontal
    273     shader_blur_h = Shader::Create(lolfx_blurh);
    274     shader_blur_h_texture = shader_blur_h->GetUniformLocation("texture");
    275     shader_blur_h_radius = shader_blur_h->GetUniformLocation("radius");
    276     // shader blur vertical
    277     shader_blur_v = Shader::Create(lolfx_blurv);
    278     shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
    279     shader_blur_v_radius = shader_blur_v->GetUniformLocation("radius");
    280297    // shader remanency
    281298    shader_remanency = Shader::Create(lolfx_remanency);
     
    288305    shader_glow_source = shader_glow->GetUniformLocation("source");
    289306    shader_glow_mix = shader_glow->GetUniformLocation("mix");
     307    // shader blur horizontal
     308    shader_blur_h = Shader::Create(lolfx_blurh);
     309    shader_blur_h_texture = shader_blur_h->GetUniformLocation("texture");
     310    shader_blur_h_radius = shader_blur_h->GetUniformLocation("radius");
     311    // shader blur vertical
     312    shader_blur_v = Shader::Create(lolfx_blurv);
     313    shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
     314    shader_blur_v_radius = shader_blur_v->GetUniformLocation("radius");
    290315    // shader radial
    291316    shader_radial = Shader::Create(lolfx_radial);
     
    348373    m_shader(true),
    349374    m_shader_remanency(true),
    350     m_shader_glow(true),
    351     m_shader_blur(true),
    352     m_shader_fx(true),
    353     m_shader_postfx(true),
     375    m_shader_glow(false),
     376    m_shader_blur(false),
     377    m_shader_postfx(false),
    354378    m_border(false)
    355379{
     
    388412    if (Input::GetButtonState(284/*SDLK_F3*/) && (timer - timer_key > timer_key_repeat))
    389413    {
     414        m_shader_glow = !m_shader_glow;
    390415        m_shader_blur = !m_shader_blur;
    391         m_shader_glow = !m_shader_glow;
    392416        timer_key = timer;
    393417    }
     
    403427    if (Input::GetButtonState(273/*SDLK_UP*/)&&(timer-timer_key>timer_key_repeat))
    404428    {
    405         if (setup_item == -1)
    406         {
    407             setup_option--;
    408             if (setup_option < 0) setup_option = setup_option_n - 1;
    409         }
    410         else
    411         {
    412             setup_item--;
    413             if (setup_item < 0) setup_item = setup_item_n - 1;
     429        if (m_setup)
     430        {
     431            if (!setup_switch)
     432            {
     433                setup_option--;
     434                if (setup_option < 0) setup_option = setup_option_n - 1;
     435                setup_item = 0;
     436            }
     437            else
     438            {
     439                setup_item--;
     440                if (setup_item < 0) setup_item = setup_item_n - 1;
     441            }
    414442        }
    415443        timer_key = timer;
     
    417445    if (Input::GetButtonState(274/*SDLK_DOWN*/)&&(timer-timer_key>timer_key_repeat))
    418446    {
    419         if (setup_item == -1)
    420         {
    421             setup_option++;
    422             if (setup_option > setup_option_n - 1) setup_option = 0;
    423         }
    424         else
    425         {
    426             setup_item++;
    427             if (setup_item > setup_item_n - 1) setup_item = 0;
     447        if (m_setup)
     448        {
     449            if (!setup_switch)
     450            {
     451                setup_option++;
     452                if (setup_option > setup_option_n - 1) setup_option = 0;
     453                setup_item = 0;
     454            }
     455            else
     456            {
     457                setup_item++;
     458                if (setup_item > setup_item_n - 1) setup_item = 0;
     459            }
    428460        }
    429461        timer_key = timer;
     
    431463    if (Input::GetButtonState(276/*SDLK_LEFT*/)&&(timer-timer_key>timer_key_repeat))
    432464    {
    433         setup_item = -1;
     465        if (m_setup && setup_switch)
     466        {
     467            int k = setup_option * (setup_item_n + 1) + 1 + setup_item;
     468            setup_var[k].w -= setup_var[k].z;
     469            if (setup_var[k].w < setup_var[k].x) setup_var[k].w = setup_var[k].x;
     470        }
    434471        timer_key = timer;
    435472    }
    436473    if (Input::GetButtonState(275/*SDLK_RIGHT*/)&&(timer-timer_key>timer_key_repeat))
    437474    {
    438         setup_item = 0;
     475        if (m_setup && setup_switch)
     476        {
     477            int k = setup_option * (setup_item_n + 1) + 1 + setup_item;
     478            setup_var[k].w += setup_var[k].z;
     479            if (setup_var[k].w > setup_var[k].y) setup_var[k].w = setup_var[k].y;
     480        }
     481        timer_key = timer;
     482    }
     483    if (Input::GetButtonState(13/*SDLK_RETURN*/)&&(timer-timer_key>timer_key_repeat))
     484    {
     485        if (m_setup)
     486        {
     487            setup_switch = !setup_switch;
     488        }
    439489        timer_key = timer;
    440490    }
     
    511561            int y = setup_p.y + 1 + i;
    512562            int k = i * (setup_item_n + 1);
    513             if (setup_option != i)
     563            if (setup_option != i || setup_switch)
    514564            {
    515565                caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
     
    528578            int y = setup_p.y + 1 + i;
    529579            int k = setup_option * (setup_item_n + 1) + 1;
    530             if (setup_option != i)
     580            if (setup_item != i || !setup_switch)
    531581            {
    532582                caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
     
    536586            {
    537587                caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
    538                 caca_draw_line(m_caca, setup_p.x + setup_size.z + 1, y, setup_p.x + setup_size.x, y,' ');
     588                caca_draw_line(m_caca, setup_p.x + setup_size.z, y, setup_p.x + setup_size.x, y,' ');
    539589                caca_put_str(m_caca, setup_p.x + setup_size.z + 1, y, setup_text[k + i]);
    540590            }
     591        }
     592        /* display variable */
     593        int y = setup_p.y + setup_size.y;
     594        caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
     595        caca_draw_line(m_caca, setup_p.x, y, setup_p.x + setup_size.x, y,' ');
     596        if (setup_switch)
     597        {
     598            int k = setup_option * (setup_item_n + 1) + 1 + setup_item;
     599            int w = setup_size.x - 3 - 4;
     600            caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[k].w);
     601            caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + w, y,'-');
     602            if(setup_var[k].w > setup_var[k].x) caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + int(w / (setup_var[k].y - setup_var[k].x) * setup_var[k].w), y,'X');
    541603        }
    542604    }
     
    637699
    638700    // shader glow
    639     if (m_shader_fx && m_shader_glow)
     701    if (m_shader_glow)
    640702    {
    641703        // shader blur horizontal
     
    689751    }
    690752
    691     if (m_shader_fx && m_shader_blur)
     753    if (m_shader_blur)
    692754    {
    693755        // shader blur horizontal
  • trunk/tools/neercs/video/render.h

    r1699 r1703  
    3333    bool m_setup;
    3434    bool m_shader;
     35    bool m_shader_remanency;
    3536    bool m_shader_blur;
    36     bool m_shader_remanency;
    3737    bool m_shader_glow;
    38     bool m_shader_fx;
    3938    bool m_shader_postfx;
    4039    bool m_border;
Note: See TracChangeset for help on using the changeset viewer.