Changeset 1473
- Timestamp:
- Jun 14, 2012, 3:41:27 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/neercs/video/render.cpp
r1469 r1473 39 39 extern char const *lolfx_text; 40 40 41 #define WIN32_LEAN_AND_MEAN42 41 #define DEBUG 1 // debug flag //#if defined(_DEBUG) 43 42 #define SHADER 1 // shader flag … … 55 54 int keys[256]; // keyboard array 56 55 int active = true; // window active flag 57 bool fullscreen = DEBUG?false:true; 56 bool fullscreen = DEBUG?false:true; // fullscreen flag 58 57 bool paused = false; // pause flag 59 58 float nearplane = 0.1f; // nearplane … … 61 60 bool polygon = true; // polygon mode 62 61 int polygon_fillmode = GL_FILL; // fill mode 63 int ratio_2d = 4; // 2d ratio64 62 /* window variable */ 65 int base_w = 800; // base width66 int base_h = 600; // base height67 int window_w = base_w; // width68 int window_h = base_h; // height69 63 ivec2 screen_size; // screen size 70 64 int window_color = 32; // color depth … … 89 83 float fade_value = 0; // value 90 84 float fade_speed; // speed 91 /* debug variable */92 bool debug_flag = false; // flag93 int debug_x; // position x94 int debug_y; // position y95 int debug_w; // width96 int debug_h; // height97 int debug_vtx[8]; // vertex array98 85 /* sync variable */ 99 86 bool sync_flag = false; // flag … … 112 99 /* dos variable */ 113 100 bool dos_flag = false; // flag 114 int dos_w; // width115 int dos_h; // height116 101 int dos_m; // margin 117 102 vec3 dos_color; // color value 118 103 int dos_vtx[8]; // vertex array 104 ivec2 ratio_2d(2,6); // 2d ratio 105 ivec2 map_size(256,256); // texture map size 106 ivec2 font_size(8,8); // font size 107 vec2 car_size(1.0f/map_size.x*font_size.x, 1.0f/map_size.y*font_size.y); 119 108 int shell_vtx[8]; // vertex array 120 109 float shell_tex[] = {1.0f, 0.96875f, 1.0f, 1.0f, 0.78125f, 1.0f, 0.78125f, 0.96875f}; … … 130 119 bool shader_glow_flag = true; 131 120 int glow_fbo_size = 2; // glow fbo size 132 int glow_color; // 0 = color /1 = alpha121 int glow_color; // 0 = color / 1 = alpha 133 122 float glow_smoothstep; // glow smoothstep value 134 123 float glow_mix_ratio1; // glow mixing ratio … … 399 388 // initialize some variable 400 389 screen(); 401 /*-PATACODE----------------------------------------------------------------*/402 390 #if SHADER 403 391 if (shader_flag) … … 454 442 } 455 443 #endif 456 /*-/PATACODE---------------------------------------------------------------*/457 444 return true; 458 445 } … … 461 448 { 462 449 screen_size = Video::GetSize(); 463 //ratio_2d = (int)(screen_size.x/400); if(ratio_2d<2) ratio_2d = 2; 464 corner_w = 16*ratio_2d; 450 corner_w = 16*ratio_2d.x; 465 451 corner(); 466 dos_w = 2*ratio_2d; 467 dos_h = 4*ratio_2d; 468 dos_m = 12*ratio_2d; 469 dos_vtx[0] = dos_w; 470 dos_vtx[1] = dos_h; 471 dos_vtx[2] = dos_w; 472 dos_vtx[3] = -dos_h; 473 dos_vtx[4] = -dos_w; 474 dos_vtx[5] = -dos_h; 475 dos_vtx[6] = -dos_w; 476 dos_vtx[7] = dos_h; 477 shell_vtx[0] = dos_m+29*ratio_2d; 478 shell_vtx[1] = dos_m+9*ratio_2d; 479 shell_vtx[2] = dos_m+29*ratio_2d; 480 shell_vtx[3] = dos_m+1*ratio_2d; 481 shell_vtx[4] = dos_m+1*ratio_2d; 482 shell_vtx[5] = dos_m+1*ratio_2d; 483 shell_vtx[6] = dos_m+1*ratio_2d; 484 shell_vtx[7] = dos_m+9*ratio_2d; 485 debug_w = 5*ratio_2d; 486 debug_h = 5*ratio_2d; 487 debug_x = 10*ratio_2d; 488 debug_y = 28*ratio_2d; 489 debug_vtx[0] = debug_w; 490 debug_vtx[1] = debug_h; 491 debug_vtx[2] = debug_w; 492 debug_vtx[3] = -debug_h; 493 debug_vtx[4] = -debug_w; 494 debug_vtx[5] = -debug_h; 495 debug_vtx[6] = -debug_w; 496 debug_vtx[7] = debug_h; 452 dos_m=12*ratio_2d.x; 453 dos_vtx[0]=font_size.x*ratio_2d.x/2.0f; 454 dos_vtx[1]=font_size.y*ratio_2d.y/2.0f; 455 dos_vtx[2]=font_size.x*ratio_2d.x/2.0f; 456 dos_vtx[3]=-font_size.y*ratio_2d.y/2.0f; 457 dos_vtx[4]=-font_size.x*ratio_2d.x/2.0f; 458 dos_vtx[5]=-font_size.y*ratio_2d.y/2.0f; 459 dos_vtx[6]=-font_size.x*ratio_2d.x/2.0f; 460 dos_vtx[7]=font_size.y*ratio_2d.y/2.0f; 461 shell_vtx[0]=dos_m+58*ratio_2d.x; 462 shell_vtx[1]=dos_m+(font_size.y+1)*ratio_2d.y; 463 shell_vtx[2]=dos_m+58*ratio_2d.x; 464 shell_vtx[3]=dos_m+ratio_2d.y; 465 shell_vtx[4]=dos_m+2*ratio_2d.x; 466 shell_vtx[5]=dos_m+ratio_2d.y; 467 shell_vtx[6]=dos_m+2*ratio_2d.x; 468 shell_vtx[7]=dos_m+(font_size.y+1)*ratio_2d.y; 497 469 InitGL(); 498 470 return true; … … 579 551 void Render::Draw2D() 580 552 { 581 /*-PATACODE----------------------------------------------------------------*/582 553 #if SHADER 583 554 if(shader_flag) … … 594 565 #endif 595 566 596 /*-/PATACODE---------------------------------------------------------------*/597 567 glEnable(GL_BLEND); 598 568 //if(polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH); … … 610 580 glDisable(GL_TEXTURE_2D); 611 581 glDisable(GL_BLEND); 612 glColor3f(1.0f, 1.0f,1.0f);613 rectangle(dos_m, dos_m, screen_size.x-(int)(26.5f*ratio_2d)-dos_m*2, 10*ratio_2d);614 rectangle(screen_size.x- (int)(25.5f*ratio_2d)-dos_m, dos_m, 11*ratio_2d, 10*ratio_2d);615 rectangle(screen_size.x- (int)(13.5f*ratio_2d)-dos_m, dos_m, 11*ratio_2d, 10*ratio_2d);616 rectangle(screen_size.x- (int)(1.5f*ratio_2d)-dos_m, dos_m, (int)(1.5f*ratio_2d), 10*ratio_2d);617 rectangle(dos_m, dos_m+10*ratio_2d, 1*ratio_2d, screen_size.y-10*ratio_2d-dos_m*2);618 rectangle(screen_size.x- 1*ratio_2d-dos_m, dos_m+10*ratio_2d, 1*ratio_2d, screen_size.y-10*ratio_2d-dos_m*2);619 rectangle(dos_m+ 1*ratio_2d, screen_size.y-1*ratio_2d-dos_m, screen_size.x-2*ratio_2d-dos_m*2, 1*ratio_2d);620 glColor3f(dos_color. r, dos_color.g, dos_color.b);621 rectangle(dos_m+ 1*ratio_2d, dos_m+1*ratio_2d, 28*ratio_2d, 8*ratio_2d);622 rectangle(dos_m+ (int)(30.5f*ratio_2d), dos_m+2*ratio_2d, screen_size.x-(int)(58.5f*ratio_2d)-dos_m*2, 2*ratio_2d);623 rectangle(dos_m+ (int)(30.5f*ratio_2d), dos_m+6*ratio_2d, screen_size.x-(int)(58.5f*ratio_2d)-dos_m*2, 2*ratio_2d);624 rectangle(screen_size.x- (int)(24.5f*ratio_2d)-dos_m, dos_m+1*ratio_2d, 7*ratio_2d, 6*ratio_2d);625 glColor3f(1.0f, 1.0f,1.0f);626 rectangle(screen_size.x- (int)(23.5f*ratio_2d)-dos_m, dos_m+2*ratio_2d, 5*ratio_2d, 4*ratio_2d);627 glColor3f(0, 0,0);628 rectangle(screen_size.x- (int)(22.5f*ratio_2d)-dos_m, dos_m+3*ratio_2d, 7*ratio_2d, 6*ratio_2d);629 rectangle(screen_size.x- (int)(12.5f*ratio_2d)-dos_m, dos_m+1*ratio_2d, 7*ratio_2d, 6*ratio_2d);630 glColor3f(dos_color. r, dos_color.g, dos_color.b);631 rectangle(screen_size.x- (int)(10.5f*ratio_2d)-dos_m, dos_m+2*ratio_2d, 7*ratio_2d, 7*ratio_2d);632 glColor3f(1.0f, 1.0f,1.0f);633 rectangle(screen_size.x- (int)(9.5f*ratio_2d)-dos_m, dos_m+3*ratio_2d, 5*ratio_2d, 5*ratio_2d);634 rectangle(screen_size.x- 8*ratio_2d-dos_m, screen_size.y-9*ratio_2d-dos_m, 7*ratio_2d, 8*ratio_2d);635 glColor3f(dos_color. r, dos_color.g, dos_color.b);636 rectangle(screen_size.x- 7*ratio_2d-dos_m, screen_size.y-8*ratio_2d-dos_m, 6*ratio_2d, 7*ratio_2d);637 glColor3f(1.0f, 1.0f,1.0f);638 rectangle(screen_size.x- 4*ratio_2d-dos_m, screen_size.y-8*ratio_2d-dos_m, 4*ratio_2d, 2*ratio_2d);639 rectangle(screen_size.x- 7*ratio_2d-dos_m, screen_size.y-5*ratio_2d-dos_m, 2*ratio_2d, 5*ratio_2d);640 rectangle(screen_size.x- 6*ratio_2d-dos_m, screen_size.y-7*ratio_2d-dos_m, 1*ratio_2d, 1*ratio_2d);641 rectangle(screen_size.x- 4*ratio_2d-dos_m, screen_size.y-5*ratio_2d-dos_m, 2*ratio_2d, 3*ratio_2d);582 glColor3f(1.0f,1.0f,1.0f); 583 rectangle(dos_m,dos_m,screen_size.x-53*ratio_2d.x-dos_m*2,(font_size.y+2)*ratio_2d.y); 584 rectangle(screen_size.x-51*ratio_2d.x-dos_m,dos_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y); 585 rectangle(screen_size.x-27*ratio_2d.x-dos_m,dos_m,22*ratio_2d.x,(font_size.y+2)*ratio_2d.y); 586 rectangle(screen_size.x-3*ratio_2d.x-dos_m,dos_m,3*ratio_2d.x,(font_size.y+2)*ratio_2d.y); 587 rectangle(dos_m,dos_m+(font_size.y+2)*ratio_2d.y,2*ratio_2d.x,screen_size.y-(font_size.y+2)*ratio_2d.y-dos_m*2); 588 rectangle(screen_size.x-2*ratio_2d.x-dos_m,dos_m+(font_size.y+2)*ratio_2d.y,2*ratio_2d.x,screen_size.y-(font_size.y+2)*ratio_2d.y-dos_m*2); 589 rectangle(dos_m+2*ratio_2d.x,screen_size.y-ratio_2d.y-dos_m,screen_size.x-4*ratio_2d.x-dos_m*2,ratio_2d.y); 590 glColor3f(dos_color.x,dos_color.y,dos_color.z); 591 rectangle(dos_m+2*ratio_2d.x,dos_m+ratio_2d.y,56*ratio_2d.x,font_size.y*ratio_2d.y); 592 rectangle(dos_m+60*ratio_2d.x,dos_m+2*ratio_2d.y,screen_size.x-115*ratio_2d.x-dos_m*2,2*ratio_2d.y); 593 rectangle(dos_m+60*ratio_2d.x,dos_m+6*ratio_2d.y,screen_size.x-115*ratio_2d.x-dos_m*2,2*ratio_2d.y); 594 rectangle(screen_size.x-49*ratio_2d.x-dos_m,dos_m+ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y); 595 glColor3f(1.0f,1.0f,1.0f); 596 rectangle(screen_size.x-47*ratio_2d.x-dos_m,dos_m+2*ratio_2d.y,10*ratio_2d.x,4*ratio_2d.y); 597 glColor3f(0,0,0); 598 rectangle(screen_size.x-45*ratio_2d.x-dos_m,dos_m+3*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y); 599 rectangle(screen_size.x-25*ratio_2d.x-dos_m,dos_m+1*ratio_2d.y,14*ratio_2d.x,6*ratio_2d.y); 600 glColor3f(dos_color.x,dos_color.y,dos_color.z); 601 rectangle(screen_size.x-21*ratio_2d.x-dos_m,dos_m+2*ratio_2d.y,14*ratio_2d.x,7*ratio_2d.y); 602 glColor3f(1.0f,1.0f,1.0f); 603 rectangle(screen_size.x-19*ratio_2d.x-dos_m,dos_m+3*ratio_2d.y,10*ratio_2d.x,5*ratio_2d.y); 604 rectangle(screen_size.x-16*ratio_2d.x-dos_m,screen_size.y-9*ratio_2d.y-dos_m,14*ratio_2d.x,8*ratio_2d.y); 605 glColor3f(dos_color.x,dos_color.y,dos_color.z); 606 rectangle(screen_size.x-14*ratio_2d.x-dos_m,screen_size.y-8*ratio_2d.y-dos_m,12*ratio_2d.x,7*ratio_2d.y); 607 glColor3f(1.0f,1.0f,1.0f); 608 rectangle(screen_size.x-8*ratio_2d.x-dos_m,screen_size.y-8*ratio_2d.y-dos_m,8*ratio_2d.x,2*ratio_2d.y); 609 rectangle(screen_size.x-14*ratio_2d.x-dos_m,screen_size.y-5*ratio_2d.y-dos_m,4*ratio_2d.x,5*ratio_2d.y); 610 rectangle(screen_size.x-12*ratio_2d.x-dos_m,screen_size.y-7*ratio_2d.y-dos_m,2*ratio_2d.x,1*ratio_2d.y); 611 rectangle(screen_size.x-8*ratio_2d.x-dos_m,screen_size.y-5*ratio_2d.y-dos_m,4*ratio_2d.x,3*ratio_2d.y); 642 612 glEnable(GL_BLEND); 643 613 if(polygon) glEnable(GL_TEXTURE_2D); … … 648 618 // draw dos text 649 619 glVertexPointer(2, GL_INT, 0, dos_vtx); 650 float x = dos_m + (float)(dos_w + 2 * ratio_2d);651 float y = dos_m + (f loat)(15 * ratio_2d);652 653 /* Background colors */620 float x = dos_m + font_size.x; 621 float y = dos_m + (font_size.y*1.5f+3)*ratio_2d.y; 622 623 /* background colors */ 654 624 glDisable(GL_TEXTURE_2D); 655 625 for (int j = 0; j < caca_get_canvas_height(m_caca); j++) … … 659 629 660 630 glLoadIdentity(); 661 glTranslated(x+i* (dos_w+2*ratio_2d), y+j*(dos_h+4*ratio_2d), 0);631 glTranslated(x+i*font_size.x*ratio_2d.x, y+j*font_size.y*ratio_2d.y, 0); 662 632 663 633 uint16_t bg = caca_attr_to_rgb12_bg(att); … … 680 650 681 651 glLoadIdentity(); 682 glTranslated(x+i*(dos_w+2*ratio_2d), y+j*(dos_h+4*ratio_2d), 0); 683 684 float l_w=(car%16)*0.03125f; 685 float l_h=(car-car%16)*0.001953125f; 686 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}; 652 glTranslated(x+i*font_size.x*ratio_2d.x, y+j*font_size.y*ratio_2d.y, 0); 653 vec2 uv((car%16)*car_size.x, (car-car%16)*1.0f/map_size.y/16*font_size.y); 654 float dos_tex[]={uv.x+car_size.x, uv.y+0.5f+car_size.y, uv.x+car_size.x, uv.y+0.5f, uv.x, uv.y+0.5f, uv.x, uv.y+0.5f+car_size.y}; 655 687 656 glTexCoordPointer(2, GL_FLOAT, 0, dos_tex); 688 657 uint16_t fg = caca_attr_to_rgb12_fg(att); … … 719 688 { 720 689 //init_viewport(0); 721 /*-PATACODE----------------------------------------------------------------*/722 690 glDisable(GL_DEPTH_TEST); 723 691 … … 841 809 } 842 810 #endif 843 /*-/PATACODE---------------------------------------------------------------*/844 811 } 845 812
Note: See TracChangeset
for help on using the changeset viewer.