]> git.jsancho.org Git - lugaru.git/commitdiff
Fix changing to interlaced mode while running.
authorVadim Trochinsky <vadim.trochinsky@gmail.com>
Sun, 23 May 2010 13:24:30 +0000 (17:24 +0400)
committerVadim Trochinsky <vadim.trochinsky@gmail.com>
Sun, 23 May 2010 13:24:30 +0000 (17:24 +0400)
Fix interlaced mode with FSAA enabled.

Source/Stereo.cpp

index b99c18e896e556c837a773d7031d238ebd824382..6680c43c8acac9d53b32f8d3939d0441f3ff5b1e 100644 (file)
@@ -47,6 +47,11 @@ void InitStereo(StereoMode mode) {
                        fprintf(stderr, "Screen width is %i, height is %i\n", kContextWidth, kContextHeight);
                        
                        // Setup stencil buffer
+                       glDisable( GL_DEPTH_TEST);
+                       glDisable(GL_CULL_FACE);
+                       glDisable(GL_LIGHTING);
+                       glDisable(GL_TEXTURE_2D);
+
                        glEnable( GL_STENCIL_TEST);
                        glClearStencil(0);
                        glClear(  GL_STENCIL_BUFFER_BIT );
@@ -62,25 +67,27 @@ void InitStereo(StereoMode mode) {
                                glMatrixMode(GL_MODELVIEW);
                                glPushMatrix();
                                        glLoadIdentity();
-                                       
                                        glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
-                                       
+                                       glDisable(GL_LINE_SMOOTH);
+
+                                       // Add 0.5 to the coordinates, because OpenGL considers a pixel should be
+                                       // turned on when a line passes through the center of it.
                                        if ( mode == stereoHorizontalInterlaced ) {
                                                for(int y=0;y<kContextHeight;y+=2) {
                                                        glBegin(GL_LINES);
-                                                               glVertex3f(0, y, 0);
-                                                               glVertex3f(kContextWidth, y, 0);
+                                                               glVertex3f(0.5, y+0.5, 0);
+                                                               glVertex3f(kContextWidth+0.5, y+0.5, 0);
                                                        glEnd();
                                                }
                                        } else {
                                                for(int x=0;x<kContextWidth;x+=2) {
                                                        glBegin(GL_LINES);
-                                                               glVertex3f(x, 0, 0);
-                                                               glVertex3f(x, kContextHeight, 0);
+                                                               glVertex3f(x+0.5, 0.5, 0);
+                                                               glVertex3f(x+0.5, kContextHeight+0.5, 0);
                                                        glEnd();
                                                }
                                        }
-                                       
+
                                        glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
                                        
                                glPopMatrix();
@@ -89,6 +96,11 @@ void InitStereo(StereoMode mode) {
                        
                        glStencilFunc(GL_NOTEQUAL, 0x01, 0x01);
                        glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+                       glEnable( GL_DEPTH_TEST);
+                       glEnable(GL_CULL_FACE);
+                       glEnable(GL_LIGHTING);
+                       glEnable(GL_TEXTURE_2D);
+
        }
        
 }