can anyone please explain to me how to do state managment in OpenGL? if you can please contact me on AIM or e-mail.
AIM: Seanrru123
E-mail: [email protected]
Printable View
can anyone please explain to me how to do state managment in OpenGL? if you can please contact me on AIM or e-mail.
AIM: Seanrru123
E-mail: [email protected]
Or even better, contact me. AIM: Gamer Tazar... I am the one hes asking this for. For more information on what he means:
In a game in OpenGL, how would you make it go from the Title Screen in the beginning, to the menu. Then to the actual game when they select it. And when they get past the first level, load the second. Does anyone have any code that i could see?
Thanks.
It shouldn't matter what graphics library you use. This will work with any game code, regardless of graphics library, OS, platform, etc.
Enumerate 2 variables to hold Major Game states and Minor Game states. In your main game loop use a switch to test for the major states, then a sub switch to test for the minor states (I actually only test for the major states in my main game loop, then calls a function (seperate function for each major state) that has a switch that checks for minor game states).
Here's a generic example:
Code://global declares
enum GameState
{gsIntro,gsMenu,gsSettings,gsCombat,gsOptions};
enum SubState
{ss1,ss2,ss3,ss4,ss5,ss6};
GameState MajorState;
SubState MinorState;
//main game loop
void GameLoop()
{
switch(MajorState)
{
case gsIntro:
{
GetIntroInput();
DoIntroBlt();
}break;
case gsMenu:
{
GetMenuInput();
DoMenuBlt();
}break;
case etc. etc. etc.....do the same
}
}
//sample generic minor state check function
void GetMenuInput()
{
switch(MinorState)
{
case ss1:
{
//get mouse/keyboard input for main menu buttons
}break;
case ss2:
{
//get mouse/keyboard input for options menu buttons
}break;
case etc. etc. etc.....
}
}
A state machine is a language independent concept. Read more about state machines here:
http://www.redbrick.dcu.ie/academic/...ter08.doc.html