]> git.jsancho.org Git - lugaru.git/blobdiff - Source/OpenGL_Windows.cpp
Moved stereo initialization code to a separate file.
[lugaru.git] / Source / OpenGL_Windows.cpp
index f8f180c6aa38b3c7a8f7ce889355f12250869b69..d4251fca6af1c3a8089ec13a33b9f1e6e5509c4a 100644 (file)
@@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
+
 #ifdef WIN32
 #define UINT8 WIN32API_UINT8
 #define UINT16 WIN32API_UINT16
@@ -35,7 +36,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 extern "C" {
        #include "zlib.h"
        #include "png.h"
-       #include "jpeglib.h"
+   #ifdef WIN32
+               #define INT32 INT32_jpeg
+               #include "jpeglib.h"
+               #undef INT32
+       #else
+               #include "jpeglib.h"
+       #endif
 }
 
 static bool load_image(const char * fname, TGAImageRec & tex);
@@ -110,12 +117,12 @@ extern float volume;
 #include "gamegl.h"
 #include "MacCompatibility.h"
 
+
 #ifdef WIN32
 #include <shellapi.h>
+#include "win-res/resource.h"
 #endif
 
-#include "res/resource.h"
-
 using namespace std;
 
 
@@ -313,7 +320,12 @@ void ShutdownDSp ()
 
 void DrawGL (Game & game)
 {
-       game.DrawGLScene();
+       if ( stereomode == stereoNone ) {
+               game.DrawGLScene(stereoCenter);
+       } else {
+               game.DrawGLScene(stereoLeft);
+               game.DrawGLScene(stereoRight);
+       }
 }
 
 
@@ -691,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){
@@ -837,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;
@@ -916,7 +946,8 @@ Boolean SetUp (Game & game)
     SDL_ShowCursor(0);
 
     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
+    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
+    
     if (SDL_SetVideoMode(kContextWidth, kContextHeight, 0, sdlflags) == NULL)
     {
         fprintf(stderr, "SDL_SetVideoMode() failed: %s\n", SDL_GetError());
@@ -965,7 +996,6 @@ Boolean SetUp (Game & game)
        glDisable( GL_FOG);
        glDisable( GL_LIGHTING);
        glDisable( GL_LOGIC_OP);
-       glDisable( GL_STENCIL_TEST);
        glDisable( GL_TEXTURE_1D);
        glDisable( GL_TEXTURE_2D);
        glPixelTransferi( GL_MAP_COLOR, GL_FALSE);
@@ -1007,6 +1037,13 @@ Boolean SetUp (Game & game)
        game.newscreenwidth=screenwidth;
        game.newscreenheight=screenheight;
 
+       if ( CanInitStereo(stereomode) ) {
+               InitStereo(stereomode);
+       } else {
+               fprintf(stderr, "Failed to initialize stereo, disabling.\n");
+               stereomode = stereoNone;
+       }
+
        game.InitGame();
 
        return true;
@@ -1499,6 +1536,7 @@ int main(int argc, char **argv)
                }
        }
 
+
        bool LoadImage(const char * fname, TGAImageRec & tex)
        {
                bool res = true;