From 281207f066058c990b4060f50f3029fbddaf8166 Mon Sep 17 00:00:00 2001 From: Vadim Trochinsky Date: Fri, 21 May 2010 23:23:07 +0200 Subject: [PATCH] Add config screen --- Source/GameDraw.cpp | 52 ++++++++++++++++++++++++++++++++++++---- Source/GameTick.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++- Source/Globals.cpp | 1 + Source/Stereo.cpp | 18 +++++++++++++- Source/Stereo.h | 2 ++ 5 files changed, 125 insertions(+), 6 deletions(-) diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 3e07606..0e153a9 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -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;istartx[i]&&(mousecoordh/screenwidth*640)starty[i]&&480-(mousecoordv/screenheight*480)0) { + //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay); if(flashamount>1)flashamount=1; if(flashdelay<=0)flashamount-=multiplier; flashdelay--; diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 8010f4f..c0d6e91 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -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)){ diff --git a/Source/Globals.cpp b/Source/Globals.cpp index b360ce0..01d8839 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -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 diff --git a/Source/Stereo.cpp b/Source/Stereo.cpp index 815e177..5c8be16 100644 --- a/Source/Stereo.cpp +++ b/Source/Stereo.cpp @@ -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 diff --git a/Source/Stereo.h b/Source/Stereo.h index c0de10f..f5d86c1 100644 --- a/Source/Stereo.h +++ b/Source/Stereo.h @@ -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 -- 2.39.5