X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FStereo.cpp;h=8887a526c6b5faec3330f6a286e61ac4d4b6eb34;hb=c5dc3750efbc615b70917f19bb95cbd352cd00f6;hp=5c8be16dd298e68525f8e52b679ea470e57b639d;hpb=5c4dee6a92fa23796ada28e5e42dee7721230d3e;p=lugaru.git diff --git a/Source/Stereo.cpp b/Source/Stereo.cpp index 5c8be16..8887a52 100644 --- a/Source/Stereo.cpp +++ b/Source/Stereo.cpp @@ -1,3 +1,22 @@ +/* +Copyright (C) 2003, 2010 - Wolfire Games +Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) + +This file is part of Lugaru. + +Lugaru is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +Lugaru is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Lugaru. If not, see . +*/ #include "Game.h" #include "Stereo.h" @@ -6,97 +25,128 @@ extern int kContextWidth; extern int kContextHeight; -bool CanInitStereo(StereoMode mode) { - GLint stencilbits = 0; - - switch(mode) { - case stereoNone: - return true; - break; - case stereoAnaglyph: - return true; - break; - case stereoHorizontalInterlaced: - case stereoVerticalInterlaced: - glGetIntegerv(GL_STENCIL_BITS, &stencilbits); - if ( stencilbits < 1 ) { - fprintf(stderr, "Failed to get a stencil buffer, interlaced stereo not available.\n"); - return false; - } else { - fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits); - } - return true; - break; - default: - return false; - } +bool CanInitStereo(StereoMode mode) +{ + GLint stencilbits = 0; + + switch (mode) { + case stereoNone: + case stereoAnaglyph: + return true; + break; + case stereoHorizontalInterlaced: + case stereoVerticalInterlaced: + glGetIntegerv(GL_STENCIL_BITS, &stencilbits); + if ( stencilbits < 1 ) { + fprintf(stderr, "Failed to get a stencil buffer, interlaced stereo not available.\n"); + return false; + } else { + fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits); + } + return true; + break; + default: + return false; + } } -void InitStereo(StereoMode mode) { - switch(mode) { - case stereoNone: - glDisable( GL_STENCIL_TEST); - return; - case stereoAnaglyph: - glDisable( GL_STENCIL_TEST); - return; - case stereoHorizontalInterlaced: - case stereoVerticalInterlaced: - - 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