]> git.jsancho.org Git - lugaru.git/blobdiff - Source/OpenGL_Windows.cpp
Add default stereo settings to config file
[lugaru.git] / Source / OpenGL_Windows.cpp
index f118ce7a6810413cd863ddeca95e54504db72b6e..576df7ecafdd761ca1b138d6448a567f9491c6b4 100644 (file)
@@ -703,6 +703,12 @@ Boolean SetUp (Game & game)
                opstream << KeyToChar(game.attackkey);
                opstream << "\nChat key:\n";
                opstream << KeyToChar(game.chatkey);
+               opstream << "\nStereoMode:\n";
+               opstream << stereomode;
+               opstream << "\nStereoSeparation:\n";
+               opstream << stereoseparation;
+               opstream << "\nStereoReverse:\n";
+               opstream << stereoreverse;
                opstream.close();
        }
        if(ipstream){
@@ -849,6 +855,18 @@ Boolean SetUp (Game & game)
                ipstream.ignore(256,'\n');
                ipstream >> string;
                game.chatkey=CharToKey(string);
+               ipstream.ignore(256,'\n');
+               ipstream.ignore(256,'\n');
+               if (!ipstream.eof()) {
+                       ipstream >> i;
+                       stereomode = (StereoMode)i;
+                       ipstream.ignore(256,'\n');
+                       ipstream.ignore(256,'\n');
+                       ipstream >> stereoseparation;
+                       ipstream.ignore(256,'\n');
+                       ipstream.ignore(256,'\n');
+                       ipstream >> stereoreverse;
+               }
                ipstream.close();
 
                if(detail>2)detail=2;
@@ -1027,47 +1045,49 @@ Boolean SetUp (Game & game)
                return false; 
        }
        
-       fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits);
-       fprintf(stderr, "Screen width is %i, height is %i\n", kContextWidth, kContextHeight);
-       
-       glEnable( GL_STENCIL_TEST);
-       glClearStencil(0);
-       glClear(  GL_STENCIL_BUFFER_BIT );
-       glStencilFunc(GL_ALWAYS, 0x1, 0x1);
-       glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
-       
-       
-       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-       glPixelStorei(GL_UNPACK_ROW_LENGTH, 3);
-       glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
-       glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
-       glColorMask( 1.0, 1.0, 1.0, 1.0 );
-       char stencil[] = {64,127,255};
-       
-       glViewport(0,0, kContextWidth, kContextHeight);
-       glMatrixMode(GL_PROJECTION);
-       glLoadIdentity();
-       glOrtho((GLdouble)0, (GLdouble)kContextWidth, (GLdouble)kContextHeight, 0, -1, 1);
-       glMatrixMode(GL_MODELVIEW);
-       glLoadIdentity();
-       
-       for(int y=0;y<kContextHeight;y+=2) {
+       if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
+               fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits);
+               fprintf(stderr, "Screen width is %i, height is %i\n", kContextWidth, kContextHeight);
                
-               for(int x=0;x<kContextWidth;x++) {
-                       glRasterPos2i(x, y);
-                       glDrawPixels(1, 1, GL_RGB, GL_UNSIGNED_BYTE, &stencil);
+               glEnable( GL_STENCIL_TEST);
+               glClearStencil(0);
+               glClear(  GL_STENCIL_BUFFER_BIT );
+               glStencilFunc(GL_ALWAYS, 0x1, 0x1);
+               glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+               
+               
+               glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+               glPixelStorei(GL_UNPACK_ROW_LENGTH, 3);
+               glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+               glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+               glColorMask( 1.0, 1.0, 1.0, 1.0 );
+               char stencil[] = {64,127,255};
+               
+               glViewport(0,0, kContextWidth, kContextHeight);
+               glMatrixMode(GL_PROJECTION);
+               glLoadIdentity();
+               glOrtho((GLdouble)0, (GLdouble)kContextWidth, (GLdouble)kContextHeight, 0, -1, 1);
+               glMatrixMode(GL_MODELVIEW);
+               glLoadIdentity();
+               
+               for(int y=0;y<kContextHeight;y+=2) {
+                       
+                       for(int x=0;x<kContextWidth;x++) {
+                               glRasterPos2i(x, y);
+                               glDrawPixels(1, 1, GL_RGB, GL_UNSIGNED_BYTE, &stencil);
+                       }
                }
+               
+               glStencilFunc(GL_NOTEQUAL, 0x01, 0x01);
+               glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+
+               // Something gets screwed up due to the changes above
+               // revert to default.
+               glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+               glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+               glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+               glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
        }
-       
-       glStencilFunc(GL_NOTEQUAL, 0x01, 0x01);
-       glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
-
-       // Something gets screwed up due to the changes above
-       // revert to default.
-       glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-       glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-       glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
-       glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
 
        game.InitGame();