Ignore:
Timestamp:
Oct 25, 2012, 2:02:05 AM (10 years ago)
Author:
rez
Message:

neercs: early integration of theme support

File:
1 edited

Legend:

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

    r2041 r2043  
    9797ivec2 canvas_size(0,0);         // caca size
    9898ivec2 font_size(8,8);           // font size
    99 ivec2 ratio_2d(2,3);            // 2d ratio
    100 ivec2 border(2,1);              // border width
     99ivec2 ratio_2d(1,1);            // 2d ratio
     100ivec2 border(0,0);              // border width
    101101/* shader variable */
    102 vec2 buffer(0.2f,0.8f);         // [new frame mix,old frame mix]
    103 vec2 remanence(0.6f,0.4f);      // remanence [source mix,buffer mix]
     102vec2 buffer(1.0f,0.0f);         // [new frame mix,old frame mix]
     103vec2 remanence(0.0f,0.0f);      // remanence [source mix,buffer mix]
    104104vec2 glow_mix(0.7f,0.3f);       // glow mix [source mix,glow mix]
    105105vec2 glow_large(3.0f,0.0f);     // large glow radius [center,corner]
     
    126126vec4 mirror(0.95f,0.9f,0.4f,4.0f);              // mirror [width,height,strength,ratio]
    127127vec4 radial(4.0f,0.9f,16,0.25f);                // radial [distance,fade ratio,iteration,strength]
     128/* theme variable */
     129int theme_i = 0;                // current theme
     130int theme_n = 2;                // theme number
     131int theme_var_n = 79;           // var number
    128132/* setup variable */
    129133bool setup_switch = false;      // switch [option/item]
     
    141145ivec2 setup_canvas_size(ivec2(setup_size.x + 1, setup_size.y + 1) * font_size * ivec2(2,4));
    142146ivec2 setup_color(0xaaa,0x222); // color [foreground,background] 0x678,0x234
    143 char const *setup_text[] = {
     147char const *setup_text[]={
    144148    "main",
    145149        "2d ratio w",
     
    270274    };
    271275
    272 vec4 theme_var[]={
    273     vec4(0), /* default */
    274         vec4(0),
    275     vec4(0), /* crt */
    276         vec4(0),
    277     vec4(0), /* green screen */
    278         vec4(0),
    279     vec4(0), /* granpa tv */
    280         vec4(0)
     276float theme_var[]={
     277    /* default */
     278    2,3,                      // ratio_2d
     279    2,1,                      // border
     280    0.2f,0.8f,                // buffer
     281    0.6f,0.4f,                // remanence
     282    0.7f,0.3f,                // glow_mix
     283    3.0f,0.0f,                // glow_large
     284    1.5f,0.0f,                // glow_small
     285    0.5f,0.0f,                // blur
     286    0.8f,0.48f,               // postfx_deform
     287    0.0f,0.8f,0.96f,          // postfx_corner
     288    0.5f,                     // postfx_vignetting
     289    0.75f,0.25f,0.42f,4.0f,   // copper_copper
     290    4.0f,4.0f,4.0f,           // copper_mask_color
     291    0.9f,0.95f,0.85f,         // color_filter
     292    1.0f,1.25f,0.1f,0.4f,     // color_color
     293    4.0f,                     // postfx_aberration
     294    1.0f,1.0f,                // noise_offset
     295    0.15f,                    // noise_noise
     296    1.0f,1.0f,0.5f,           // noise_retrace
     297    1.0f,0.0f,0.0f,-0.25f,    // postfx_ghost1
     298    1.5f,0.0f,0.0f,0.25f,     // postfx_ghost2
     299    8.0f,0.25f,0.75f,0.2f,    // postfx_glass
     300    0.75f,-0.25f,0.0f,1.0f,   // postfx_moire_h
     301    0.75f,-0.25f,1.0f,2.0f,   // postfx_moire_v
     302    1.0f,0.0f,0.0f,0.0f,      // postfx_scanline_h
     303    0.75f,-0.25f,2.0f,0.0f,   // postfx_scanline_v
     304    0.95f,0.9f,0.4f,4.0f,     // mirror
     305    4.0f,0.9f,16,0.25f,       // radial
     306    /* crt */
     307    /* green screen */
     308    /* granpa tv */
     309    0.0f
    281310    };
     311
     312void Render::InitVar()
     313{
     314    int k = theme_i * theme_var_n;
     315    ratio_2d = vec2(theme_var[k], theme_var[k + 1]);
     316    border = vec2(theme_var[k + 2], theme_var[k + 3]);
     317    buffer = vec2(theme_var[k + 4], theme_var[k + 5]);
     318    remanence = vec2(theme_var[k + 6], theme_var[k + 7]);
     319    glow_mix = vec2(theme_var[k + 8], theme_var[k + 9]);
     320    glow_large = vec2(theme_var[k + 10], theme_var[k + 11]);
     321    glow_small = vec2(theme_var[k + 12], theme_var[k + 13]);
     322    blur = vec2(theme_var[k + 14], theme_var[k + 15]);
     323    postfx_deform = vec2(theme_var[k + 16], theme_var[k + 17]);
     324    postfx_corner = vec3(theme_var[k + 18], theme_var[k + 19], theme_var[k + 20]);
     325    postfx_vignetting = theme_var[k + 21],
     326    copper_copper = vec4(theme_var[k + 22], theme_var[k + 23], theme_var[k + 24], theme_var[k + 25]);
     327    copper_mask_color = vec3(theme_var[k + 26], theme_var[k + 27], theme_var[k + 28]);
     328    color_filter = vec3(theme_var[k + 29], theme_var[k + 30], theme_var[k + 31]);
     329    color_color = vec4(theme_var[k + 32], theme_var[k + 33], theme_var[k + 34], theme_var[k + 35]);
     330    postfx_aberration = theme_var[k + 36];
     331    noise_offset = vec2(theme_var[k + 37], theme_var[k + 38]);
     332    noise_noise = theme_var[k + 39];
     333    noise_retrace = vec3(theme_var[k + 40], theme_var[k + 41], theme_var[k + 42]);
     334    postfx_ghost1 = vec4(theme_var[k + 43], theme_var[k + 44], theme_var[k + 45], theme_var[k + 46]);
     335    postfx_ghost2 = vec4(theme_var[k + 47], theme_var[k + 48], theme_var[k + 49], theme_var[k + 50]);
     336    postfx_glass = vec4(theme_var[k + 51], theme_var[k + 52], theme_var[k + 53], theme_var[k + 54]);
     337    postfx_moire_h = vec4(theme_var[k + 55], theme_var[k + 56], theme_var[k + 57], theme_var[k + 58]);
     338    postfx_moire_v = vec4(theme_var[k + 59], theme_var[k + 60], theme_var[k + 61], theme_var[k + 62]);
     339    postfx_scanline_h = vec4(theme_var[k + 63], theme_var[k + 64], theme_var[k + 65], theme_var[k + 66]);
     340    postfx_scanline_v = vec4(theme_var[k + 67], theme_var[k + 68], theme_var[k + 69], theme_var[k + 70]);
     341    mirror = vec4(theme_var[k + 71], theme_var[k + 72], theme_var[k + 73], theme_var[k + 74]);
     342    radial = vec4(theme_var[k + 75], theme_var[k + 76], theme_var[k + 77], theme_var[k + 78]);
     343}
    282344
    283345vec4 setup_var[]={ // setup variable [start,end,step,value]
     
    415477    int k = 1; /* main */
    416478    ratio_2d = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    417     border = vec2(setup_var[k].w, setup_var[k + 1].w) * ratio_2d * font_size; k += 2;
     479    border = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    418480    k += 5; /* remanence */
    419481    m_shader_remanence = (setup_var[k].w == 1) ? true : false; k++;
     
    469531{
    470532    screen_size = Video::GetSize();
    471     canvas_char = (screen_size - border * 2) / (font_size * ratio_2d);
     533    canvas_char = (screen_size - border * ratio_2d * font_size * 2) / (font_size * ratio_2d);
    472534    canvas_char = max(canvas_char, ivec2(1, 1));
    473535    canvas_size = canvas_char * font_size * ratio_2d;
     
    570632    glEnable(GL_CULL_FACE);   // disable cull face
    571633    glCullFace(GL_BACK);      // don't draw front face
    572 
    573634    /* initialise framebuffer objects */
    574635    fbo_back = new FrameBuffer(screen_size);
     
    661722    UpdateSize();
    662723    InitDraw();
     724    InitVar();
     725    UpdateSize();
    663726    return true;
    664727}
Note: See TracChangeset for help on using the changeset viewer.