6 extern int kContextWidth;
7 extern int kContextHeight;
9 bool CanInitStereo(StereoMode mode) {
10 GLint stencilbits = 0;
19 case stereoHorizontalInterlaced:
20 case stereoVerticalInterlaced:
21 glGetIntegerv(GL_STENCIL_BITS, &stencilbits);
22 if ( stencilbits < 1 ) {
23 fprintf(stderr, "Failed to get a stencil buffer, interlaced stereo not available.\n");
26 fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits);
35 void InitStereo(StereoMode mode) {
41 case stereoHorizontalInterlaced:
42 case stereoVerticalInterlaced:
44 fprintf(stderr, "Screen width is %i, height is %i\n", kContextWidth, kContextHeight);
46 glEnable( GL_STENCIL_TEST);
48 glClear( GL_STENCIL_BUFFER_BIT );
49 glStencilFunc(GL_ALWAYS, 0x1, 0x1);
50 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
53 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
54 glPixelStorei(GL_UNPACK_ROW_LENGTH, 3);
55 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
56 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
57 glColorMask( 1.0, 1.0, 1.0, 1.0 );
58 char stencil[] = {64,127,255};
60 glViewport(0,0, kContextWidth, kContextHeight);
61 glMatrixMode(GL_PROJECTION);
63 glOrtho((GLdouble)0, (GLdouble)kContextWidth, (GLdouble)kContextHeight, 0, -1, 1);
64 glMatrixMode(GL_MODELVIEW);
67 for(int y=0;y<kContextHeight;y+=2) {
69 for(int x=0;x<kContextWidth;x++) {
71 glDrawPixels(1, 1, GL_RGB, GL_UNSIGNED_BYTE, &stencil);
75 glStencilFunc(GL_NOTEQUAL, 0x01, 0x01);
76 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
78 // Something gets screwed up due to the changes above
80 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
81 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
82 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
83 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);