Changeset 1458 for trunk/neercs/video/render.cpp
- Timestamp:
- Jun 11, 2012, 11:56:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/neercs/video/render.cpp
r1457 r1458 1 1 // 2 // Monsterz 3 // 4 // Copyright: (c) 2005-2012 Sam Hocevar <sam@hocevar.net> 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the Do What The Fuck You Want To 7 // Public License, Version 2, as published by Sam Hocevar. See 8 // http://sam.zoy.org/projects/COPYING.WTFPL for more details. 2 // Neercs 9 3 // 10 4 … … 45 39 46 40 #define WIN32_LEAN_AND_MEAN 47 #define DEBUG 1 48 #define SHADER 1 49 #define PI 3.1415926535f // pi50 #define PID PI/180.0f 51 #define CR 1.0f/256.0f 41 #define DEBUG 1 // debug flag //#if defined(_DEBUG) 42 #define SHADER 1 // shader flag 43 #define PI 3.1415926535f // pi 44 #define PID PI/180.0f // pi ratio 45 #define CR 1.0f/256.0f // color ratio 52 46 53 47 bool done=false; 54 48 55 49 Timer *timer; 56 float timer_global=0;57 float timer_global_previous=0;58 float timer_fps=0;59 float timer_fps_total=0;60 float timer_fps_average=0;61 float timer_fps_min=32768;62 float timer_fps_max=0;63 int frame_counter=0;64 50 65 51 //char *param=GetCommandLine(); 66 52 67 int keys[256]; 68 int active=true; 69 bool fullscreen=DEBUG?false:true; 70 bool pause=false; 71 float nearplane=0.1f; 72 float farplane=1000.0f; 73 bool polygon=true; 74 int polygon_fillmode=GL_FILL; // fill mode75 int ratio_2d=4; 76 /* window variable 77 int base_w=800; 78 int base_h=600; 79 int window_w=base_w; 80 int window_h=base_h; 81 int screen_w; 82 int screen_h; 83 int window_color=32; 84 float screen_r; 85 float screen_g; 86 float screen_b; 87 /* object variable 88 float main_angle;// main angle89 float part_angle;// part angle90 float fx_angle; 91 /* liner variable 92 int car; 93 int car_cursor=126; 94 int liner_length; 95 int liner_line_n; 96 int liner_line; 97 int liner_max; 98 int liner_i; 99 int liner_count; 100 /* text variable 53 int keys[256]; // keyboard array 54 int active=true; // window active flag 55 bool fullscreen=DEBUG?false:true; // fullscreen flag 56 bool pause=false; // pause flag 57 float nearplane=0.1f; // nearplane 58 float farplane=1000.0f; // farplane 59 bool polygon=true; // polygon mode 60 int polygon_fillmode=GL_FILL; // fill mode 61 int ratio_2d=4; // 2d ratio 62 /* window variable */ 63 int base_w=800; // base width 64 int base_h=600; // base height 65 int window_w=base_w; // width 66 int window_h=base_h; // height 67 int screen_w; // screen width 68 int screen_h; // screen height 69 int window_color=32; // color depth 70 float screen_r; // color red 71 float screen_g; // color green 72 float screen_b; // color blue 73 /* object variable */ 74 float main_angle; // main angle 75 float part_angle; // part angle 76 float fx_angle; // current angle 77 /* liner variable */ 78 int car; // ascii code 79 int car_cursor=126; // cursor ascii code 80 int liner_length; // text length 81 int liner_line_n; // line number 82 int liner_line; // line increment 83 int liner_max; // line max length 84 int liner_i; // char increment 85 int liner_count; // counter 86 /* text variable */ 101 87 char *name="cacaShell"; 102 88 std::string txt(""); 103 /* fs_quad variable 104 float 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};105 float fs_quad_tex[]={0, 1.0f,0,0,1.0f,0,1.0f,1.0f};106 /* flash variable 107 bool flash_flag=false; 108 float flash_angle=0; 109 float flash_value=0; 110 float flash_speed; 111 /* fade variable 112 bool fade_flag=false; 113 float fade_angle=0; 114 float fade_value=0; 115 float fade_speed; 116 /* debug variable 117 bool debug_flag=false; 118 int debug_x; 119 int debug_y; 120 int debug_w; 121 int debug_h; 122 int debug_vtx[8]; 123 /* sync variable 124 bool sync_flag=false; 125 float sync_angle=0; 126 float sync_value=0; 127 float sync_speed; 128 /* beat variable 129 bool beat_flag=false; 130 float beat_angle=0; 131 float beat_value=0; 132 float beat_speed; 133 /* corner variable 134 const int corner_n=10; 135 int corner_w=24; 89 /* fs_quad variable */ 90 float 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}; 91 float fs_quad_tex[]={0, 1.0f, 0, 0, 1.0f, 0, 1.0f, 1.0f}; 92 /* flash variable */ 93 bool flash_flag=false; // flag 94 float flash_angle=0; // angle 95 float flash_value=0; // value 96 float flash_speed; // speed 97 /* fade variable */ 98 bool fade_flag=false; // flag 99 float fade_angle=0; // angle 100 float fade_value=0; // value 101 float fade_speed; // speed 102 /* debug variable */ 103 bool debug_flag=false; // flag 104 int debug_x; // position x 105 int debug_y; // position y 106 int debug_w; // width 107 int debug_h; // height 108 int debug_vtx[8]; // vertex array 109 /* sync variable */ 110 bool sync_flag=false; // flag 111 float sync_angle=0; // angle 112 float sync_value=0; // value 113 float sync_speed; // speed 114 /* beat variable */ 115 bool beat_flag=false; // flag 116 float beat_angle=0; // angle 117 float beat_value=0; // value 118 float beat_speed; // speed 119 /* corner variable */ 120 const int corner_n=10; // polygon number 121 int corner_w=24; // radius 136 122 int corner_vtx[corner_n*6];// vertex array 137 /* dos variable 138 bool dos_flag=false; 139 int dos_w; 140 int dos_h; 141 int dos_m; 142 float dos_r; 143 float dos_g; 144 float dos_b; 145 int dos_vtx[8]; 146 int shell_vtx[8]; 147 float shell_tex[]={1.0f, 0.96875f,1.0f,1.0f,0.78125f,1.0f,0.78125f,0.96875f};148 /* keyboard variable 149 int key_code=0; 150 /* common variable 151 int i, j,k,l;152 float x, y,z,w,h;153 float r, g,b,c;154 float value, angle,radius,scale,speed;123 /* dos variable */ 124 bool dos_flag=false; // flag 125 int dos_w; // width 126 int dos_h; // height 127 int dos_m; // margin 128 float dos_r; // red value 129 float dos_g; // green value 130 float dos_b; // blue value 131 int dos_vtx[8]; // vertex array 132 int shell_vtx[8]; // vertex array 133 float shell_tex[]={1.0f, 0.96875f, 1.0f, 1.0f, 0.78125f, 1.0f, 0.78125f, 0.96875f}; 134 /* keyboard variable */ 135 int key_code=0; // keyboard code 136 /* common variable */ 137 int i, j, k, l; 138 float x, y, z, w, h; 139 float r, g, b, c; 140 float value, angle, radius, scale, speed; 155 141 TileSet *tex_map; 156 /* shader variable 142 /* shader variable */ 157 143 bool shader_flag=SHADER?true:false; 158 144 bool shader_blur_flag=SHADER?true:false; 159 145 bool shader_effect_flag=SHADER?true:false; 160 146 bool shader_glow_flag=true; 161 int glow_fbo_size=2; 162 int glow_color; 163 float glow_smoothstep; 164 float glow_mix_ratio1; 165 float glow_mix_ratio2; 147 int glow_fbo_size=2; // glow fbo size 148 int glow_color; // 0=color/1=alpha 149 float glow_smoothstep; // glow smoothstep value 150 float glow_mix_ratio1; // glow mixing ratio 151 float glow_mix_ratio2; // source mixing ratio 166 152 bool shader_radial_flag=false; 167 153 float radial_value1; 168 154 float radial_value2; 169 float radial_color; 155 float radial_color; // color 170 156 bool shader_postfx_flag=SHADER?true:false; 171 157 bool postfx_scanline=true; 172 float postfx_deform; 158 float postfx_deform; // deformation ratio 173 159 #if SHADER 174 160 Shader* shader_simple; … … 215 201 ShaderUniform shader_postfx_scanline; 216 202 ShaderUniform shader_postfx_sync; 203 217 204 FrameBuffer *fbo_back; 218 205 FrameBuffer *fbo_front; … … 224 211 225 212 void init_viewport(int type) 226 227 glViewport(0,0,screen_w,screen_h);228 229 230 mat4 proj = (type == 0) ? mat4::perspective(70, (float)(float)screen_w,(float)screen_h,nearplane,farplane) : mat4::ortho(0, screen_w, screen_h, 0);213 { 214 glViewport(0, 0, screen_w, screen_h); 215 glMatrixMode(GL_PROJECTION); 216 glLoadIdentity(); 217 mat4 proj = (type == 0) ? mat4::perspective(70, (float)(float)screen_w, (float)screen_h, nearplane, farplane) : mat4::ortho(0, screen_w, screen_h, 0); 231 218 glLoadMatrixf(&proj[0][0]); 232 233 219 glMatrixMode(GL_MODELVIEW); 220 } 234 221 235 222 #if SHADER 236 223 void init_shader() 237 238 239 glVertexPointer(4,GL_FLOAT,0,fs_quad_vtx);240 glTexCoordPointer(2,GL_FLOAT,0,fs_quad_tex);241 224 { 225 glDisable(GL_BLEND); 226 glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx); 227 glTexCoordPointer(2, GL_FLOAT, 0, fs_quad_tex); 228 } 242 229 243 230 void fs_quad() 244 245 246 glDrawArrays(GL_QUADS,0,4);247 248 249 void draw_shader_simple(FrameBuffer *fbo_output, int n)250 251 252 shader_simple->SetTexture(shader_simple_texture,fbo_output->GetTexture(),n);253 254 255 231 { 232 glLoadIdentity(); 233 glDrawArrays(GL_QUADS, 0, 4); 234 } 235 236 void draw_shader_simple(FrameBuffer *fbo_output, int n) 237 { 238 shader_simple->Bind(); 239 shader_simple->SetTexture(shader_simple_texture, fbo_output->GetTexture(), n); 240 fs_quad(); 241 shader_simple->Unbind(); 242 } 256 243 #endif 257 244 258 245 void calc_txt() 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 246 { 247 liner_length=txt.length(); 248 liner_count=0; 249 liner_line_n=0; 250 liner_max=0; 251 liner_i=0; 252 for(i=0;i<liner_length;i++) 253 { 254 if((unsigned char)txt[i]!=13) 255 { 256 liner_i++; 257 } 258 else 259 { 260 if(liner_i>liner_max) liner_max=liner_i; 261 liner_line_n++; 262 liner_i=0; 263 } 264 } 265 if(liner_i>liner_max) liner_max=liner_i; 266 } 280 267 281 268 void flash() 282 283 284 285 269 { 270 flash_flag=true; 271 flash_angle=main_angle; 272 } 286 273 287 274 void fade() 288 289 290 291 275 { 276 fade_flag=true; 277 fade_angle=main_angle; 278 } 292 279 293 280 void sync() 294 295 296 297 281 { 282 sync_flag=true; 283 sync_angle=main_angle; 284 } 298 285 299 286 void beat() 300 301 302 303 304 305 void rectangle(int x, int y,int w,int h)306 307 308 309 glVertex2i(x+w,y );310 glVertex2i(x ,y );311 glVertex2i(x ,y+h);312 glVertex2i(x+w,y+h);313 314 287 { 288 beat_flag=true; 289 beat_angle=main_angle; 290 } 291 292 void rectangle(int x, int y, int w, int h) 293 { 294 glLoadIdentity(); 295 glBegin(GL_QUADS); 296 glVertex2i(x+w, y ); 297 glVertex2i(x , y ); 298 glVertex2i(x , y+h); 299 glVertex2i(x+w, y+h); 300 glEnd(); 301 } 315 302 316 303 void corner() 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 304 { 305 float vertex[2+corner_n*2]; 306 vertex[0]=0; 307 vertex[1]=0; 308 for(i=1;i<corner_n+1;i++) 309 { 310 j=i*2; 311 float a=PID*90.0f/(corner_n-1)*(i-1); 312 vertex[j ]=corner_w-corner_w*cosf(a); 313 vertex[j+1]=corner_w-corner_w*sinf(a); 314 } 315 for(i=0;i<corner_n;i++) 316 { 317 j=i*6; 318 k=i*2; 319 corner_vtx[j ]=(int)vertex[0]; 320 corner_vtx[j+1]=(int)vertex[1]; 321 corner_vtx[j+2]=(int)vertex[2+k]; 322 corner_vtx[j+3]=(int)vertex[3+k]; 323 corner_vtx[j+4]=(int)vertex[4+k]; 324 corner_vtx[j+5]=(int)vertex[5+k]; 325 } 326 } 340 327 341 328 void screen() 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 glClearColor(screen_r,screen_g,screen_b,1.0f);374 329 { 330 part_angle=main_angle; 331 dos_flag=true; 332 dos_r=CR*48; 333 dos_g=CR*56; 334 dos_b=CR*64; 335 screen_r=dos_r; 336 screen_g=dos_g; 337 screen_b=dos_b; 338 txt="\rCopyright \x05e 2012 cacaShell v0.1\r "; 339 calc_txt(); 340 /*-------------------------*/ 341 shader_effect_flag=true; 342 shader_glow_flag=true; 343 glow_color=1; 344 glow_smoothstep=0;//.025f; 345 glow_mix_ratio1=0.5f; 346 glow_mix_ratio2=0.5f; 347 shader_radial_flag=false; 348 radial_value1=2.0f; 349 radial_value2=0.8f; 350 radial_color=0; 351 postfx_deform=0.5f; 352 /*-------------------------*/ 353 flash_speed=1.5f; 354 fade_speed=0.2f; 355 sync_flag=false; 356 sync_value=1.0f; 357 sync_speed=1.0f; 358 beat_speed=2.0f; 359 /*-------------------------*/ 360 glClearColor(screen_r, screen_g, screen_b, 1.0f); 361 } 375 362 376 363 int InitGL(void) 377 378 glClearDepth(1.0f);// set depth buffer379 glDepthMask(GL_TRUE);// do not write z-buffer380 glEnable(GL_CULL_FACE);// disable cull face381 glCullFace(GL_BACK);// don't draw front face382 383 384 385 386 387 388 389 390 391 392 393 fbo_back=new FrameBuffer(ivec2(screen_w,screen_h));394 fbo_front=new FrameBuffer(ivec2(screen_w,screen_h));395 fbo_blur_h=new FrameBuffer(ivec2(screen_w/glow_fbo_size,screen_h/glow_fbo_size));396 fbo_blur_v=new FrameBuffer(ivec2(screen_w/glow_fbo_size,screen_h/glow_fbo_size));397 fbo_ping=new FrameBuffer(ivec2(screen_w,screen_h));398 fbo_pong=new FrameBuffer(ivec2(screen_w,screen_h));399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 364 { 365 glClearDepth(1.0f); // set depth buffer 366 glDepthMask(GL_TRUE); // do not write z-buffer 367 glEnable(GL_CULL_FACE); // disable cull face 368 glCullFace(GL_BACK); // don't draw front face 369 glEnableClientState(GL_VERTEX_ARRAY); 370 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 371 // load texture 372 tex_map=new TileSet("neercs/video/resource/map.bmp", ivec2(256, 256), ivec2(1)); 373 // initialize some variable 374 timer=new Timer(); 375 screen(); 376 /*-PATACODE----------------------------------------------------------------*/ 377 #if SHADER 378 if(shader_flag) 379 { 380 fbo_back=new FrameBuffer(ivec2(screen_w, screen_h)); 381 fbo_front=new FrameBuffer(ivec2(screen_w, screen_h)); 382 fbo_blur_h=new FrameBuffer(ivec2(screen_w/glow_fbo_size, screen_h/glow_fbo_size)); 383 fbo_blur_v=new FrameBuffer(ivec2(screen_w/glow_fbo_size, screen_h/glow_fbo_size)); 384 fbo_ping=new FrameBuffer(ivec2(screen_w, screen_h)); 385 fbo_pong=new FrameBuffer(ivec2(screen_w, screen_h)); 386 // shader simple 387 shader_simple=Shader::Create(lolfx_simple); 388 shader_simple_texture=shader_simple->GetUniformLocation("texture"); 389 // shader blur horizontal 390 shader_blur_h=Shader::Create(lolfx_blurh); 391 shader_blur_h_texture=shader_blur_h->GetUniformLocation("texture"); 392 shader_blur_h_screen_w=shader_blur_h->GetUniformLocation("screen_w"); 393 shader_blur_h_screen_h=shader_blur_h->GetUniformLocation("screen_h"); 394 shader_blur_h_time=shader_blur_h->GetUniformLocation("time"); 395 shader_blur_h_value=shader_blur_h->GetUniformLocation("value"); 396 // shader blur vertical 397 shader_blur_v=Shader::Create(lolfx_blurv); 398 shader_blur_v_texture=shader_blur_v->GetUniformLocation("texture"); 399 shader_blur_v_screen_w=shader_blur_v->GetUniformLocation("screen_w"); 400 shader_blur_v_screen_h=shader_blur_v->GetUniformLocation("screen_h"); 401 shader_blur_v_time=shader_blur_v->GetUniformLocation("time"); 402 shader_blur_v_value=shader_blur_v->GetUniformLocation("value"); 403 // shader glow 404 shader_glow=Shader::Create(lolfx_glow); 405 shader_glow_texture=shader_glow->GetUniformLocation("texture"); 406 shader_glow_texture_prv=shader_glow->GetUniformLocation("texture_prv"); 407 shader_glow_screen_w=shader_glow->GetUniformLocation("screen_w"); 408 shader_glow_screen_h=shader_glow->GetUniformLocation("screen_h"); 409 shader_glow_time=shader_glow->GetUniformLocation("time"); 410 shader_glow_step=shader_glow->GetUniformLocation("step"); 411 shader_glow_value1=shader_glow->GetUniformLocation("value1"); 412 shader_glow_value2=shader_glow->GetUniformLocation("value2"); 413 // shader radial 414 shader_radial=Shader::Create(lolfx_radial); 415 shader_radial_texture=shader_radial->GetUniformLocation("texture"); 416 shader_radial_screen_w=shader_radial->GetUniformLocation("screen_w"); 417 shader_radial_screen_h=shader_radial->GetUniformLocation("screen_h"); 418 shader_radial_time=shader_radial->GetUniformLocation("time"); 419 shader_radial_value1=shader_radial->GetUniformLocation("value1"); 420 shader_radial_value2=shader_radial->GetUniformLocation("value2"); 421 shader_radial_color=shader_radial->GetUniformLocation("color"); 422 // shader postfx 423 shader_postfx=Shader::Create(lolfx_postfx); 424 shader_postfx_texture=shader_postfx->GetUniformLocation("texture"); 425 shader_postfx_texture_2d=shader_postfx->GetUniformLocation("texture_2d"); 426 shader_postfx_screen_w=shader_postfx->GetUniformLocation("screen_w"); 427 shader_postfx_screen_h=shader_postfx->GetUniformLocation("screen_h"); 428 shader_postfx_time=shader_postfx->GetUniformLocation("time"); 429 shader_postfx_flash=shader_postfx->GetUniformLocation("flash"); 430 shader_postfx_value=shader_postfx->GetUniformLocation("value"); 431 shader_postfx_deform=shader_postfx->GetUniformLocation("deform"); 432 shader_postfx_scanline=shader_postfx->GetUniformLocation("scanline"); 433 shader_postfx_sync=shader_postfx->GetUniformLocation("sync"); 434 } 435 #endif 436 /*-/PATACODE---------------------------------------------------------------*/ 437 return true; 438 } 452 439 453 440 int DrawGLScene(void) // draw scene 454 { 455 frame_counter++; 456 // timer 457 timer_global_previous=timer_global; 458 timer_global+=timer->Get(); 459 if(!pause) main_angle=timer_global*100.0f*PID; 460 timer_fps=1.0f/(timer_global-timer_global_previous); 461 if(timer_fps<0) timer_fps=0; 462 if(timer_fps>1000) timer_fps=0; 463 timer_fps_total+=timer_fps; 464 timer_fps_average=timer_fps_total/frame_counter; 465 if(timer_fps<timer_fps_min) timer_fps_min=timer_fps; 466 if(timer_fps>timer_fps_max) timer_fps_max=timer_fps; 467 if(sync_flag) 468 { 469 angle=(main_angle-sync_angle)*sync_speed; 470 sync_value=1.0f-sinf(angle); 471 if(angle>90.0f*PID) 472 { 473 sync_value=0; 474 sync_flag=false; 475 } 476 } 477 if(beat_flag) 478 { 479 angle=(main_angle-beat_angle)*beat_speed; 480 beat_value=1.0f-sinf(angle); 481 if(angle>90.0f*PID) 482 { 483 beat_value=0; 484 beat_flag=false; 485 } 486 } 487 if(flash_flag) 488 { 489 angle=(main_angle-flash_angle)*flash_speed; 490 flash_value=1.0f-sinf(angle); 491 if(angle>90.0f*PID) 492 { 493 flash_value=0; 494 flash_flag=false; 495 } 496 } 497 if(fade_flag) 498 { 499 angle=(main_angle-fade_angle)*fade_speed; 500 fade_value=1.0f-sinf(angle); 501 if(angle>90.0f*PID) 502 { 503 fade_value=0; 504 fade_flag=false; 505 } 506 } 507 /*-PATACODE----------------------------------------------------------------*/ 508 #if SHADER 509 if(shader_flag) 510 { 511 fbo_back->Bind(); 512 fbo_back->Clear(vec4(screen_r,screen_g,screen_b,0.0f),1.0f); 513 } 514 else 515 { 516 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 517 } 518 #else 519 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 520 #endif 521 /*-/PATACODE---------------------------------------------------------------*/ 522 glEnable(GL_BLEND); 523 //if(polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH); 524 glLineWidth((polygon)?2.0f:1.0f); 525 fx_angle=main_angle-part_angle; 526 if(polygon) glEnable(GL_TEXTURE_2D); 527 /* .-------------------. */ 528 /* | DRAW SOME 2D HERE | */ 529 /* °-------------------° */ 530 init_viewport(1); 441 { 442 // timer 443 if(!pause) main_angle += timer->Get() * 100.0f * PID; 444 if(sync_flag) 445 { 446 angle=(main_angle-sync_angle)*sync_speed; 447 sync_value=1.0f-sinf(angle); 448 if(angle>90.0f*PID) 449 { 450 sync_value=0; 451 sync_flag=false; 452 } 453 } 454 if(beat_flag) 455 { 456 angle=(main_angle-beat_angle)*beat_speed; 457 beat_value=1.0f-sinf(angle); 458 if(angle>90.0f*PID) 459 { 460 beat_value=0; 461 beat_flag=false; 462 } 463 } 464 if(flash_flag) 465 { 466 angle=(main_angle-flash_angle)*flash_speed; 467 flash_value=1.0f-sinf(angle); 468 if(angle>90.0f*PID) 469 { 470 flash_value=0; 471 flash_flag=false; 472 } 473 } 474 if(fade_flag) 475 { 476 angle=(main_angle-fade_angle)*fade_speed; 477 fade_value=1.0f-sinf(angle); 478 if(angle>90.0f*PID) 479 { 480 fade_value=0; 481 fade_flag=false; 482 } 483 } 484 /*-PATACODE----------------------------------------------------------------*/ 485 #if SHADER 486 if(shader_flag) 487 { 488 fbo_back->Bind(); 489 fbo_back->Clear(vec4(screen_r, screen_g, screen_b, 0.0f), 1.0f); 490 } 491 else 492 { 493 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 494 } 495 #else 496 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 497 #endif 498 /*-/PATACODE---------------------------------------------------------------*/ 499 glEnable(GL_BLEND); 500 //if(polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH); 501 glLineWidth((polygon)?2.0f:1.0f); 502 fx_angle=main_angle-part_angle; 503 if(polygon) glEnable(GL_TEXTURE_2D); 504 /* .-------------------. */ 505 /* | DRAW SOME 2D HERE | */ 506 /* °-------------------° */ 507 init_viewport(1); 531 508 tex_map->Bind(); 532 533 534 535 536 537 538 glColor3f(1.0f,1.0f,1.0f);539 rectangle(dos_m,dos_m,screen_w-(int)(26.5f*ratio_2d)-dos_m*2,10*ratio_2d);540 rectangle(screen_w-(int)(25.5f*ratio_2d)-dos_m,dos_m,11*ratio_2d,10*ratio_2d);541 rectangle(screen_w-(int)(13.5f*ratio_2d)-dos_m,dos_m,11*ratio_2d,10*ratio_2d);542 rectangle(screen_w-(int)(1.5f*ratio_2d)-dos_m,dos_m,(int)(1.5f*ratio_2d),10*ratio_2d);543 rectangle(dos_m,dos_m+10*ratio_2d,1*ratio_2d,screen_h-10*ratio_2d-dos_m*2);544 rectangle(screen_w-1*ratio_2d-dos_m,dos_m+10*ratio_2d,1*ratio_2d,screen_h-10*ratio_2d-dos_m*2);545 rectangle(dos_m+1*ratio_2d,screen_h-1*ratio_2d-dos_m,screen_w-2*ratio_2d-dos_m*2,1*ratio_2d);546 glColor3f(dos_r,dos_g,dos_b);547 rectangle(dos_m+1*ratio_2d,dos_m+1*ratio_2d,28*ratio_2d,8*ratio_2d);548 rectangle(dos_m+(int)(30.5f*ratio_2d),dos_m+2*ratio_2d,screen_w-(int)(58.5f*ratio_2d)-dos_m*2,2*ratio_2d);549 rectangle(dos_m+(int)(30.5f*ratio_2d),dos_m+6*ratio_2d,screen_w-(int)(58.5f*ratio_2d)-dos_m*2,2*ratio_2d);550 rectangle(screen_w-(int)(24.5f*ratio_2d)-dos_m,dos_m+1*ratio_2d,7*ratio_2d,6*ratio_2d);551 glColor3f(1.0f,1.0f,1.0f);552 rectangle(screen_w-(int)(23.5f*ratio_2d)-dos_m,dos_m+2*ratio_2d,5*ratio_2d,4*ratio_2d);553 glColor3f(0,0,0);554 rectangle(screen_w-(int)(22.5f*ratio_2d)-dos_m,dos_m+3*ratio_2d,7*ratio_2d,6*ratio_2d);555 rectangle(screen_w-(int)(12.5f*ratio_2d)-dos_m,dos_m+1*ratio_2d,7*ratio_2d,6*ratio_2d);556 glColor3f(dos_r,dos_g,dos_b);557 rectangle(screen_w-(int)(10.5f*ratio_2d)-dos_m,dos_m+2*ratio_2d,7*ratio_2d,7*ratio_2d);558 glColor3f(1.0f,1.0f,1.0f);559 rectangle(screen_w-(int)(9.5f*ratio_2d)-dos_m,dos_m+3*ratio_2d,5*ratio_2d,5*ratio_2d);560 rectangle(screen_w-8*ratio_2d-dos_m,screen_h-9*ratio_2d-dos_m,7*ratio_2d,8*ratio_2d);561 glColor3f(dos_r,dos_g,dos_b);562 rectangle(screen_w-7*ratio_2d-dos_m,screen_h-8*ratio_2d-dos_m,6*ratio_2d,7*ratio_2d);563 glColor3f(1.0f,1.0f,1.0f);564 rectangle(screen_w-4*ratio_2d-dos_m,screen_h-8*ratio_2d-dos_m,4*ratio_2d,2*ratio_2d);565 rectangle(screen_w-7*ratio_2d-dos_m,screen_h-5*ratio_2d-dos_m,2*ratio_2d,5*ratio_2d);566 rectangle(screen_w-6*ratio_2d-dos_m,screen_h-7*ratio_2d-dos_m,1*ratio_2d,1*ratio_2d);567 rectangle(screen_w-4*ratio_2d-dos_m,screen_h-5*ratio_2d-dos_m,2*ratio_2d,3*ratio_2d);568 569 570 glBlendFunc(GL_ONE,GL_ONE);571 glVertexPointer(2,GL_INT,0,shell_vtx);572 glTexCoordPointer(2,GL_FLOAT,0,shell_tex);573 glDrawArrays(GL_QUADS,0,4);574 575 glVertexPointer(2,GL_INT,0,dos_vtx);576 577 578 579 580 581 582 583 584 585 586 glTranslated(x+j*(dos_w+2*ratio_2d),y,0);587 588 589 float dos_tex[]={l_w+0.03125f,0.5f-l_h-0.03125f,l_w+0.03125f,0.5f-l_h,l_w,0.5f-l_h,l_w,0.5f-l_h-0.03125f};590 glTexCoordPointer(2,GL_FLOAT,0,dos_tex);591 if(car==car_cursor) glColor3f(CR*(dos_r+64),CR*(dos_g+48),CR*(dos_b+48));592 glDrawArrays(GL_QUADS,0,4);593 if(car==car_cursor) glColor3f(1.0f,1.0f,1.0f);594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 sprintf(debug,"width=%d\rheight=%d\rratio=%dx\rfps=%3.1f\raverage=%3.1f\rfps min=%3.1f\rfps max=%3.1f\rbeat=%-02.1f\rsync=%-02.1f\rkey code=%03d\r",screen_w,screen_h,ratio_2d,timer_fps,timer_fps_average,timer_fps_min,timer_fps_max,beat_value,sync_value,key_code);611 612 613 glVertexPointer(2,GL_INT,0,debug_vtx);614 615 glBlendFunc(GL_ONE,GL_ONE);616 glColor3f(0.625f,0.25f,0.0f);617 glTranslated(debug_x,debug_y,0);618 619 620 621 622 623 624 625 glTranslated(-j*(debug_w-ratio_2d)*2,(debug_h-ratio_2d)*2,0);626 627 628 glTranslated((debug_w-ratio_2d)*2,0,0);629 630 631 632 633 float debug_tex[]={l_w+l_v-l_j,1.0f-l_h-l_v,l_w+l_v-l_j,1.0f-l_h,l_w-l_j,1.0f-l_h,l_w-l_j,1.0f-l_h-l_v};634 glTexCoordPointer(2,GL_FLOAT,0,debug_tex);635 glDrawArrays(GL_QUADS,0,4);636 637 638 639 640 641 642 643 glVertexPointer(2,GL_INT,0,corner_vtx);644 645 glColor3f(0,0,0);646 glDrawArrays(GL_TRIANGLES,0,corner_n*3);647 glTranslated(screen_w,0,0);648 glRotated(90.0f,0,0,1.0f);649 glDrawArrays(GL_TRIANGLES,0,corner_n*3);650 glTranslated(screen_h,0,0);651 glRotated(90.0f,0,0,1.0f);652 glDrawArrays(GL_TRIANGLES,0,corner_n*3);653 glTranslated(screen_w,0,0);654 glRotated(90.0f,0,0,1.0f);655 glDrawArrays(GL_TRIANGLES,0,corner_n*3);656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 shader_blur_h->SetTexture(shader_blur_h_texture,fbo_back->GetTexture(),0);673 shader_blur_h->SetUniform(shader_blur_h_screen_w,1.0f);674 shader_blur_h->SetUniform(shader_blur_h_screen_h,1.0f);675 shader_blur_h->SetUniform(shader_blur_h_time,fx_angle);676 shader_blur_h->SetUniform(shader_blur_h_value,0.5f/screen_w);677 678 679 680 681 682 683 shader_blur_v->SetTexture(shader_blur_v_texture,fbo_ping->GetTexture(),0);684 shader_blur_v->SetUniform(shader_blur_v_screen_w,1.0f);685 shader_blur_v->SetUniform(shader_blur_v_screen_h,1.0f);686 shader_blur_v->SetUniform(shader_blur_v_time,fx_angle);687 shader_blur_v->SetUniform(shader_blur_v_value,0.5f/screen_h);688 689 690 691 692 693 694 695 draw_shader_simple(fbo_back,0);696 697 698 699 700 701 702 703 704 shader_blur_h->SetTexture(shader_blur_h_texture,fbo_ping->GetTexture(),0);705 shader_blur_h->SetUniform(shader_blur_h_screen_w,1.0f/glow_fbo_size);706 shader_blur_h->SetUniform(shader_blur_h_screen_h,1.0f/glow_fbo_size);707 shader_blur_h->SetUniform(shader_blur_h_time,fx_angle);708 shader_blur_h->SetUniform(shader_blur_h_value,2.5f/screen_w);709 710 711 712 713 714 715 shader_blur_v->SetTexture(shader_blur_v_texture,fbo_blur_h->GetTexture(),0);716 shader_blur_v->SetUniform(shader_blur_v_screen_w,1.0f/glow_fbo_size);717 shader_blur_v->SetUniform(shader_blur_v_screen_h,1.0f/glow_fbo_size);718 shader_blur_v->SetUniform(shader_blur_v_time,fx_angle);719 shader_blur_v->SetUniform(shader_blur_h_value,2.5f/screen_h);720 721 722 723 724 725 726 shader_blur_h->SetTexture(shader_blur_h_texture,fbo_blur_v->GetTexture(),0);727 shader_blur_h->SetUniform(shader_blur_h_screen_w,1.0f/glow_fbo_size);728 shader_blur_h->SetUniform(shader_blur_h_screen_h,1.0f/glow_fbo_size);729 shader_blur_h->SetUniform(shader_blur_h_time,fx_angle);730 shader_blur_h->SetUniform(shader_blur_h_value,1.0f/screen_w);731 732 733 734 735 736 737 shader_blur_v->SetTexture(shader_blur_v_texture,fbo_blur_h->GetTexture(),0);738 shader_blur_v->SetUniform(shader_blur_v_screen_w,1.0f/glow_fbo_size);739 shader_blur_v->SetUniform(shader_blur_v_screen_h,1.0f/glow_fbo_size);740 shader_blur_v->SetUniform(shader_blur_v_time,fx_angle);741 shader_blur_v->SetUniform(shader_blur_h_value,1.0f/screen_h);742 743 744 745 746 747 748 shader_glow->SetTexture(shader_glow_texture,fbo_blur_v->GetTexture(),0);749 shader_glow->SetTexture(shader_glow_texture_prv,fbo_front->GetTexture(),1);750 shader_glow->SetUniform(shader_glow_screen_w,1.0f);751 shader_glow->SetUniform(shader_glow_screen_h,1.0f);752 shader_glow->SetUniform(shader_glow_time,fx_angle);753 shader_glow->SetUniform(shader_glow_step,glow_smoothstep);754 shader_glow->SetUniform(shader_glow_value1,glow_mix_ratio1);755 shader_glow->SetUniform(shader_glow_value2,glow_mix_ratio2);756 757 758 759 760 761 762 763 draw_shader_simple(fbo_front,0);764 765 766 767 768 769 770 shader_postfx->SetTexture(shader_postfx_texture,fbo_pong->GetTexture(),0);771 shader_postfx->SetUniform(shader_postfx_screen_w,screen_w);772 shader_postfx->SetUniform(shader_postfx_screen_h,screen_h);773 shader_postfx->SetUniform(shader_postfx_time,fx_angle);774 shader_postfx->SetUniform(shader_postfx_flash,flash_value);775 shader_postfx->SetUniform(shader_postfx_value,4.0f);776 shader_postfx->SetUniform(shader_postfx_deform,postfx_deform);777 shader_postfx->SetUniform(shader_postfx_scanline,postfx_scanline);778 shader_postfx->SetUniform(shader_postfx_sync,(float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f)));779 780 781 782 783 784 785 draw_shader_simple(fbo_pong,0);786 787 788 789 790 791 509 glEnable(GL_BLEND); 510 // draw dos 511 if(dos_flag) 512 { 513 glDisable(GL_TEXTURE_2D); 514 glDisable(GL_BLEND); 515 glColor3f(1.0f, 1.0f, 1.0f); 516 rectangle(dos_m, dos_m, screen_w-(int)(26.5f*ratio_2d)-dos_m*2, 10*ratio_2d); 517 rectangle(screen_w-(int)(25.5f*ratio_2d)-dos_m, dos_m, 11*ratio_2d, 10*ratio_2d); 518 rectangle(screen_w-(int)(13.5f*ratio_2d)-dos_m, dos_m, 11*ratio_2d, 10*ratio_2d); 519 rectangle(screen_w-(int)(1.5f*ratio_2d)-dos_m, dos_m, (int)(1.5f*ratio_2d), 10*ratio_2d); 520 rectangle(dos_m, dos_m+10*ratio_2d, 1*ratio_2d, screen_h-10*ratio_2d-dos_m*2); 521 rectangle(screen_w-1*ratio_2d-dos_m, dos_m+10*ratio_2d, 1*ratio_2d, screen_h-10*ratio_2d-dos_m*2); 522 rectangle(dos_m+1*ratio_2d, screen_h-1*ratio_2d-dos_m, screen_w-2*ratio_2d-dos_m*2, 1*ratio_2d); 523 glColor3f(dos_r, dos_g, dos_b); 524 rectangle(dos_m+1*ratio_2d, dos_m+1*ratio_2d, 28*ratio_2d, 8*ratio_2d); 525 rectangle(dos_m+(int)(30.5f*ratio_2d), dos_m+2*ratio_2d, screen_w-(int)(58.5f*ratio_2d)-dos_m*2, 2*ratio_2d); 526 rectangle(dos_m+(int)(30.5f*ratio_2d), dos_m+6*ratio_2d, screen_w-(int)(58.5f*ratio_2d)-dos_m*2, 2*ratio_2d); 527 rectangle(screen_w-(int)(24.5f*ratio_2d)-dos_m, dos_m+1*ratio_2d, 7*ratio_2d, 6*ratio_2d); 528 glColor3f(1.0f, 1.0f, 1.0f); 529 rectangle(screen_w-(int)(23.5f*ratio_2d)-dos_m, dos_m+2*ratio_2d, 5*ratio_2d, 4*ratio_2d); 530 glColor3f(0, 0, 0); 531 rectangle(screen_w-(int)(22.5f*ratio_2d)-dos_m, dos_m+3*ratio_2d, 7*ratio_2d, 6*ratio_2d); 532 rectangle(screen_w-(int)(12.5f*ratio_2d)-dos_m, dos_m+1*ratio_2d, 7*ratio_2d, 6*ratio_2d); 533 glColor3f(dos_r, dos_g, dos_b); 534 rectangle(screen_w-(int)(10.5f*ratio_2d)-dos_m, dos_m+2*ratio_2d, 7*ratio_2d, 7*ratio_2d); 535 glColor3f(1.0f, 1.0f, 1.0f); 536 rectangle(screen_w-(int)(9.5f*ratio_2d)-dos_m, dos_m+3*ratio_2d, 5*ratio_2d, 5*ratio_2d); 537 rectangle(screen_w-8*ratio_2d-dos_m, screen_h-9*ratio_2d-dos_m, 7*ratio_2d, 8*ratio_2d); 538 glColor3f(dos_r, dos_g, dos_b); 539 rectangle(screen_w-7*ratio_2d-dos_m, screen_h-8*ratio_2d-dos_m, 6*ratio_2d, 7*ratio_2d); 540 glColor3f(1.0f, 1.0f, 1.0f); 541 rectangle(screen_w-4*ratio_2d-dos_m, screen_h-8*ratio_2d-dos_m, 4*ratio_2d, 2*ratio_2d); 542 rectangle(screen_w-7*ratio_2d-dos_m, screen_h-5*ratio_2d-dos_m, 2*ratio_2d, 5*ratio_2d); 543 rectangle(screen_w-6*ratio_2d-dos_m, screen_h-7*ratio_2d-dos_m, 1*ratio_2d, 1*ratio_2d); 544 rectangle(screen_w-4*ratio_2d-dos_m, screen_h-5*ratio_2d-dos_m, 2*ratio_2d, 3*ratio_2d); 545 glEnable(GL_BLEND); 546 if(polygon) glEnable(GL_TEXTURE_2D); 547 glBlendFunc(GL_ONE, GL_ONE); 548 glVertexPointer(2, GL_INT, 0, shell_vtx); 549 glTexCoordPointer(2, GL_FLOAT, 0, shell_tex); 550 glDrawArrays(GL_QUADS, 0, 4); 551 // draw dos text 552 glVertexPointer(2, GL_INT, 0, dos_vtx); 553 j=0; 554 liner_line=-1; 555 for(i=1;i<liner_length+1;i++) 556 { 557 j++; 558 car=(unsigned char)txt[i-1]; 559 if(i==liner_length) car=car_cursor; 560 if(car>32) 561 { 562 glLoadIdentity(); 563 glTranslated(x+j*(dos_w+2*ratio_2d), y, 0); 564 float l_w=(car%16)*0.03125f; 565 float l_h=(car-car%16)*0.001953125f; 566 float dos_tex[]={l_w+0.03125f, 0.5f-l_h-0.03125f, l_w+0.03125f, 0.5f-l_h, l_w, 0.5f-l_h, l_w, 0.5f-l_h-0.03125f}; 567 glTexCoordPointer(2, GL_FLOAT, 0, dos_tex); 568 if(car==car_cursor) glColor3f(CR*(dos_r+64), CR*(dos_g+48), CR*(dos_b+48)); 569 glDrawArrays(GL_QUADS, 0, 4); 570 if(car==car_cursor) glColor3f(1.0f, 1.0f, 1.0f); 571 } 572 if(car==13) 573 { 574 j=0; 575 liner_line++; 576 x=dos_m; 577 y=dos_m+(float)(15*ratio_2d+liner_line*(dos_h+4*ratio_2d)); 578 if(y+dos_h>screen_h-dos_m) break; 579 } 580 } 581 } 582 // draw debug 583 //#if DEBUG 584 if(debug_flag) 585 { 586 char debug[512]; 587 sprintf(debug, "width=%d\rheight=%d\rratio=%dx\rbeat=%-02.1f\rsync=%-02.1f\rkey code=%03d\r", screen_w, screen_h, ratio_2d, beat_value, sync_value, key_code); 588 float l_v=0.0390625f; 589 float l_j=0.001953125f; 590 glVertexPointer(2, GL_INT, 0, debug_vtx); 591 glLoadIdentity(); 592 glBlendFunc(GL_ONE, GL_ONE); 593 glColor3f(0.625f, 0.25f, 0.0f); 594 glTranslated(debug_x, debug_y, 0); 595 j=0; 596 for(i=0;i<(int)strlen(debug);i++) 597 { 598 j++; 599 car=(unsigned char)debug[i]; 600 if(car==13) 601 { 602 glTranslated(-j*(debug_w-ratio_2d)*2, (debug_h-ratio_2d)*2, 0); 603 j=0; 604 } 605 glTranslated((debug_w-ratio_2d)*2, 0, 0); 606 if(car>32) 607 { 608 float l_w=(car%16)*0.03515625f; 609 float l_h=(car-car%16)*0.00244140625f; 610 float debug_tex[]={l_w+l_v-l_j, 1.0f-l_h-l_v, l_w+l_v-l_j, 1.0f-l_h, l_w-l_j, 1.0f-l_h, l_w-l_j, 1.0f-l_h-l_v}; 611 glTexCoordPointer(2, GL_FLOAT, 0, debug_tex); 612 glDrawArrays(GL_QUADS, 0, 4); 613 } 614 } 615 } 616 //#endif 617 // draw corner 618 glDisable(GL_TEXTURE_2D); 619 glDisable(GL_BLEND); 620 glVertexPointer(2, GL_INT, 0, corner_vtx); 621 glLoadIdentity(); 622 glColor3f(0, 0, 0); 623 glDrawArrays(GL_TRIANGLES, 0, corner_n*3); 624 glTranslated(screen_w, 0, 0); 625 glRotated(90.0f, 0, 0, 1.0f); 626 glDrawArrays(GL_TRIANGLES, 0, corner_n*3); 627 glTranslated(screen_h, 0, 0); 628 glRotated(90.0f, 0, 0, 1.0f); 629 glDrawArrays(GL_TRIANGLES, 0, corner_n*3); 630 glTranslated(screen_w, 0, 0); 631 glRotated(90.0f, 0, 0, 1.0f); 632 glDrawArrays(GL_TRIANGLES, 0, corner_n*3); 633 glEnable(GL_BLEND); 634 /* .-------------------. */ 635 /* | DRAW SOME 3D HERE | */ 636 /* °-------------------° */ 637 //init_viewport(0); 638 /*-PATACODE----------------------------------------------------------------*/ 639 #if SHADER 640 if(shader_flag) 641 { 642 init_shader(); 643 fbo_back->Unbind(); 644 if(shader_effect_flag&&shader_blur_flag) 645 { 646 // shader blur horizontal 647 fbo_ping->Bind(); 648 shader_blur_h->Bind(); 649 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0); 650 shader_blur_h->SetUniform(shader_blur_h_screen_w, 1.0f); 651 shader_blur_h->SetUniform(shader_blur_h_screen_h, 1.0f); 652 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 653 shader_blur_h->SetUniform(shader_blur_h_value, 0.5f/screen_w); 654 fs_quad(); 655 shader_blur_h->Unbind(); 656 fbo_ping->Unbind(); 657 // shader blur vertical 658 fbo_front->Bind(); 659 shader_blur_v->Bind(); 660 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0); 661 shader_blur_v->SetUniform(shader_blur_v_screen_w, 1.0f); 662 shader_blur_v->SetUniform(shader_blur_v_screen_h, 1.0f); 663 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 664 shader_blur_v->SetUniform(shader_blur_v_value, 0.5f/screen_h); 665 fs_quad(); 666 shader_blur_v->Unbind(); 667 } 668 else 669 { 670 // shader simple 671 fbo_front->Bind(); 672 draw_shader_simple(fbo_back, 0); 673 } 674 fbo_front->Unbind(); 675 // shader glow 676 if(shader_effect_flag&&shader_glow_flag) 677 { 678 // shader blur horizontal 679 fbo_blur_h->Bind(); 680 shader_blur_h->Bind(); 681 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0); 682 shader_blur_h->SetUniform(shader_blur_h_screen_w, 1.0f/glow_fbo_size); 683 shader_blur_h->SetUniform(shader_blur_h_screen_h, 1.0f/glow_fbo_size); 684 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 685 shader_blur_h->SetUniform(shader_blur_h_value, 2.5f/screen_w); 686 fs_quad(); 687 shader_blur_h->Unbind(); 688 fbo_blur_h->Unbind(); 689 // shader blur vertical 690 fbo_blur_v->Bind(); 691 shader_blur_v->Bind(); 692 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 693 shader_blur_v->SetUniform(shader_blur_v_screen_w, 1.0f/glow_fbo_size); 694 shader_blur_v->SetUniform(shader_blur_v_screen_h, 1.0f/glow_fbo_size); 695 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 696 shader_blur_v->SetUniform(shader_blur_h_value, 2.5f/screen_h); 697 fs_quad(); 698 shader_blur_v->Unbind(); 699 fbo_blur_v->Unbind(); 700 // shader blur horizontal 701 fbo_blur_h->Bind(); 702 shader_blur_h->Bind(); 703 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0); 704 shader_blur_h->SetUniform(shader_blur_h_screen_w, 1.0f/glow_fbo_size); 705 shader_blur_h->SetUniform(shader_blur_h_screen_h, 1.0f/glow_fbo_size); 706 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 707 shader_blur_h->SetUniform(shader_blur_h_value, 1.0f/screen_w); 708 fs_quad(); 709 shader_blur_h->Unbind(); 710 fbo_blur_h->Unbind(); 711 // shader blur vertical 712 fbo_blur_v->Bind(); 713 shader_blur_v->Bind(); 714 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 715 shader_blur_v->SetUniform(shader_blur_v_screen_w, 1.0f/glow_fbo_size); 716 shader_blur_v->SetUniform(shader_blur_v_screen_h, 1.0f/glow_fbo_size); 717 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 718 shader_blur_v->SetUniform(shader_blur_h_value, 1.0f/screen_h); 719 fs_quad(); 720 shader_blur_v->Unbind(); 721 fbo_blur_v->Unbind(); 722 // shader glow 723 fbo_pong->Bind(); 724 shader_glow->Bind(); 725 shader_glow->SetTexture(shader_glow_texture, fbo_blur_v->GetTexture(), 0); 726 shader_glow->SetTexture(shader_glow_texture_prv, fbo_front->GetTexture(), 1); 727 shader_glow->SetUniform(shader_glow_screen_w, 1.0f); 728 shader_glow->SetUniform(shader_glow_screen_h, 1.0f); 729 shader_glow->SetUniform(shader_glow_time, fx_angle); 730 shader_glow->SetUniform(shader_glow_step, glow_smoothstep); 731 shader_glow->SetUniform(shader_glow_value1, glow_mix_ratio1); 732 shader_glow->SetUniform(shader_glow_value2, glow_mix_ratio2); 733 fs_quad(); 734 shader_glow->Unbind(); 735 } 736 if(!shader_effect_flag) 737 { 738 // shader simple 739 fbo_pong->Bind(); 740 draw_shader_simple(fbo_front, 0); 741 } 742 fbo_pong->Unbind(); 743 if(shader_postfx_flag) 744 { 745 // shader postfx 746 shader_postfx->Bind(); 747 shader_postfx->SetTexture(shader_postfx_texture, fbo_pong->GetTexture(), 0); 748 shader_postfx->SetUniform(shader_postfx_screen_w, screen_w); 749 shader_postfx->SetUniform(shader_postfx_screen_h, screen_h); 750 shader_postfx->SetUniform(shader_postfx_time, fx_angle); 751 shader_postfx->SetUniform(shader_postfx_flash, flash_value); 752 shader_postfx->SetUniform(shader_postfx_value, 4.0f); 753 shader_postfx->SetUniform(shader_postfx_deform, postfx_deform); 754 shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline); 755 shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f))); 756 fs_quad(); 757 shader_postfx->Unbind(); 758 } 759 else 760 { 761 // shader simple 762 draw_shader_simple(fbo_pong, 0); 763 } 764 } 765 #endif 766 /*-/PATACODE---------------------------------------------------------------*/ 767 return true; 768 } 792 769 793 770 int CreateGLWindow(char* title) 794 { 795 GLuint pixelFormat; // pixel format result 796 uint32_t dwExStyle; // window extended style 797 uint32_t dwStyle; // window style 798 screen_w=Video::GetSize().x; 799 screen_h=Video::GetSize().y; 800 timer_fps_min=32768; 801 timer_fps_max=0; 802 //ratio_2d=(int)(screen_w/400); if(ratio_2d<2) ratio_2d=2; 803 corner_w=16*ratio_2d; 804 corner(); 805 dos_w=2*ratio_2d; 806 dos_h=4*ratio_2d; 807 dos_m=12*ratio_2d; 808 dos_vtx[0]=dos_w; 809 dos_vtx[1]=dos_h; 810 dos_vtx[2]=dos_w; 811 dos_vtx[3]=-dos_h; 812 dos_vtx[4]=-dos_w; 813 dos_vtx[5]=-dos_h; 814 dos_vtx[6]=-dos_w; 815 dos_vtx[7]=dos_h; 816 shell_vtx[0]=dos_m+29*ratio_2d; 817 shell_vtx[1]=dos_m+9*ratio_2d; 818 shell_vtx[2]=dos_m+29*ratio_2d; 819 shell_vtx[3]=dos_m+1*ratio_2d; 820 shell_vtx[4]=dos_m+1*ratio_2d; 821 shell_vtx[5]=dos_m+1*ratio_2d; 822 shell_vtx[6]=dos_m+1*ratio_2d; 823 shell_vtx[7]=dos_m+9*ratio_2d; 824 debug_w=5*ratio_2d; 825 debug_h=5*ratio_2d; 826 debug_x=10*ratio_2d; 827 debug_y=28*ratio_2d; 828 debug_vtx[0]=debug_w; 829 debug_vtx[1]=debug_h; 830 debug_vtx[2]=debug_w; 831 debug_vtx[3]=-debug_h; 832 debug_vtx[4]=-debug_w; 833 debug_vtx[5]=-debug_h; 834 debug_vtx[6]=-debug_w; 835 debug_vtx[7]=debug_h; 771 { 772 GLuint pixelFormat; // pixel format result 773 uint32_t dwExStyle; // window extended style 774 uint32_t dwStyle; // window style 775 screen_w=Video::GetSize().x; 776 screen_h=Video::GetSize().y; 777 //ratio_2d=(int)(screen_w/400); if(ratio_2d<2) ratio_2d=2; 778 corner_w=16*ratio_2d; 779 corner(); 780 dos_w=2*ratio_2d; 781 dos_h=4*ratio_2d; 782 dos_m=12*ratio_2d; 783 dos_vtx[0]=dos_w; 784 dos_vtx[1]=dos_h; 785 dos_vtx[2]=dos_w; 786 dos_vtx[3]=-dos_h; 787 dos_vtx[4]=-dos_w; 788 dos_vtx[5]=-dos_h; 789 dos_vtx[6]=-dos_w; 790 dos_vtx[7]=dos_h; 791 shell_vtx[0]=dos_m+29*ratio_2d; 792 shell_vtx[1]=dos_m+9*ratio_2d; 793 shell_vtx[2]=dos_m+29*ratio_2d; 794 shell_vtx[3]=dos_m+1*ratio_2d; 795 shell_vtx[4]=dos_m+1*ratio_2d; 796 shell_vtx[5]=dos_m+1*ratio_2d; 797 shell_vtx[6]=dos_m+1*ratio_2d; 798 shell_vtx[7]=dos_m+9*ratio_2d; 799 debug_w=5*ratio_2d; 800 debug_h=5*ratio_2d; 801 debug_x=10*ratio_2d; 802 debug_y=28*ratio_2d; 803 debug_vtx[0]=debug_w; 804 debug_vtx[1]=debug_h; 805 debug_vtx[2]=debug_w; 806 debug_vtx[3]=-debug_h; 807 debug_vtx[4]=-debug_w; 808 debug_vtx[5]=-debug_h; 809 debug_vtx[6]=-debug_w; 810 debug_vtx[7]=debug_h; 836 811 InitGL(); 837 838 812 return true; 813 } 839 814 840 815 Render::Render() … … 857 832 todo = 0; 858 833 } 859 834 DrawGLScene(); 860 835 } 861 836
Note: See TracChangeset
for help on using the changeset viewer.