Changeset 1461
- Timestamp:
- Jun 12, 2012, 7:56:18 PM (9 years ago)
- Location:
- trunk/neercs/video
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/neercs/video/render.cpp
r1460 r1461 195 195 glMatrixMode(GL_PROJECTION); 196 196 glLoadIdentity(); 197 mat4 proj = (type == 0) ? mat4::perspective(70, (float)screen_size.x, (float)screen_size.y, nearplane, farplane) : mat4::ortho(0, screen_size.x, screen_size.y, 0); 198 glLoadMatrixf(&proj[0][0]); 197 mat4 m; 198 if (type == 0) 199 m = mat4::perspective(70, (float)screen_size.x, (float)screen_size.y, 200 nearplane, farplane); 201 else 202 m = mat4::ortho(0, screen_size.x, screen_size.y, 0, -1.f, 1.f); 203 glLoadMatrixf(&m[0][0]); 199 204 glMatrixMode(GL_MODELVIEW); 200 205 } … … 488 493 } 489 494 } 495 496 Draw2D(); 497 Draw3D(); 498 } 499 500 void Render::Draw2D() 501 { 490 502 /*-PATACODE----------------------------------------------------------------*/ 491 503 #if SHADER 492 504 if(shader_flag) 493 505 { … … 499 511 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 500 512 } 501 513 #else 502 514 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 503 #endif 515 #endif 516 504 517 /*-/PATACODE---------------------------------------------------------------*/ 505 518 glEnable(GL_BLEND); … … 508 521 fx_angle=main_angle-part_angle; 509 522 if(polygon) glEnable(GL_TEXTURE_2D); 510 /* .-------------------. */ 511 /* | DRAW SOME 2D HERE | */ 512 /* °-------------------° */ 523 513 524 init_viewport(1); 525 514 526 tex_map->Bind(); 515 527 glEnable(GL_BLEND); … … 570 582 float l_w=(car%16)*0.03125f; 571 583 float l_h=(car-car%16)*0.001953125f; 572 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};584 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}; 573 585 glTexCoordPointer(2, GL_FLOAT, 0, dos_tex); 574 586 if(car==car_cursor) glColor3f(CR*(dos_color.r+64), CR*(dos_color.g+48), CR*(dos_color.b+48)); … … 638 650 glDrawArrays(GL_TRIANGLES, 0, corner_n*3); 639 651 glEnable(GL_BLEND); 640 /* .-------------------. */ 641 /* | DRAW SOME 3D HERE | */ 642 /* °-------------------° */ 652 tex_map->Unbind(); 653 } 654 655 void Render::Draw3D() 656 { 643 657 //init_viewport(0); 644 658 /*-PATACODE----------------------------------------------------------------*/ 645 #if SHADER 646 if (shader_flag) 647 { 648 init_shader(); 649 fbo_back->Unbind(); 650 if (shader_effect_flag && shader_blur_flag) 651 { 652 // shader blur horizontal 653 fbo_ping->Bind(); 654 shader_blur_h->Bind(); 655 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0); 656 shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f)); 657 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 658 shader_blur_h->SetUniform(shader_blur_h_value, 0.5f/screen_size.x); 659 fs_quad(); 660 shader_blur_h->Unbind(); 661 fbo_ping->Unbind(); 662 // shader blur vertical 663 fbo_front->Bind(); 664 shader_blur_v->Bind(); 665 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0); 666 shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f)); 667 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 668 shader_blur_v->SetUniform(shader_blur_v_value, 0.5f/screen_size.y); 669 fs_quad(); 670 shader_blur_v->Unbind(); 671 } 672 else 673 { 674 // shader simple 675 fbo_front->Bind(); 676 draw_shader_simple(fbo_back, 0); 677 } 678 fbo_front->Unbind(); 659 glDisable(GL_DEPTH_TEST); 660 661 #if SHADER 662 if (!shader_flag) 663 return; 664 665 init_shader(); 666 fbo_back->Unbind(); 667 if (shader_effect_flag && shader_blur_flag) 668 { 669 // shader blur horizontal 670 fbo_ping->Bind(); 671 shader_blur_h->Bind(); 672 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0); 673 shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f)); 674 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 675 shader_blur_h->SetUniform(shader_blur_h_value, 0.5f/screen_size.x); 676 fs_quad(); 677 shader_blur_h->Unbind(); 678 fbo_ping->Unbind(); 679 // shader blur vertical 680 fbo_front->Bind(); 681 shader_blur_v->Bind(); 682 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0); 683 shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f)); 684 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 685 shader_blur_v->SetUniform(shader_blur_v_value, 0.5f/screen_size.y); 686 fs_quad(); 687 shader_blur_v->Unbind(); 688 } 689 else 690 { 691 // shader simple 692 fbo_front->Bind(); 693 draw_shader_simple(fbo_back, 0); 694 } 695 fbo_front->Unbind(); 696 // shader glow 697 if(shader_effect_flag&&shader_glow_flag) 698 { 699 // shader blur horizontal 700 fbo_blur_h->Bind(); 701 shader_blur_h->Bind(); 702 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0); 703 shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size)); 704 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 705 shader_blur_h->SetUniform(shader_blur_h_value, 2.5f/screen_size.x); 706 fs_quad(); 707 shader_blur_h->Unbind(); 708 fbo_blur_h->Unbind(); 709 // shader blur vertical 710 fbo_blur_v->Bind(); 711 shader_blur_v->Bind(); 712 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 713 shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size)); 714 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 715 shader_blur_v->SetUniform(shader_blur_h_value, 2.5f/screen_size.y); 716 fs_quad(); 717 shader_blur_v->Unbind(); 718 fbo_blur_v->Unbind(); 719 // shader blur horizontal 720 fbo_blur_h->Bind(); 721 shader_blur_h->Bind(); 722 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0); 723 shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size)); 724 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 725 shader_blur_h->SetUniform(shader_blur_h_value, 1.0f/screen_size.x); 726 fs_quad(); 727 shader_blur_h->Unbind(); 728 fbo_blur_h->Unbind(); 729 // shader blur vertical 730 fbo_blur_v->Bind(); 731 shader_blur_v->Bind(); 732 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 733 shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size)); 734 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 735 shader_blur_v->SetUniform(shader_blur_h_value, 1.0f/screen_size.y); 736 fs_quad(); 737 shader_blur_v->Unbind(); 738 fbo_blur_v->Unbind(); 679 739 // shader glow 680 if(shader_effect_flag&&shader_glow_flag) 681 { 682 // shader blur horizontal 683 fbo_blur_h->Bind(); 684 shader_blur_h->Bind(); 685 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0); 686 shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size)); 687 shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); 688 shader_blur_h->SetUniform(shader_blur_h_value, 2.5f/screen_size.x); 689 fs_quad(); 690 shader_blur_h->Unbind(); 691 fbo_blur_h->Unbind(); 692 // shader blur vertical 693 fbo_blur_v->Bind(); 694 shader_blur_v->Bind(); 695 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 696 shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size)); 697 shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); 698 shader_blur_v->SetUniform(shader_blur_h_value, 2.5f/screen_size.y); 699 fs_quad(); 700 shader_blur_v->Unbind(); 701 fbo_blur_v->Unbind(); 702 // shader blur horizontal 703 fbo_blur_h->Bind(); 704 shader_blur_h->Bind(); 705 shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0); 706 shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(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, 1.0f/screen_size.x); 709 fs_quad(); 710 shader_blur_h->Unbind(); 711 fbo_blur_h->Unbind(); 712 // shader blur vertical 713 fbo_blur_v->Bind(); 714 shader_blur_v->Bind(); 715 shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 716 shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(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_size.y); 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_size, vec2(1.0f)); 728 shader_glow->SetUniform(shader_glow_time, fx_angle); 729 shader_glow->SetUniform(shader_glow_step, glow_smoothstep); 730 shader_glow->SetUniform(shader_glow_value1, glow_mix_ratio1); 731 shader_glow->SetUniform(shader_glow_value2, glow_mix_ratio2); 732 fs_quad(); 733 shader_glow->Unbind(); 734 } 735 if(!shader_effect_flag) 736 { 737 // shader simple 738 fbo_pong->Bind(); 739 draw_shader_simple(fbo_front, 0); 740 } 741 fbo_pong->Unbind(); 742 if(shader_postfx_flag) 743 { 744 // shader postfx 745 shader_postfx->Bind(); 746 shader_postfx->SetTexture(shader_postfx_texture, fbo_pong->GetTexture(), 0); 747 shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size); 748 shader_postfx->SetUniform(shader_postfx_time, fx_angle); 749 shader_postfx->SetUniform(shader_postfx_flash, flash_value); 750 shader_postfx->SetUniform(shader_postfx_value, 4.0f); 751 shader_postfx->SetUniform(shader_postfx_deform, postfx_deform); 752 shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline); 753 shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f))); 754 fs_quad(); 755 shader_postfx->Unbind(); 756 } 757 else 758 { 759 // shader simple 760 draw_shader_simple(fbo_pong, 0); 761 } 762 } 763 #endif 740 fbo_pong->Bind(); 741 shader_glow->Bind(); 742 shader_glow->SetTexture(shader_glow_texture, fbo_blur_v->GetTexture(), 0); 743 shader_glow->SetTexture(shader_glow_texture_prv, fbo_front->GetTexture(), 1); 744 shader_glow->SetUniform(shader_glow_screen_size, vec2(1.0f)); 745 shader_glow->SetUniform(shader_glow_time, fx_angle); 746 shader_glow->SetUniform(shader_glow_step, glow_smoothstep); 747 shader_glow->SetUniform(shader_glow_value1, glow_mix_ratio1); 748 shader_glow->SetUniform(shader_glow_value2, glow_mix_ratio2); 749 fs_quad(); 750 shader_glow->Unbind(); 751 } 752 if(!shader_effect_flag) 753 { 754 // shader simple 755 fbo_pong->Bind(); 756 draw_shader_simple(fbo_front, 0); 757 } 758 fbo_pong->Unbind(); 759 if(shader_postfx_flag) 760 { 761 // shader postfx 762 shader_postfx->Bind(); 763 shader_postfx->SetTexture(shader_postfx_texture, fbo_pong->GetTexture(), 0); 764 shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size); 765 shader_postfx->SetUniform(shader_postfx_time, fx_angle); 766 shader_postfx->SetUniform(shader_postfx_flash, flash_value); 767 shader_postfx->SetUniform(shader_postfx_value, 4.0f); 768 shader_postfx->SetUniform(shader_postfx_deform, postfx_deform); 769 shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline); 770 shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f))); 771 fs_quad(); 772 shader_postfx->Unbind(); 773 } 774 else 775 { 776 // shader simple 777 draw_shader_simple(fbo_pong, 0); 778 } 779 #endif 764 780 /*-/PATACODE---------------------------------------------------------------*/ 765 781 } -
trunk/neercs/video/render.h
r1447 r1461 17 17 virtual void TickDraw(float seconds); 18 18 19 void Draw2D(); 20 void Draw3D(); 21 19 22 private: 20 23 };
Note: See TracChangeset
for help on using the changeset viewer.