581 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
590 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
582 DrawWorldStereo(0, rmRightEye); |
591 DrawWorldStereo(0, rmRightEye); |
583 |
592 |
584 // detatch drawing from fbs |
593 // detatch drawing from fbs |
585 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); |
594 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); |
586 glGetFloatv(GL_COLOR_CLEAR_VALUE, @cc); |
|
587 glClearColor(0, 0, 0, 0); |
|
588 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
595 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
589 glClearColor(cc[0], cc[1], cc[2], cc[3]); |
|
590 SetScale(cDefaultZoomLevel); |
596 SetScale(cDefaultZoomLevel); |
591 |
|
592 // enable gl stuff |
|
593 glEnable(GL_TEXTURE_2D); |
|
594 glEnable(GL_BLEND); |
|
595 glBlendFunc(GL_ONE, GL_ONE); |
|
596 |
597 |
597 // draw left frame |
598 // draw left frame |
598 glBindTexture(GL_TEXTURE_2D, texl); |
599 glBindTexture(GL_TEXTURE_2D, texl); |
599 glColor3f(0.0, 1.0, 1.0); |
|
600 glBegin(GL_QUADS); |
600 glBegin(GL_QUADS); |
601 glTexCoord2f(0.0, 0.0); |
601 if cStereoMode = smHorizontal then |
602 glVertex2d(cScreenWidth / -2, cScreenHeight); |
602 begin |
603 glTexCoord2f(1.0, 0.0); |
603 glTexCoord2f(0.0, 0.0); |
604 glVertex2d(cScreenWidth / 2, cScreenHeight); |
604 glVertex2d(cScreenWidth / -2, cScreenHeight); |
605 glTexCoord2f(1.0, 1.0); |
605 glTexCoord2f(1.0, 0.0); |
606 glVertex2d(cScreenWidth / 2, 0); |
606 glVertex2d(0, cScreenHeight); |
607 glTexCoord2f(0.0, 1.0); |
607 glTexCoord2f(1.0, 1.0); |
608 glVertex2d(cScreenWidth / -2, 0); |
608 glVertex2d(0, 0); |
|
609 glTexCoord2f(0.0, 1.0); |
|
610 glVertex2d(cScreenWidth / -2, 0); |
|
611 end |
|
612 else |
|
613 begin |
|
614 glTexCoord2f(0.0, 0.0); |
|
615 glVertex2d(cScreenWidth / -2, cScreenHeight / 2); |
|
616 glTexCoord2f(1.0, 0.0); |
|
617 glVertex2d(cScreenWidth / 2, cScreenHeight / 2); |
|
618 glTexCoord2f(1.0, 1.0); |
|
619 glVertex2d(cScreenWidth / 2, 0); |
|
620 glTexCoord2f(0.0, 1.0); |
|
621 glVertex2d(cScreenWidth / -2, 0); |
|
622 end; |
609 glEnd(); |
623 glEnd(); |
610 |
624 |
611 // draw right frame |
625 // draw right frame |
612 glBindTexture(GL_TEXTURE_2D, texr); |
626 glBindTexture(GL_TEXTURE_2D, texr); |
613 glColor3f(1.0, 0.0, 0.0); |
|
614 glBegin(GL_QUADS); |
627 glBegin(GL_QUADS); |
615 glTexCoord2f(0.0, 0.0); |
628 if cStereoMode = smHorizontal then |
616 glVertex2d(cScreenWidth / -2, cScreenHeight); |
629 begin |
617 glTexCoord2f(1.0, 0.0); |
630 glTexCoord2f(0.0, 0.0); |
618 glVertex2d(cScreenWidth / 2, cScreenHeight); |
631 glVertex2d(0, cScreenHeight); |
619 glTexCoord2f(1.0, 1.0); |
632 glTexCoord2f(1.0, 0.0); |
620 glVertex2d(cScreenWidth / 2, 0); |
633 glVertex2d(cScreenWidth / 2, cScreenHeight); |
621 glTexCoord2f(0.0, 1.0); |
634 glTexCoord2f(1.0, 1.0); |
622 glVertex2d(cScreenWidth / -2, 0); |
635 glVertex2d(cScreenWidth / 2, 0); |
|
636 glTexCoord2f(0.0, 1.0); |
|
637 glVertex2d(0, 0); |
|
638 end |
|
639 else |
|
640 begin |
|
641 glTexCoord2f(0.0, 0.0); |
|
642 glVertex2d(cScreenWidth / -2, cScreenHeight); |
|
643 glTexCoord2f(1.0, 0.0); |
|
644 glVertex2d(cScreenWidth / 2, cScreenHeight); |
|
645 glTexCoord2f(1.0, 1.0); |
|
646 glVertex2d(cScreenWidth / 2, cScreenHeight / 2); |
|
647 glTexCoord2f(0.0, 1.0); |
|
648 glVertex2d(cScreenWidth / -2, cScreenHeight / 2); |
|
649 end; |
623 glEnd(); |
650 glEnd(); |
624 |
|
625 // reset |
|
626 glColor3f(1.0, 1.0, 1.0); |
|
627 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
628 SetScale(zoom); |
651 SetScale(zoom); |
629 end |
652 end |
|
653 else |
|
654 begin |
|
655 // clear scene |
|
656 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
|
657 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
|
658 // draw left eye in red channel only |
|
659 if cStereoMode = smGreenRed then |
|
660 glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE) |
|
661 else if cStereoMode = smBlueRed then |
|
662 glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE) |
|
663 else if cStereoMode = smCyanRed then |
|
664 glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE) |
|
665 else |
|
666 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); |
|
667 DrawWorldStereo(Lag, rmLeftEye); |
|
668 // draw right eye in selected channel(s) only |
|
669 if cStereoMode = smRedGreen then |
|
670 glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE) |
|
671 else if cStereoMode = smRedBlue then |
|
672 glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE) |
|
673 else if cStereoMode = smRedCyan then |
|
674 glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE) |
|
675 else |
|
676 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); |
|
677 DrawWorldStereo(Lag, rmRightEye); |
|
678 end |
630 end; |
679 end; |
631 |
680 |
632 procedure ChangeDepth(rm: TRenderMode; d: GLfloat); |
681 procedure ChangeDepth(rm: TRenderMode; d: GLfloat); |
633 begin |
682 begin |
|
683 d:= d / 5; |
634 if rm = rmDefault then exit |
684 if rm = rmDefault then exit |
635 else if rm = rmRightEye then d:= -d; |
685 else if rm = rmLeftEye then d:= -d; |
636 stereoDepth:= stereoDepth + d; |
686 stereoDepth:= stereoDepth + d; |
637 glMatrixMode(GL_PROJECTION); |
687 glMatrixMode(GL_PROJECTION); |
638 glTranslatef(d, 0, 0); |
688 glTranslatef(d, 0, 0); |
639 glMatrixMode(GL_MODELVIEW) |
689 glMatrixMode(GL_MODELVIEW) |
640 end; |
690 end; |