source: trunk/tools/neercs/video/render.cpp @ 1699

Last change on this file since 1699 was 1699, checked in by rez, 10 years ago

setup menu - basic option listing (F1/key_up/key_down)

File size: 21.9 KB
Line 
1//
2// Neercs
3//
4
5#if defined HAVE_CONFIG_H
6#   include "config.h"
7#endif
8
9#if defined _XBOX
10#   define _USE_MATH_DEFINES /* for M_PI */
11#   include <xtl.h>
12#elif defined _WIN32
13#   define _USE_MATH_DEFINES /* for M_PI */
14#   define WIN32_LEAN_AND_MEAN
15#   include <windows.h>
16#endif
17
18#include <cmath>
19#include <cstdio>
20#include <cstdlib>
21#include <ctime>
22#include <string>
23
24#include "core.h"
25#include "lolgl.h"
26
27using namespace std;
28using namespace lol;
29
30#include "../neercs.h"
31#include "render.h"
32#include "text-render.h"
33
34extern char const *lolfx_blurh;
35extern char const *lolfx_blurv;
36extern char const *lolfx_remanency;
37extern char const *lolfx_glow;
38extern char const *lolfx_postfx;
39extern char const *lolfx_radial;
40extern char const *lolfx_simple;
41
42#define PID M_PI/180.0f    // pi ratio
43#define CR 1.0f/256.0f     // color ratio
44
45/*
46 * Various variables
47 */
48
49int active = true;         // window active flag
50float nearplane = 0.1f;    // nearplane
51float farplane = 1000.0f;  // farplane
52int polygon_fillmode = GL_FILL; // fill mode
53/* timer variable */
54float timer = 0;           // timer
55float timer_key = 0;       // key timer
56float timer_key_repeat = 0.25f;// key repeat delay
57/* window variable */
58ivec2 screen_size;         // screen size
59vec3 screen_color = CR * vec3(32, 32, 32); // screen color
60/* object variable */
61float main_angle = 0.0f;   // main angle
62float part_angle = 0.0f;   // part angle
63float fx_angle;            // current angle
64/* fs_quad variable */
65float 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};
66float fs_quad_tex[] = {0, 1.0f, 0, 0, 1.0f, 0, 1.0f, 1.0f};
67/* flash variable */
68bool flash_flag = false;   // flag
69float flash_angle = 0;     // angle
70float flash_value = 0;     // value
71float flash_speed = 1.5f;  // speed
72/* fade variable */
73bool fade_flag = false;    // flag
74float fade_angle = 0;      // angle
75float fade_value = 0;      // value
76float fade_speed = 0.2f;   // speed
77/* sync variable */
78bool sync_flag = false;    // flagsh
79float sync_angle = 0;      // angle
80float sync_value = 1.0f;   // value
81float sync_speed = 1.0f;   // speed
82/* beat variable */
83bool beat_flag = false;    // flag
84float beat_angle = 0;      // angle
85float beat_value = 0;      // value
86float beat_speed = 2.0f;   // speed
87/* window variable */
88ivec2 border;              // border width
89/* text variable */
90ivec2 ratio_2d(2,4);       // 2d ratio
91ivec2 map_size(256,256);   // texture map size
92ivec2 font_size(8,8);      // font size
93ivec2 canvas_char(0,0);    // canvas char number
94ivec2 canvas_size(0,0);    // caca size
95/* setup variable */
96int setup_option=4;             // selected option
97ivec2 setup_p(1,1);             // position [x,y]
98ivec2 setup_size(32,0);         // size [w,h]
99ivec2 setup_color(0x678,0x234); // size [w,h]
100char const *setup_text[]={"remanency","blur","glow","deform","color","retrace","offset","noise","aberration","scanline"};
101/* common variable */
102float value, angle, radius, scale, speed;
103/* shader variable */
104vec2 buffer(0.75f,0.25f);       // [new frame mix,old frame mix]
105vec2 remanency(0.25f,0.75f);    // remanency [source mix,buffer mix]
106vec2 blur(0.25f,0.75f);         // glow radius [normal,deform]
107vec2 glow_mix(0.5f,0.5f);       // glow mix [source mix,glow mix]
108vec2 glow_large(2.0f,2.0f);     // large glow radius [normal,deform]
109vec2 glow_small(1.0f,1.0f);     // small glow radius [normal,deform]
110//vec3 radial(2.0f,0.8f,0);     // radial [mix,strength,color mode]
111//------------------------------// [IDEAS] http://www.youtube.com/watch?v=d1qEP2vMe-I
112float postfx_deform = 0.625f;   // deformation ratio
113vec3 postfx_filter(0.875f,0.75f,1.0f);// color filter [red,green,blue]
114vec3 postfx_color(1.75f,1.75f,0.5f);  // color modifier [brightness,contrast,gray]
115vec3 postfx_retrace(0.025f,2.0f,4.0f);// retrace [color,length,speed]
116vec2 postfx_offset(3.0f,3.0f);  // random line [horizontal,vertical]
117float postfx_noise = 0.125f;    // noise
118float postfx_aberration = 3.0f; // chromatic aberration
119bool postfx_moire = true;       // moire
120vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f);
121vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f);
122bool postfx_scanline = true;    // scanline
123vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f);// vertical scanline [base,variable,repeat x,repeat y]
124vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f);// horizontal scanline [base,variable,repeat x,repeat y]
125
126Shader *shader_simple;
127Shader *shader_blur_h, *shader_blur_v;
128Shader *shader_remanency, *shader_glow, *shader_radial, *shader_postfx;
129// shader variables
130ShaderUniform shader_simple_texture;
131ShaderUniform shader_blur_h_texture,
132              shader_blur_h_radius,
133              shader_blur_v_texture,
134              shader_blur_v_radius;
135ShaderUniform shader_remanency_source,
136              shader_remanency_buffer,
137              shader_remanency_mix;
138ShaderUniform shader_glow_glow,
139              shader_glow_source,
140              shader_glow_mix;
141ShaderUniform shader_radial_texture,
142              shader_radial_screen_size,
143              shader_radial_time,
144              shader_radial_value1,
145              shader_radial_value2,
146              shader_radial_color;
147ShaderUniform shader_postfx_texture,
148              shader_postfx_texture_2d,
149              shader_postfx_screen_size,
150              shader_postfx_time,
151              shader_postfx_deform,
152              shader_postfx_filter,
153              shader_postfx_color,
154              shader_postfx_retrace,
155              shader_postfx_offset,
156              shader_postfx_noise,
157              shader_postfx_aberration,
158              shader_postfx_moire,
159              shader_postfx_moire_h,
160              shader_postfx_moire_v,
161              shader_postfx_scanline,
162              shader_postfx_scanline_h,
163              shader_postfx_scanline_v,
164              shader_postfx_flash,
165              shader_postfx_sync;
166
167FrameBuffer *fbo_back, *fbo_front, *fbo_buffer;
168FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_ping, *fbo_pong;
169
170TextRender *text_render;
171
172void fs_quad()
173{
174    glLoadIdentity();
175    glDrawArrays(GL_QUADS, 0, 4);
176}
177
178void draw_shader_simple(FrameBuffer *fbo_output, int n)
179{
180    shader_simple->Bind();
181    shader_simple->SetTexture(shader_simple_texture, fbo_output->GetTexture(), n);
182    fs_quad();
183    shader_simple->Unbind();
184}
185
186void rectangle(int x, int y, int w, int h)
187{
188    glLoadIdentity();
189    glBegin(GL_QUADS);
190        glVertex2i(x+w, y  );
191        glVertex2i(x  , y  );
192        glVertex2i(x  , y+h);
193        glVertex2i(x+w, y+h);
194    glEnd();
195}
196
197int Render::InitDraw(void)
198{
199    glDepthMask(GL_TRUE);     // do not write z-buffer
200    glEnable(GL_CULL_FACE);   // disable cull face
201    glCullFace(GL_BACK);      // don't draw front face
202
203    /* Initialise framebuffer objects */
204    fbo_back = new FrameBuffer(screen_size);
205    fbo_front = new FrameBuffer(screen_size);
206    fbo_buffer = new FrameBuffer(screen_size);
207    fbo_blur_h = new FrameBuffer(screen_size);
208    fbo_blur_v = new FrameBuffer(screen_size);
209    fbo_ping = new FrameBuffer(screen_size);
210    fbo_pong = new FrameBuffer(screen_size);
211    // shader simple
212    shader_simple = Shader::Create(lolfx_simple);
213    shader_simple_texture = shader_simple->GetUniformLocation("texture");
214    // shader blur horizontal
215    shader_blur_h = Shader::Create(lolfx_blurh);
216    shader_blur_h_texture = shader_blur_h->GetUniformLocation("texture");
217    shader_blur_h_radius = shader_blur_h->GetUniformLocation("radius");
218    // shader blur vertical
219    shader_blur_v = Shader::Create(lolfx_blurv);
220    shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
221    shader_blur_v_radius = shader_blur_v->GetUniformLocation("radius");
222    // shader remanency
223    shader_remanency = Shader::Create(lolfx_remanency);
224    shader_remanency_source = shader_remanency->GetUniformLocation("source");
225    shader_remanency_buffer = shader_remanency->GetUniformLocation("buffer");
226    shader_remanency_mix = shader_remanency->GetUniformLocation("mix");
227    // shader glow
228    shader_glow = Shader::Create(lolfx_glow);
229    shader_glow_glow = shader_glow->GetUniformLocation("glow");
230    shader_glow_source = shader_glow->GetUniformLocation("source");
231    shader_glow_mix = shader_glow->GetUniformLocation("mix");
232    // shader radial
233    shader_radial = Shader::Create(lolfx_radial);
234    shader_radial_texture = shader_radial->GetUniformLocation("texture");
235    shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
236    shader_radial_time = shader_radial->GetUniformLocation("time");
237    shader_radial_value1 = shader_radial->GetUniformLocation("value1");
238    shader_radial_value2 = shader_radial->GetUniformLocation("value2");
239    shader_radial_color = shader_radial->GetUniformLocation("color");
240    // shader postfx
241    shader_postfx = Shader::Create(lolfx_postfx);
242    shader_postfx_texture = shader_postfx->GetUniformLocation("texture");
243    shader_postfx_texture_2d = shader_postfx->GetUniformLocation("texture_2d");
244    shader_postfx_screen_size = shader_postfx->GetUniformLocation("screen_size");
245    shader_postfx_time = shader_postfx->GetUniformLocation("time");
246    shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
247    shader_postfx_filter = shader_postfx->GetUniformLocation("filter");
248    shader_postfx_color = shader_postfx->GetUniformLocation("color");
249    shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace");
250    shader_postfx_offset = shader_postfx->GetUniformLocation("offset");
251    shader_postfx_noise = shader_postfx->GetUniformLocation("noise");
252    shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration");
253    shader_postfx_moire = shader_postfx->GetUniformLocation("moire");
254    shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h");
255    shader_postfx_moire_v = shader_postfx->GetUniformLocation("moire_v");
256    shader_postfx_scanline = shader_postfx->GetUniformLocation("scanline");
257    shader_postfx_scanline_h = shader_postfx->GetUniformLocation("scanline_h");
258    shader_postfx_scanline_v = shader_postfx->GetUniformLocation("scanline_v");
259    shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
260    shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
261
262    return true;
263}
264
265int Render::CreateGLWindow()
266{
267    screen_size = Video::GetSize();
268    border = 18 * ratio_2d;
269    border.y = border.x; // enabled to get same border everywhere
270    canvas_char = (screen_size - border * 2) / (font_size * ratio_2d);
271    canvas_size = canvas_char * font_size * ratio_2d;
272
273    border = (screen_size - canvas_size) / 2;
274
275    caca_set_canvas_size(m_caca, canvas_char.x, canvas_char.y);
276
277    setup_size.y = 10;//sizeof setup_text;
278    setup_p = (canvas_char - setup_size) / 2;
279
280    InitDraw();
281    return true;
282}
283
284Render::Render(caca_canvas_t *caca)
285  : m_caca(caca),
286    m_ready(false),
287    m_pause(false),
288    m_polygon(true),
289    m_setup(true),
290    m_shader(true),
291    m_shader_remanency(true),
292    m_shader_glow(true),
293    m_shader_blur(true),
294    m_shader_fx(true),
295    m_shader_postfx(true),
296    m_border(false)
297{
298    text_render = new TextRender(m_caca, font_size);
299}
300
301void Render::TickGame(float seconds)
302{
303    Entity::TickGame(seconds);
304}
305
306void Render::Pause()
307{
308    m_pause=!m_pause;
309}
310
311void Render::TickDraw(float seconds)
312{
313    /* keyboard manager */
314    if (Input::GetButtonState(27/*SDLK_ESCAPE*/))
315        Ticker::Shutdown();
316    if (Input::GetButtonState(282/*SDLK_F1*/) && (timer - timer_key > timer_key_repeat))
317        {
318        m_setup = !m_setup;
319        timer_key = timer;
320        }
321    if (Input::GetButtonState(283/*SDLK_F2*/) && (timer - timer_key > timer_key_repeat))
322        {
323        /*
324        m_polygon = !m_polygon;
325        polygon_fillmode = (m_polygon)?GL_FILL:GL_LINE;
326        glPolygonMode(GL_FRONT, polygon_fillmode);
327        */
328        timer_key = timer;
329        }
330    if (Input::GetButtonState(284/*SDLK_F3*/) && (timer - timer_key > timer_key_repeat))
331        {
332        m_shader_blur = !m_shader_blur;
333        m_shader_glow = !m_shader_glow;
334        timer_key = timer;
335        }
336    if (Input::GetButtonState(285/*SDLK_F4*/)&&(timer-timer_key>timer_key_repeat))
337        {
338        m_shader_postfx = !m_shader_postfx;
339        timer_key = timer;
340        }
341    if (Input::GetButtonState(286/*SDLK_F5*/))
342        {
343        Pause();
344        }
345    if (Input::GetButtonState(273/*SDLK_UP*/)&&(timer-timer_key>timer_key_repeat))
346        {
347        setup_option--;
348        if (setup_option < 0) setup_option = setup_size.y - 1;
349        timer_key = timer;
350        }
351    if (Input::GetButtonState(274/*SDLK_DOWN*/)&&(timer-timer_key>timer_key_repeat))
352        {
353        setup_option++;
354        if (setup_option > setup_size.y - 1) setup_option = 0;
355        timer_key = timer;
356        }
357
358    Entity::TickDraw(seconds);
359
360    if (!m_ready)
361    {
362        CreateGLWindow();
363        text_render->Init();
364        m_ready = true;
365    }
366
367    // timer
368    if (!m_pause)
369    {
370        timer += seconds;
371        main_angle = timer * 100.0f * PID;
372    }
373    if (sync_flag)
374    {
375        angle=(main_angle-sync_angle)*sync_speed;
376        sync_value=1.0f-sinf(angle);
377        if (angle>90.0f*PID)
378        {
379            sync_value=0;
380            sync_flag=false;
381        }
382    }
383    if (beat_flag)
384    {
385        angle=(main_angle-beat_angle)*beat_speed;
386        beat_value=1.0f-sinf(angle);
387        if (angle>90.0f*PID)
388        {
389            beat_value=0;
390            beat_flag=false;
391        }
392    }
393    if (flash_flag)
394    {
395        angle=(main_angle-flash_angle)*flash_speed;
396        flash_value=1.0f-sinf(angle);
397        if (angle>90.0f*PID)
398        {
399            flash_value=0;
400            flash_flag=false;
401        }
402    }
403    if (fade_flag)
404    {
405        angle=(main_angle-fade_angle)*fade_speed;
406        fade_value=1.0f-sinf(angle);
407        if (angle>90.0f*PID)
408        {
409            fade_value=0;
410            fade_flag=false;
411        }
412    }
413    /* draw setup */
414    if (m_setup)
415    {
416        /* title */
417        caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
418        caca_draw_line(m_caca, setup_p.x, setup_p.y, setup_p.x + setup_size.x, setup_p.y,' ');
419        caca_put_str(m_caca, setup_p.x + setup_size.x / 2 - 3, setup_p.y, "SETUP");
420        /* entries */
421        caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
422        caca_fill_box(m_caca, setup_p.x, setup_p.y + 1, setup_size.x + 1, setup_size.y,' ');
423        for (int i = 0; i < setup_size.y; i++)
424        {
425            int y = setup_p.y + 1 + i;
426            if (setup_option != i)
427            {
428                caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
429                caca_put_str(m_caca, setup_p.x + 1, y, setup_text[i]);
430            }
431            else
432            {
433                caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
434                caca_draw_line(m_caca, setup_p.x, y, setup_p.x + setup_size.x, y,' ');
435                caca_put_str(m_caca, setup_p.x + 1, y, setup_text[i]);
436            }
437        }
438    }
439
440    Draw2D();
441    Draw3D();
442
443}
444
445void Render::Draw2D()
446{
447    /* Draw text in an offline buffer */
448    text_render->Render();
449
450    if (m_shader)
451    {
452        fbo_back->Bind();
453    }
454
455    glViewport(0, 0, screen_size.x, screen_size.y);
456
457    /* Clear the back buffer */
458    glEnable(GL_BLEND);
459    glBlendFunc(GL_SRC_COLOR,GL_DST_ALPHA);
460    glClearColor(screen_color.r, screen_color.g, screen_color.b, 1.0f);
461    glClearDepth(1.0f); // set depth buffer
462    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
463
464    text_render->Blit(border, canvas_size);
465
466    //if (m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
467    glLineWidth((m_polygon)?2.0f:1.0f);
468    fx_angle=main_angle-part_angle;
469    if (m_polygon)
470        glEnable(GL_TEXTURE_2D);
471
472    glMatrixMode(GL_PROJECTION);
473    mat4 m = mat4::ortho(0, screen_size.x, screen_size.y, 0, -1.f, 1.f);
474    glLoadMatrixf(&m[0][0]);
475    glMatrixMode(GL_MODELVIEW);
476    // draw border
477    if (m_border)
478    {
479        glDisable(GL_TEXTURE_2D);
480        glDisable(GL_BLEND);
481        glColor3f(1.0f, 1.0f, 1.0f);
482        rectangle(border.x - ratio_2d.x, border.y - ratio_2d.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
483        rectangle(border.x - ratio_2d.x, border.y, ratio_2d.x, canvas_size.y);
484        rectangle(border.x + canvas_size.x, border.y, ratio_2d.x, canvas_size.y);
485        rectangle(border.x - ratio_2d.x, border.y + canvas_size.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
486        glEnable(GL_BLEND);
487    }
488}
489
490void Render::Draw3D()
491{
492    if (!m_shader)
493        return;
494
495    glDisable(GL_DEPTH_TEST);
496    glDisable(GL_BLEND);
497
498    glEnableClientState(GL_VERTEX_ARRAY);
499    glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx);
500
501    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
502    glTexCoordPointer(2, GL_FLOAT, 0, fs_quad_tex);
503
504    if (m_shader_remanency)
505    {
506        // shader remanency
507        fbo_ping->Bind();
508        shader_remanency->Bind();
509        shader_remanency->SetTexture(shader_remanency_source, fbo_back->GetTexture(), 0);
510        shader_remanency->SetTexture(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);
511        shader_remanency->SetUniform(shader_remanency_mix, remanency);
512        fs_quad();
513        shader_remanency->Unbind();
514        fbo_ping->Unbind();
515        // shader simple
516        fbo_back->Bind();
517        draw_shader_simple(fbo_ping, 0);
518        fbo_back->Unbind();
519        // save previous fbo
520        fbo_ping->Bind();
521        shader_remanency->Bind();
522        shader_remanency->SetTexture(shader_remanency_source, fbo_front->GetTexture(), 0);
523        shader_remanency->SetTexture(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);
524        shader_remanency->SetUniform(shader_remanency_mix, buffer);
525        fs_quad();
526        shader_remanency->Unbind();
527        fbo_ping->Unbind();
528        // shader simple
529        fbo_buffer->Bind();
530        draw_shader_simple(fbo_ping, 0);
531        fbo_buffer->Unbind();
532    }
533
534    // shader glow
535    if (m_shader_fx && m_shader_glow)
536    {
537        // shader blur horizontal
538        fbo_blur_h->Bind();
539        shader_blur_h->Bind();
540        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0);
541        shader_blur_h->SetUniform(shader_blur_h_radius, glow_large / screen_size.x);
542        fs_quad();
543        shader_blur_h->Unbind();
544        fbo_blur_h->Unbind();
545        // shader blur vertical
546        fbo_blur_v->Bind();
547        shader_blur_v->Bind();
548        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
549        shader_blur_v->SetUniform(shader_blur_v_radius, glow_large / screen_size.y);
550        fs_quad();
551        shader_blur_v->Unbind();
552        fbo_blur_v->Unbind();
553        // shader blur horizontal
554        fbo_blur_h->Bind();
555        shader_blur_h->Bind();
556        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
557        shader_blur_h->SetUniform(shader_blur_h_radius, glow_small / screen_size.x);
558        fs_quad();
559        shader_blur_h->Unbind();
560        fbo_blur_h->Unbind();
561        // shader blur vertical
562        fbo_blur_v->Bind();
563        shader_blur_v->Bind();
564        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
565        shader_blur_v->SetUniform(shader_blur_v_radius, glow_small / screen_size.y);
566        fs_quad();
567        shader_blur_v->Unbind();
568        fbo_blur_v->Unbind();
569        // shader glow
570        fbo_front->Bind();
571        shader_glow->Bind();
572        shader_glow->SetTexture(shader_glow_glow, fbo_blur_v->GetTexture(), 0);
573        shader_glow->SetTexture(shader_glow_source, fbo_back->GetTexture(), 1);
574        shader_glow->SetUniform(shader_glow_mix, glow_mix);
575        fs_quad();
576        shader_glow->Unbind();
577        fbo_front->Unbind();
578    }
579    else
580    {
581        // shader simple
582        fbo_front->Bind();
583        draw_shader_simple(fbo_back, 0);
584        fbo_front->Unbind();
585    }
586
587    if (m_shader_fx && m_shader_blur)
588    {
589        // shader blur horizontal
590        fbo_ping->Bind();
591        shader_blur_h->Bind();
592        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_front->GetTexture(), 0);
593        shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
594        fs_quad();
595        shader_blur_h->Unbind();
596        fbo_ping->Unbind();
597        // shader blur vertical
598        fbo_front->Bind();
599        shader_blur_v->Bind();
600        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
601        shader_blur_v->SetUniform(shader_blur_v_radius, blur / screen_size.y);
602        fs_quad();
603        shader_blur_v->Unbind();
604        fbo_front->Unbind();
605    }
606
607    if (m_shader_postfx)
608    {
609        // shader postfx
610        shader_postfx->Bind();
611        shader_postfx->SetTexture(shader_postfx_texture, fbo_front->GetTexture(), 0);
612        shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size);
613        shader_postfx->SetUniform(shader_postfx_time, fx_angle);
614        shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);
615        shader_postfx->SetUniform(shader_postfx_filter, postfx_filter);
616        shader_postfx->SetUniform(shader_postfx_color, postfx_color);
617        shader_postfx->SetUniform(shader_postfx_retrace, postfx_retrace);
618        shader_postfx->SetUniform(shader_postfx_offset, postfx_offset);
619        shader_postfx->SetUniform(shader_postfx_noise, postfx_noise);
620        shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration);
621        shader_postfx->SetUniform(shader_postfx_moire, postfx_moire);
622        shader_postfx->SetUniform(shader_postfx_moire_h, postfx_moire_h);
623        shader_postfx->SetUniform(shader_postfx_moire_v, postfx_moire_v);
624        shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline);
625        shader_postfx->SetUniform(shader_postfx_scanline_h, postfx_scanline_h);
626        shader_postfx->SetUniform(shader_postfx_scanline_v, postfx_scanline_v);
627        shader_postfx->SetUniform(shader_postfx_flash, flash_value);
628        shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f)));
629        fs_quad();
630        shader_postfx->Unbind();
631    }
632    else
633    {
634        // shader simple
635        draw_shader_simple(fbo_front, 0);
636    }
637
638    glDisableClientState(GL_VERTEX_ARRAY);
639    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
640}
641
642Render::~Render()
643{
644}
Note: See TracBrowser for help on using the repository browser.