| 637 | VAR(reflectscissor, 0, 1, 1); |
| 638 | |
| 639 | void drawreflection(float hf, int w, int h, float changelod, bool refract) |
| 640 | { |
| 641 | reflecting = true; |
| 642 | refracting = refract; |
| 643 | |
| 644 | int size = 1<<reflectsize, sizelimit = min(hwtexsize, min(w, h)); |
| 645 | while(size > sizelimit) size /= 2; |
| 646 | if(size!=reflectlastsize) |
| 647 | { |
| 648 | if(reflecttex) glDeleteTextures(1, &reflecttex); |
| 649 | if(refracttex) glDeleteTextures(1, &refracttex); |
| 650 | reflecttex = refracttex = 0; |
| 651 | } |
| 652 | if(!reflecttex || (waterrefract && !refracttex)) |
| 653 | { |
| 654 | if(!reflecttex) |
| 655 | { |
| 656 | glGenTextures(1, &reflecttex); |
| 657 | createtexture(reflecttex, size, size, NULL, 3, false, false, GL_RGB); |
| 658 | } |
| 659 | if(!refracttex) |
| 660 | { |
| 661 | glGenTextures(1, &refracttex); |
| 662 | createtexture(refracttex, size, size, NULL, 3, false, false, GL_RGB); |
| 663 | } |
| 664 | reflectlastsize = size; |
| 665 | } |
| 666 | |
| 667 | extern float wsx1, wsx2, wsy1, wsy2; |
| 668 | int sx = 0, sy = 0, sw = size, sh = size; |
| 669 | if(reflectscissor && (wsx1 > -1 || wsy1 > -1 || wsx1 < 1 || wsy1 < 1)) |
| 670 | { |
| 671 | sx = int(floor((wsx1+1)*0.5f*size)); |
| 672 | sy = int(floor((wsy1+1)*0.5f*size)); |
| 673 | sw = int(ceil((wsx2+1)*0.5f*size)) - sx; |
| 674 | sh = int(ceil((wsy2+1)*0.5f*size)) - sy; |
| 675 | } |
| 676 | glScissor(sx, sy, sw, sh); |
| 677 | glEnable(GL_SCISSOR_TEST); |
| 678 | |
| 679 | if(!refract) glCullFace(GL_BACK); |
| 680 | glViewport(0, 0, size, size); |
| 681 | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); |
| 682 | |
| 683 | resetcubes(); |
| 684 | |
| 685 | render_world(camera1->o.x, camera1->o.y, refract ? camera1->o.z : hf, changelod, |
| 686 | (int)camera1->yaw, (refract ? 1 : -1)*(int)camera1->pitch, dynfov(), fovy, size, size); |
| 687 | |
| 688 | setupstrips(); |
| 689 | |
| 690 | glEnable(GL_TEXTURE_2D); |
| 691 | |
| 692 | glPushMatrix(); |
| 693 | if(!refract) |
| 694 | { |
| 695 | glTranslatef(0, 0, 2*hf); |
| 696 | glScalef(1, 1, -1); |
no test coverage detected