]> git.jsancho.org Git - lugaru.git/commitdiff
Add config screen
authorVadim Trochinsky <vadim.trochinsky@gmail.com>
Fri, 21 May 2010 21:23:07 +0000 (23:23 +0200)
committerVadim Trochinsky <vadim.trochinsky@gmail.com>
Fri, 21 May 2010 21:23:07 +0000 (23:23 +0200)
Source/GameDraw.cpp
Source/GameTick.cpp
Source/Globals.cpp
Source/Stereo.cpp
Source/Stereo.h

index 3e076067f232acdf3e68ed03e0bc61688ffb0e3a..0e153a9420bfd6c07be9c524e868c9dc27d6623f 100644 (file)
@@ -2372,7 +2372,7 @@ int Game::DrawGLScene(StereoSide side)
 
                /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
 
-               if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==13||mainmenu==17){
+               if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==13||mainmenu==17||mainmenu==18){
                        glClear(GL_DEPTH_BUFFER_BIT);
                        glEnable(GL_ALPHA_TEST);
                        glAlphaFunc(GL_GREATER, 0.001f);
@@ -2436,7 +2436,7 @@ int Game::DrawGLScene(StereoSide side)
                        glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
 
                        if(mainmenu==3){                        
-                               nummenuitems=12;
+                               nummenuitems=13;
                                if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
                                else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
                                startx[0]=10+20;
@@ -2536,6 +2536,14 @@ int Game::DrawGLScene(StereoSide side)
                                movex[7]=0;
                                movey[7]=0;
 
+                               sprintf (menustring[12], "-Configure Stereo -");
+                               startx[12]=10+15;
+                               starty[12]=60;
+                               endx[12]=startx[12]+strlen(menustring[7])*10;
+                               endy[12]=starty[12]+20;
+                               movex[12]=0;
+                               movey[12]=0;
+                               
                                if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
                                else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
                                startx[8]=10;
@@ -3070,6 +3078,40 @@ int Game::DrawGLScene(StereoSide side)
                                movex[7]=0;
                                movey[7]=0;*/
                        }
+                       if (mainmenu==18) {
+                               nummenuitems=4;
+                               sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
+                               startx[0]=70;
+                               starty[0]=400;
+                               endx[0]=startx[0]+strlen(menustring[0])*10;
+                               endy[0]=starty[0]+20;
+                               movex[0]=0;
+                               movey[0]=0;
+                               
+                               sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
+                               startx[1]=10;
+                               starty[1]=360;
+                               endx[1]=startx[1]+strlen(menustring[1])*10;
+                               endy[1]=starty[1]+20;
+                               movex[1]=0;
+                               movey[1]=0;
+
+                               sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
+                               startx[2]=40;
+                               starty[2]=320;
+                               endx[2]=startx[2]+strlen(menustring[2])*10;
+                               endy[2]=starty[2]+20;
+                               movex[2]=0;
+                               movey[2]=0;
+                               
+                               sprintf (menustring[3], "Back");
+                               startx[3]=10;
+                               endx[3]=startx[3]+strlen(menustring[3])*10;
+                               starty[3]=10;
+                               endy[3]=starty[3]+20;
+                               movex[3]=0;
+                               movey[3]=0;                             
+                       }
                }
 
                if(mainmenu==13){       
@@ -3259,7 +3301,7 @@ int Game::DrawGLScene(StereoSide side)
                                }
                        }
 
-                       if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17)
+                       if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
                                for(i=0;i<nummenuitems;i++){
                                        if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
                                                if(mainmenu!=5)selected=i;
@@ -3452,7 +3494,7 @@ int Game::DrawGLScene(StereoSide side)
                                                                                        }
                                                                                }
                                                                        }
-                                                                       if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17)
+                                                                       if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
                                                                        {
                                                                                if(mainmenu!=5||j<6)
                                                                                {
@@ -3505,6 +3547,7 @@ int Game::DrawGLScene(StereoSide side)
                                                                                                        if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==17)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==13&&j!=1)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+                                                                                                       if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        /*else{
                                                                                                        if(displayblink){
                                                                                                        sprintf (string, "_");
@@ -3764,6 +3807,7 @@ int Game::DrawGLScene(StereoSide side)
 
                                                                if(flashamount>0)
                                                                {
+                                                                       //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
                                                                        if(flashamount>1)flashamount=1;
                                                                        if(flashdelay<=0)flashamount-=multiplier;
                                                                        flashdelay--;
index 8010f4f265d014dec90a00ff7afec107f47f575c..c0d6e9114dccb43ecb0f971c485dc1bd697d2562 100644 (file)
@@ -3087,6 +3087,17 @@ void     Game::Tick()
                                mainmenu=4;
                                keyselect=-1;
                        }
+                       if(Button() && !oldbutton && selected == 12) {
+                               flashr=1;
+                               flashg=0;
+                               flashb=0;
+                               flashamount=1;
+                               flashdelay=1;
+                               
+                               newstereomode = stereomode;
+                               mainmenu=18;
+                               keyselect = -1;
+                       }
                        if(Button()&&!oldbutton&&selected==8){
                                float gLoc[3]={0,0,0};
                                float vel[3]={0,0,0};
@@ -3649,9 +3660,54 @@ void     Game::Tick()
                        if(Button())oldbutton=1;
                        else oldbutton=0;
                }
+               if (mainmenu==18) {
+                       if(Button()&&!oldbutton) {
+                               printf("Button %i pressed\n", selected);
+                       }
+                       
+                       if(Button()&&!oldbutton&&selected==0) {
+                               newstereomode = (StereoMode)(newstereomode + 1);
+                               while(!CanInitStereo(newstereomode)) {
+                                       printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode), newstereomode);
+                                       newstereomode = (StereoMode)(newstereomode + 1);
+                                       if ( newstereomode >= stereoCount ) {
+                                               newstereomode = stereoNone;
+                                       }
+                               }
+                       }
+                       
+                       if(buttons[0]&&!oldbutton&&selected==1) {
+                               stereoseparation+=0.001;
+                       }
+                       if(buttons[1]&&!oldbutton&&selected==1) {
+                               stereoseparation-=0.001;
+                       }
+
+                       if(Button()&&!oldbutton&&selected==2) {
+                               stereoreverse =! stereoreverse;
+                       }
+                       
+                       if(Button()&&!oldbutton&&selected==3) {
+                               flashr=1;
+                               flashg=0;
+                               flashb=0;
+                               flashamount=1;
+                               flashdelay=1;
+
+                               if ( stereomode != newstereomode ) {
+                                       stereomode = newstereomode;
+                                       InitStereo(stereomode);
+                               }
+                               
+                               mainmenu=3;
+                       }
+                       
+                       if(Button() || buttons[1])oldbutton=1;
+                       else oldbutton=0;
+               }
 
 
-               if(Button())oldbutton=1;
+               if(Button()||buttons[1])oldbutton=1;
                else oldbutton=0;
 
                if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
index b360ce055c9ed75e55ec4f947b22bbbd40fbd09f..01d883915679b2c3cd23bee90779b715367bbde7 100644 (file)
@@ -269,5 +269,6 @@ bool gamestarted = 0;
 //TextureList textures;
 
 StereoMode stereomode =  stereoNone;
+StereoMode newstereomode = stereoNone;
 float stereoseparation = 0.05;
 bool  stereoreverse = false;
\ No newline at end of file
index 815e177952f27ac8fcbe20baed3d66ec8f25bd44..5c8be16dd298e68525f8e52b679ea470e57b639d 100644 (file)
@@ -25,7 +25,8 @@ bool CanInitStereo(StereoMode mode) {
                        } else {
                                fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits);
                        }
-                       
+                       return true;
+                       break;
                default:
                        return false;
        }
@@ -35,8 +36,10 @@ bool CanInitStereo(StereoMode mode) {
 void InitStereo(StereoMode mode) {
        switch(mode) {
                case stereoNone:
+                       glDisable( GL_STENCIL_TEST);
                        return;
                case stereoAnaglyph:
+                       glDisable( GL_STENCIL_TEST);
                        return;
                case stereoHorizontalInterlaced:
                case stereoVerticalInterlaced:
@@ -83,4 +86,17 @@ void InitStereo(StereoMode mode) {
                        glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
        }
        
+}
+
+const char* StereoModeName(StereoMode mode) {
+       switch(mode) {
+               case stereoNone:                 return "None"; break;
+               case stereoAnaglyph:             return "Anaglyph"; break;
+               case stereoHorizontalInterlaced: return "Horizontal interlacing"; break;
+               case stereoVerticalInterlaced:   return "Vertical interlacing"; break;
+               case stereoHorizontalSplit:      return "Horizontal split"; break;
+               case stereoVerticalSplit:        return "Vertical split"; break;
+               case stereoOpenGL:               return "OpenGL"; break;
+               default:                         return "(error)"; break; 
+       }
 }
\ No newline at end of file
index c0de10f9ac3ebbff224d04b45d4ad9a2fd029eb5..f5d86c1a34a7850a81bb93df5e233accffcf21bb 100644 (file)
@@ -22,10 +22,12 @@ enum StereoSide {
 };
 
 extern StereoMode stereomode;
+extern StereoMode newstereomode;
 extern float stereoseparation;
 extern bool  stereoreverse;
 
 bool CanInitStereo(StereoMode mode);
 void InitStereo(StereoMode mode);
+const char* StereoModeName(StereoMode mode);
 
 #endif
\ No newline at end of file