From: Vadim Trochinsky Date: Sun, 16 May 2010 12:56:33 +0000 (+0400) Subject: Merged with parent X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=44e4a5263469eb8e216bd6abfad3f0b5e2627d69;hp=-c;p=lugaru.git Merged with parent --- 44e4a5263469eb8e216bd6abfad3f0b5e2627d69 diff --combined Source/OpenGL_Windows.cpp index b862fc2,3752028..f118ce7 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@@ -120,10 -120,9 +120,9 @@@ extern float volume #ifdef WIN32 #include + #include "win-res/resource.h" #endif - #include "res/resource.h" - using namespace std; @@@ -321,12 -320,7 +320,12 @@@ void ShutdownDSp ( void DrawGL (Game & game) { - game.DrawGLScene(); + if ( stereomode == stereoNone ) { + game.DrawGLScene(stereoCenter); + } else { + game.DrawGLScene(stereoLeft); + game.DrawGLScene(stereoRight); + } } @@@ -929,8 -923,7 +928,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()); @@@ -979,6 -972,7 +978,6 @@@ 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); @@@ -1020,56 -1014,6 +1019,56 @@@ game.newscreenwidth=screenwidth; game.newscreenheight=screenheight; + GLint stencilbits = 0; + glGetIntegerv(GL_STENCIL_BITS, &stencilbits); + if ( stencilbits < 1 ) { + fprintf(stderr, "Failed to get a stencil buffer!\n"); + SDL_Quit(); + 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