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

Last change on this file since 1622 was 1622, checked in by rez, 11 years ago

updated logo (again) + better text canvas size (unfinished)

File size: 20.7 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_glow;
37extern char const *lolfx_postfx;
38extern char const *lolfx_radial;
39extern char const *lolfx_simple;
40
41#define PID M_PI/180.0f    // pi ratio
42#define CR 1.0f/256.0f     // color ratio
43
44/*
45 * Various variables
46 */
47
48int active = true;         // window active flag
49float nearplane = 0.1f;    // nearplane
50float farplane = 1000.0f;  // farplane
51int polygon_fillmode = GL_FILL; // fill mode
52bool key_state = 0;      // key state
53/* window variable */
54ivec2 screen_size;         // screen size
55vec3 screen_color = CR * vec3(48, 56, 64); // screen color
56/* object variable */
57float main_angle = 0.0f;   // main angle
58float part_angle = 0.0f;   // part angle
59float fx_angle;            // current angle
60/* fs_quad variable */
61float 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};
62float fs_quad_tex[] = {0, 1.0f, 0, 0, 1.0f, 0, 1.0f, 1.0f};
63/* flash variable */
64bool flash_flag = false;   // flag
65float flash_angle = 0;     // angle
66float flash_value = 0;     // value
67float flash_speed = 1.5f;  // speed
68/* fade variable */
69bool fade_flag = false;    // flag
70float fade_angle = 0;      // angle
71float fade_value = 0;      // value
72float fade_speed = 0.2f;   // speed
73/* sync variable */
74bool sync_flag = false;    // flag
75float sync_angle = 0;      // angle
76float sync_value = 1.0f;   // value
77float sync_speed = 1.0f;   // speed
78/* beat variable */
79bool beat_flag = false;    // flag
80float beat_angle = 0;      // angle
81float beat_value = 0;      // value
82float beat_speed = 2.0f;   // speed
83/* window variable */
84int window_m;              // margin
85int window_vtx[8];         // vertex array
86ivec2 ratio_2d(2,4);       // 2d ratio
87ivec2 map_size(256,256);   // texture map size
88ivec2 font_size(8,8);      // font size
89ivec2 text_size(80,25);    // text size
90ivec2 blit_top(0,0);       // text blit top position
91ivec2 blit_bottom(0,0);    // text blit bottom position
92int shell_vtx[8];          // vertex array
93float shell_tex[] = {1.0f, 0.96875f, 1.0f, 1.0f, 0.78125f, 1.0f, 0.78125f, 0.96875f};
94/* common variable */
95float value, angle, radius, scale, speed;
96/* shader variable */
97int glow_fbo_size = 2;        // glow fbo size
98float glow_smoothstep = 0.0f; // glow smoothstep value (try 0.025f)
99float glow_mix_ratio1 = 0.5f; // glow mixing ratio
100float glow_mix_ratio2 = 0.5f; // source mixing ratio
101float radial_value1 = 2.0f;
102float radial_value2 = 0.8f;
103float radial_color = 0;       // color
104bool postfx_scanline = true;
105float postfx_deform = 0.5f;   // deformation ratio
106
107Shader *shader_simple, *shader_blur_h, *shader_blur_v;
108Shader *shader_glow, *shader_radial, *shader_postfx;
109// shader variables
110ShaderUniform shader_simple_texture;
111ShaderUniform shader_blur_h_texture,
112              shader_blur_h_screen_size,
113              shader_blur_h_time,
114              shader_blur_h_value;
115ShaderUniform shader_blur_v_texture,
116              shader_blur_v_screen_size,
117              shader_blur_v_time,
118              shader_blur_v_value;
119ShaderUniform shader_glow_texture,
120              shader_glow_texture_prv,
121              shader_glow_screen_size,
122              shader_glow_time,
123              shader_glow_step,
124              shader_glow_value1,
125              shader_glow_value2;
126ShaderUniform shader_radial_texture,
127              shader_radial_screen_size,
128              shader_radial_time,
129              shader_radial_value1,
130              shader_radial_value2,
131              shader_radial_color;
132ShaderUniform shader_postfx_texture,
133              shader_postfx_texture_2d,
134              shader_postfx_screen_size,
135              shader_postfx_time,
136              shader_postfx_flash,
137              shader_postfx_value,
138              shader_postfx_deform,
139              shader_postfx_scanline,
140              shader_postfx_sync;
141
142FrameBuffer *fbo_back, *fbo_front;
143FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_ping, *fbo_pong;
144
145TextRender *text_render;
146
147void fs_quad()
148{
149    glLoadIdentity();
150    glDrawArrays(GL_QUADS, 0, 4);
151}
152
153void draw_shader_simple(FrameBuffer *fbo_output, int n)
154{
155    shader_simple->Bind();
156    shader_simple->SetTexture(shader_simple_texture, fbo_output->GetTexture(), n);
157    fs_quad();
158    shader_simple->Unbind();
159}
160
161void rectangle(int x, int y, int w, int h)
162{
163    glLoadIdentity();
164    glBegin(GL_QUADS);
165        glVertex2i(x+w, y  );
166        glVertex2i(x  , y  );
167        glVertex2i(x  , y+h);
168        glVertex2i(x+w, y+h);
169    glEnd();
170}
171
172int Render::InitDraw(void)
173{
174    glDepthMask(GL_TRUE);     // do not write z-buffer
175    glEnable(GL_CULL_FACE);   // disable cull face
176    glCullFace(GL_BACK);      // don't draw front face
177
178    if (m_shader)
179    {
180        /* Initialise framebuffer objects */
181        fbo_back = new FrameBuffer(screen_size);
182        fbo_front = new FrameBuffer(screen_size);
183        fbo_blur_h = new FrameBuffer(screen_size / glow_fbo_size);
184        fbo_blur_v = new FrameBuffer(screen_size / glow_fbo_size);
185        fbo_ping = new FrameBuffer(screen_size);
186        fbo_pong = new FrameBuffer(screen_size);
187        // shader simple
188        shader_simple = Shader::Create(lolfx_simple);
189        shader_simple_texture = shader_simple->GetUniformLocation("texture");
190        // shader blur horizontal
191        shader_blur_h = Shader::Create(lolfx_blurh);
192        shader_blur_h_texture = shader_blur_h->GetUniformLocation("texture");
193        shader_blur_h_screen_size = shader_blur_h->GetUniformLocation("screen_size");
194        shader_blur_h_time = shader_blur_h->GetUniformLocation("time");
195        shader_blur_h_value = shader_blur_h->GetUniformLocation("value");
196        // shader blur vertical
197        shader_blur_v = Shader::Create(lolfx_blurv);
198        shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
199        shader_blur_v_screen_size = shader_blur_v->GetUniformLocation("screen_size");
200        shader_blur_v_time = shader_blur_v->GetUniformLocation("time");
201        shader_blur_v_value = shader_blur_v->GetUniformLocation("value");
202        // shader glow
203        shader_glow = Shader::Create(lolfx_glow);
204        shader_glow_texture = shader_glow->GetUniformLocation("texture");
205        shader_glow_texture_prv = shader_glow->GetUniformLocation("texture_prv");
206        shader_glow_screen_size = shader_glow->GetUniformLocation("screen_size");
207        shader_glow_time = shader_glow->GetUniformLocation("time");
208        shader_glow_step = shader_glow->GetUniformLocation("step");
209        shader_glow_value1 = shader_glow->GetUniformLocation("value1");
210        shader_glow_value2 = shader_glow->GetUniformLocation("value2");
211        // shader radial
212        shader_radial = Shader::Create(lolfx_radial);
213        shader_radial_texture = shader_radial->GetUniformLocation("texture");
214        shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
215        shader_radial_time = shader_radial->GetUniformLocation("time");
216        shader_radial_value1 = shader_radial->GetUniformLocation("value1");
217        shader_radial_value2 = shader_radial->GetUniformLocation("value2");
218        shader_radial_color = shader_radial->GetUniformLocation("color");
219        // shader postfx
220        shader_postfx = Shader::Create(lolfx_postfx);
221        shader_postfx_texture = shader_postfx->GetUniformLocation("texture");
222        shader_postfx_texture_2d = shader_postfx->GetUniformLocation("texture_2d");
223        shader_postfx_screen_size = shader_postfx->GetUniformLocation("screen_size");
224        shader_postfx_time = shader_postfx->GetUniformLocation("time");
225        shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
226        shader_postfx_value = shader_postfx->GetUniformLocation("value");
227        shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
228        shader_postfx_scanline = shader_postfx->GetUniformLocation("scanline");
229        shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
230    }
231
232    return true;
233}
234
235int Render::CreateGLWindow()
236{
237    screen_size = Video::GetSize();
238
239    window_m = 12 * ratio_2d.x;
240    window_vtx[0] = font_size.x * ratio_2d.x / 2.0f;
241    window_vtx[1] = font_size.y * ratio_2d.y / 2.0f;
242    window_vtx[2] = font_size.x * ratio_2d.x / 2.0f;
243    window_vtx[3] = -font_size.y * ratio_2d.y / 2.0f;
244    window_vtx[4] = -font_size.x * ratio_2d.x / 2.0f;
245    window_vtx[5] = -font_size.y * ratio_2d.y / 2.0f;
246    window_vtx[6] = -font_size.x * ratio_2d.x / 2.0f;
247    window_vtx[7] = font_size.y * ratio_2d.y / 2.0f;
248    shell_vtx[0] = window_m + 58 * ratio_2d.x;
249    shell_vtx[1] = window_m + (font_size.y + 1) * ratio_2d.y;
250    shell_vtx[2] = window_m + 58 * ratio_2d.x;
251    shell_vtx[3] = window_m + ratio_2d.y;
252    shell_vtx[4] = window_m + 2 * ratio_2d.x;
253    shell_vtx[5] = window_m + ratio_2d.y;
254    shell_vtx[6] = window_m + 2 * ratio_2d.x;
255    shell_vtx[7] = window_m + (font_size.y + 1) * ratio_2d.y;
256
257    blit_top = ivec2(window_m, window_m + font_size.y * ratio_2d.y) + ratio_2d * 2;
258    blit_bottom = screen_size - ivec2(window_m * 2, window_m * 2 + font_size.y * ratio_2d.y) + ratio_2d * 2;
259
260    //caca_set_canvas_size(m_caca,20,10);
261
262    InitDraw();
263    return true;
264}
265
266Render::Render(caca_canvas_t *caca)
267  : m_caca(caca),
268    m_ready(false),
269    m_pause(false),
270    m_polygon(true),
271    m_shader(true),
272    m_shader_blur(true),
273    m_shader_glow(true),
274    m_shader_fx(true),
275    m_shader_postfx(true)
276{
277    text_render = new TextRender(m_caca, font_size);
278}
279
280void Render::TickGame(float seconds)
281{
282    Entity::TickGame(seconds);
283}
284
285void Render::Pause()
286{
287    m_pause=!m_pause;
288}
289
290void Render::TickDraw(float seconds)
291{
292    /* keyboard manager */
293    if (Input::GetButtonState(27/*SDLK_ESCAPE*/))
294        Ticker::Shutdown();
295    //if (Input::GetButtonState(282/*SDLK_F1*/))
296    //    Pause();
297    if (Input::GetButtonState(283/*SDLK_F2*/))
298        {
299        m_polygon=!m_polygon;
300        polygon_fillmode=(m_polygon)?GL_FILL:GL_LINE;
301        glPolygonMode(GL_FRONT,polygon_fillmode);
302        }
303    if (Input::GetButtonState(284/*SDLK_F3*/)&&key_state!=284)
304        {
305        m_shader=!m_shader;
306        key_state=284;
307        }
308    if (Input::GetButtonState(285/*SDLK_F4*/))
309        m_shader_postfx=!m_shader_postfx;
310    if (Input::GetButtonState(286/*SDLK_F5*/))
311        Pause();
312
313    Entity::TickDraw(seconds);
314
315    if (!m_ready)
316    {
317        CreateGLWindow();
318        text_render->Init();
319        m_ready = true;
320    }
321
322    // timer
323    if(!m_pause)
324        main_angle += seconds * 100.0f * PID;
325    if(sync_flag)
326    {
327        angle=(main_angle-sync_angle)*sync_speed;
328        sync_value=1.0f-sinf(angle);
329        if(angle>90.0f*PID)
330        {
331            sync_value=0;
332            sync_flag=false;
333        }
334    }
335    if(beat_flag)
336    {
337        angle=(main_angle-beat_angle)*beat_speed;
338        beat_value=1.0f-sinf(angle);
339        if(angle>90.0f*PID)
340        {
341            beat_value=0;
342            beat_flag=false;
343        }
344    }
345    if(flash_flag)
346    {
347        angle=(main_angle-flash_angle)*flash_speed;
348        flash_value=1.0f-sinf(angle);
349        if(angle>90.0f*PID)
350        {
351            flash_value=0;
352            flash_flag=false;
353        }
354    }
355    if(fade_flag)
356    {
357        angle=(main_angle-fade_angle)*fade_speed;
358        fade_value=1.0f-sinf(angle);
359        if(angle>90.0f*PID)
360        {
361            fade_value=0;
362            fade_flag=false;
363        }
364    }
365
366    Draw2D();
367    Draw3D();
368}
369
370void Render::Draw2D()
371{
372    /* Draw text in an offline buffer */
373    text_render->Render();
374
375    if(m_shader)
376        fbo_back->Bind();
377
378    glViewport(0, 0, screen_size.x, screen_size.y);
379
380    /* Clear the back buffer */
381    glEnable(GL_BLEND);
382    glBlendFunc(GL_SRC_COLOR,GL_DST_ALPHA);
383    glClearColor(screen_color.r, screen_color.g, screen_color.b, 1.0f);
384    glClearDepth(1.0f); // set depth buffer
385    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
386
387    text_render->Blit(blit_top, blit_bottom);
388
389    //if(m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
390    glLineWidth((m_polygon)?2.0f:1.0f);
391    fx_angle=main_angle-part_angle;
392    if(m_polygon) glEnable(GL_TEXTURE_2D);
393
394    glMatrixMode(GL_PROJECTION);
395    mat4 m = mat4::ortho(0, screen_size.x, screen_size.y, 0, -1.f, 1.f);
396    glLoadMatrixf(&m[0][0]);
397    glMatrixMode(GL_MODELVIEW);
398    // draw window
399    glDisable(GL_TEXTURE_2D);
400    glDisable(GL_BLEND);
401    glColor3f(1.0f,1.0f,1.0f);
402    rectangle(window_m,window_m,screen_size.x-53*ratio_2d.x-window_m*2,(font_size.y+2)*ratio_2d.y);
403    rectangle(screen_size.x-51*ratio_2d.x-window_m,window_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
404    rectangle(screen_size.x-27*ratio_2d.x-window_m,window_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
405    rectangle(screen_size.x-3*ratio_2d.x-window_m,window_m,3*ratio_2d.x,(font_size.y+2)*ratio_2d.y);
406    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);
407    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);
408    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);
409    glColor3f(screen_color.x,screen_color.y,screen_color.z);
410    rectangle(window_m+2*ratio_2d.x,window_m+ratio_2d.y,56*ratio_2d.x,font_size.y*ratio_2d.y);
411    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);
412    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);
413    rectangle(screen_size.x-49*ratio_2d.x-window_m,window_m+ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
414    glColor3f(1.0f,1.0f,1.0f);
415    rectangle(screen_size.x-47*ratio_2d.x-window_m,window_m+2*ratio_2d.y,10*ratio_2d.x,4*ratio_2d.y);
416    glColor3f(0,0,0);
417    rectangle(screen_size.x-45*ratio_2d.x-window_m,window_m+3*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
418    rectangle(screen_size.x-25*ratio_2d.x-window_m,window_m+1*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y);
419    glColor3f(screen_color.x,screen_color.y,screen_color.z);
420    rectangle(screen_size.x-21*ratio_2d.x-window_m,window_m+2*ratio_2d.y,14*ratio_2d.x,7*ratio_2d.y);
421    glColor3f(1.0f,1.0f,1.0f);
422    rectangle(screen_size.x-19*ratio_2d.x-window_m,window_m+3*ratio_2d.y,10*ratio_2d.x,5*ratio_2d.y);
423    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);
424    glColor3f(screen_color.x,screen_color.y,screen_color.z);
425    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);
426    glColor3f(1.0f,1.0f,1.0f);
427    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);
428    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);
429    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);
430    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);
431    glEnable(GL_BLEND);
432    if(m_polygon) glEnable(GL_TEXTURE_2D);
433    glBlendFunc(GL_ONE, GL_ONE);
434    glVertexPointer(2, GL_INT, 0, shell_vtx);
435    glTexCoordPointer(2, GL_FLOAT, 0, shell_tex);
436    glDrawArrays(GL_QUADS, 0, 4);
437    glEnable(GL_BLEND);
438}
439
440void Render::Draw3D()
441{
442    if (!m_shader)
443        return;
444
445    glDisable(GL_DEPTH_TEST);
446    glDisable(GL_BLEND);
447
448    glEnableClientState(GL_VERTEX_ARRAY);
449    glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx);
450
451    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
452    glTexCoordPointer(2, GL_FLOAT, 0, fs_quad_tex);
453
454    fbo_back->Unbind();
455    if (m_shader_fx && m_shader_blur)
456    {
457        // shader blur horizontal
458        fbo_ping->Bind();
459        shader_blur_h->Bind();
460        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0);
461        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f));
462        shader_blur_h->SetUniform(shader_blur_h_time, fx_angle);
463        shader_blur_h->SetUniform(shader_blur_h_value, 0.5f/screen_size.x);
464        fs_quad();
465        shader_blur_h->Unbind();
466        fbo_ping->Unbind();
467        // shader blur vertical
468        fbo_front->Bind();
469        shader_blur_v->Bind();
470        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
471        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f));
472        shader_blur_v->SetUniform(shader_blur_v_time, fx_angle);
473        shader_blur_v->SetUniform(shader_blur_v_value, 0.5f/screen_size.y);
474        fs_quad();
475        shader_blur_v->Unbind();
476    }
477    else
478    {
479        // shader simple
480        fbo_front->Bind();
481        draw_shader_simple(fbo_back, 0);
482    }
483    fbo_front->Unbind();
484    // shader glow
485    if(m_shader_fx && m_shader_glow)
486    {
487        // shader blur horizontal
488        fbo_blur_h->Bind();
489        shader_blur_h->Bind();
490        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0);
491        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
492        shader_blur_h->SetUniform(shader_blur_h_time, fx_angle);
493        shader_blur_h->SetUniform(shader_blur_h_value, 2.5f/screen_size.x);
494        fs_quad();
495        shader_blur_h->Unbind();
496        fbo_blur_h->Unbind();
497        // shader blur vertical
498        fbo_blur_v->Bind();
499        shader_blur_v->Bind();
500        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
501        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
502        shader_blur_v->SetUniform(shader_blur_v_time, fx_angle);
503        shader_blur_v->SetUniform(shader_blur_h_value, 2.5f/screen_size.y);
504        fs_quad();
505        shader_blur_v->Unbind();
506        fbo_blur_v->Unbind();
507        // shader blur horizontal
508        fbo_blur_h->Bind();
509        shader_blur_h->Bind();
510        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
511        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
512        shader_blur_h->SetUniform(shader_blur_h_time, fx_angle);
513        shader_blur_h->SetUniform(shader_blur_h_value, 1.0f/screen_size.x);
514        fs_quad();
515        shader_blur_h->Unbind();
516        fbo_blur_h->Unbind();
517        // shader blur vertical
518        fbo_blur_v->Bind();
519        shader_blur_v->Bind();
520        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
521        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
522        shader_blur_v->SetUniform(shader_blur_v_time, fx_angle);
523        shader_blur_v->SetUniform(shader_blur_h_value, 1.0f/screen_size.y);
524        fs_quad();
525        shader_blur_v->Unbind();
526        fbo_blur_v->Unbind();
527        // shader glow
528        fbo_pong->Bind();
529        shader_glow->Bind();
530        shader_glow->SetTexture(shader_glow_texture, fbo_blur_v->GetTexture(), 0);
531        shader_glow->SetTexture(shader_glow_texture_prv, fbo_front->GetTexture(), 1);
532        shader_glow->SetUniform(shader_glow_screen_size, vec2(1.0f));
533        shader_glow->SetUniform(shader_glow_time, fx_angle);
534        shader_glow->SetUniform(shader_glow_step, glow_smoothstep);
535        shader_glow->SetUniform(shader_glow_value1, glow_mix_ratio1);
536        shader_glow->SetUniform(shader_glow_value2, glow_mix_ratio2);
537        fs_quad();
538        shader_glow->Unbind();
539    }
540    if(!m_shader_fx)
541    {
542        // shader simple
543        fbo_pong->Bind();
544        draw_shader_simple(fbo_front, 0);
545    }
546    fbo_pong->Unbind();
547    if(m_shader_postfx)
548    {
549        // shader postfx
550        shader_postfx->Bind();
551        shader_postfx->SetTexture(shader_postfx_texture, fbo_pong->GetTexture(), 0);
552        shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size);
553        shader_postfx->SetUniform(shader_postfx_time, fx_angle);
554        shader_postfx->SetUniform(shader_postfx_flash, flash_value);
555        shader_postfx->SetUniform(shader_postfx_value, 4.0f);
556        shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);
557        shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline);
558        shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f)));
559        fs_quad();
560        shader_postfx->Unbind();
561    }
562    else
563    {
564        // shader simple
565        draw_shader_simple(fbo_pong, 0);
566    }
567
568    glDisableClientState(GL_VERTEX_ARRAY);
569    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
570}
571
572Render::~Render()
573{
574}
Note: See TracBrowser for help on using the repository browser.