Index: tr_backend.c =================================================================== --- tr_backend.c (revision 2260) +++ tr_backend.c (working copy) @@ -509,7 +509,44 @@ } } +void +interlace_stencil(int gliWindowWidth, int gliWindowHeight) +{ + GLint gliY; + // seting screen-corresponding geometry + qglViewport(0,0,gliWindowWidth,gliWindowHeight); + qglMatrixMode(GL_MODELVIEW); + qglLoadIdentity(); + qglMatrixMode (GL_PROJECTION); + qglLoadIdentity(); + qglOrtho(0.0,gliWindowWidth-1,0.0,gliWindowHeight-1,-1,1); + qglMatrixMode(GL_MODELVIEW); + qglLoadIdentity(); + + // clearing and configuring stencil drawing + qglDrawBuffer(GL_BACK); + qglEnable(GL_STENCIL_TEST); + qglClearStencil(0); + qglClear(GL_STENCIL_BUFFER_BIT); + qglStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE); // colorbuffer is copied to stencil + qglDisable(GL_DEPTH_TEST); + qglStencilFunc(GL_ALWAYS,1,1); // to avoid interaction with stencil content + + // drawing stencil pattern + //qglColor4f(1,1,1,0); // alfa is 0 not to interfere with alpha tests + for (gliY=0; gliYinteger == 2) + interlace_stencil(glConfig.vidWidth, glConfig.vidHeight); + #if 0 RB_DrawSun(); #endif @@ -961,9 +1001,17 @@ const drawBufferCommand_t *cmd; cmd = (const drawBufferCommand_t *)data; + + if (r_stereoEnabled->integer == 2) { + qglDrawBuffer( GL_BACK ); + if (cmd->buffer == GL_BACK_LEFT) + glStencilFunc(GL_NOTEQUAL,1,1); + else + glStencilFunc(GL_EQUAL,1,1); + } + else + qglDrawBuffer( cmd->buffer ); - qglDrawBuffer( cmd->buffer ); - // clear screen for debugging if ( r_clear->integer ) { qglClearColor( 1, 0, 0.5, 1 );