Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

ExManagerWindow Class Reference

#include <ExManagerWindow.h>

Inheritance diagram for ExManagerWindow:

ExManager

Public Methods

void CreateNewWindow (int SizeX, int SizeY, int PosX, int PosY, char *argv)
void CreateNewWindow (int SizeX, int SizeY, char *argv)
void Move (int Posx, int Posy)
void SetResolution (int SizeX, int SizeY)
void SetRate (int Rate)
void SetBits (int Bits)
void SetFullScreen (bool State)
void SetWindowTitle (char *Title)
void SetIconTitle (char *Title)
void SetCursor (int Cursor)
void Apply (void)
int GetResolutionX (void)
int GetResolutionY (void)
int GetRate (void)
int GetBits (void)
bool GetFullScreen (void)
void SetGrilleState (bool state)
bool GetGrilleState (void)
void SetFpsState (bool state)
bool GetFpsState (void)
void ShowFps (void)
void ShowNetStat (void)
void Reset (void)
ExCAction InputCommand (ExCCommand Command)
ExCAction InputAction (ExCAction Action)

Static Public Methods

ExManagerWindow * CreateSingleton (void)

Data Fields

void(* GlutCallBack )()

Private Methods

 ExManagerWindow (void)
 ~ExManagerWindow (void)

Private Attributes

ExCOptionsoptions
int m_WindowHandler
int m_WindowSizeX
int m_WindowSizeY
int m_WindowSizeXOld
int m_WindowSizeYOld
int m_WindowPosX
int m_WindowPosY
int m_Bits
int m_Rate
bool m_FullScreen
bool m_OldMode
char * m_Title
char * m_IconTitle
int m_Cursor
bool m_ShowGrille
bool m_ShowFps
int frame
int timeframe
int timebase
char s [30]

Static Private Attributes

bool m_flag = false
ExManagerWindow * m_instance = NULL

Constructor & Destructor Documentation

ExManagerWindow void    [private]
 

Definition at line 29 of file ExManagerWindow.cpp.

References ExManagerWindow(), Guard, m_Bits, m_Cursor, m_FullScreen, m_IconTitle, m_OldMode, m_Rate, m_ShowFps, m_ShowGrille, m_Title, m_WindowPosX, m_WindowPosY, m_WindowSizeX, m_WindowSizeXOld, m_WindowSizeY, m_WindowSizeYOld, and VERSION.

Referenced by ExManagerWindow(), and ~ExManagerWindow().

00029                                     {
00030 Guard(ExManagerWindow::ExManagerWindow(void))
00031         m_ShowGrille=false;
00032 
00033 //      m_Antialliasing=true;
00034         
00035         /*
00036         options = new ExCOptions;
00037         
00038         m_ShowFps = options->getWindowShowfps ();
00039         
00040         m_WindowSizeX = options->getWindowResolutionX ();
00041         m_WindowSizeY = options->getWindowResolutionY ();
00042                 m_Bits = options->getWindowDepth ();
00043         m_Rate = options->getWindowRate ();
00044         m_FullScreen = options->getWindowFullscreen () ;
00045         */
00046         m_ShowFps = true;
00047         m_WindowSizeX = 800;
00048         m_WindowSizeY = 600;
00049         m_WindowSizeXOld = m_WindowSizeX;
00050         m_WindowSizeYOld = m_WindowSizeY;
00051         m_WindowPosX=0;
00052         m_WindowPosY=0;
00053         m_Bits = 16;
00054         m_Rate = 75;
00055         m_FullScreen = true ;
00056         m_OldMode=m_FullScreen;
00057         m_Cursor=GLUT_CURSOR_CROSSHAIR;
00058         
00059         m_Title=new char[strlen("ExNihilo Engine Version ")+20];
00060         sprintf(m_Title,"ExNihilo Engine Version %s",VERSION);
00061         
00062         m_IconTitle=new char[strlen("ExNihilo Engine Version ")+20];
00063         sprintf(m_IconTitle,"ExNihilo Engine Version %s",VERSION);
00064 
00065 UnGuard
00066 }

~ExManagerWindow void    [private]
 

Definition at line 68 of file ExManagerWindow.cpp.

References ExManagerWindow(), Guard, and m_flag.

00069 {
00070 Guard(ExManagerWindow::~ExManagerWindow(void))
00071         m_flag=false;
00072 UnGuard
00073 }


Member Function Documentation

void Apply void   
 

Definition at line 160 of file ExManagerWindow.cpp.

References Apply(), GlutCallBack, Guard, m_Bits, m_Rate, m_Title, m_WindowHandler, m_WindowPosX, m_WindowPosY, m_WindowSizeX, and m_WindowSizeY.

Referenced by Apply(), InitManager(), and InputAction().

00160                                {
00161 Guard(ExManagerWindow::Apply(void))
00162         if(m_FullScreen)
00163         {
00164                 char *game;
00165                 game=new char[15];
00166                 sprintf(game,"%dx%d:%d@%d",m_WindowSizeX,m_WindowSizeY,m_Bits,m_Rate);
00167                 if(m_OldMode)
00168                 {
00169                         glutDestroyWindow(m_WindowHandler);
00170                 }
00171 
00172                 glutGameModeString(game);
00173 
00174                 if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE)) 
00175                 {
00176                         m_WindowHandler=glutEnterGameMode();
00177                         GlutCallBack();
00178                         glutSetWindow(m_WindowHandler);
00179 
00180                 }else 
00181                 {
00182                         std::cout << "Can not switch to fullscreen  error with your graphic card or glut lib " << std::endl;
00183                 }
00184         }else
00185         {
00186                 if(m_OldMode)
00187                 {
00188                         glutLeaveGameMode();
00189                         glutInitWindowPosition(m_WindowPosX,m_WindowPosY);
00190                         glutInitWindowSize(m_WindowSizeX,m_WindowSizeY);                
00191                         m_WindowHandler=glutCreateWindow(m_Title);
00192                 }else
00193                 {
00194                         glutReshapeWindow(m_WindowSizeX,m_WindowSizeY);
00195                 }
00196         }
00197 UnGuard
00198 }

void CreateNewWindow int    SizeX,
int    SizeY,
char *    argv
 

Definition at line 105 of file ExManagerWindow.cpp.

References CreateNewWindow(), Guard, m_Cursor, m_IconTitle, m_Title, m_WindowHandler, m_WindowPosX, m_WindowPosY, m_WindowSizeX, m_WindowSizeXOld, m_WindowSizeY, m_WindowSizeYOld, and SetCursor().

00105                                                                    {
00106 Guard(ExManagerWindow::CreateNewWindow(int SizeX,int SizeY,char *argv))
00107         m_WindowSizeX=SizeX;
00108         m_WindowSizeY=SizeY;
00109         m_WindowSizeXOld=SizeX;
00110         m_WindowSizeYOld=SizeY;
00111         glutInitWindowPosition(m_WindowPosX,m_WindowPosY);
00112         glutInitWindowSize(m_WindowSizeX,m_WindowSizeY);                
00113         m_WindowHandler=glutCreateWindow(m_Title);
00114         glutSetIconTitle(m_IconTitle);
00115         SetCursor(m_Cursor);
00116 UnGuard
00117 }

void CreateNewWindow int    SizeX,
int    SizeY,
int    PosX,
int    PosY,
char *    argv
 

Definition at line 89 of file ExManagerWindow.cpp.

References CreateNewWindow(), Guard, m_Cursor, m_IconTitle, m_Title, m_WindowHandler, m_WindowPosX, m_WindowPosY, m_WindowSizeX, m_WindowSizeXOld, m_WindowSizeY, m_WindowSizeYOld, and SetCursor().

Referenced by CreateNewWindow(), and main().

00089                                                                                      {
00090 Guard(ExManagerWindow::CreateNewWindow(int SizeX,int SizeY,int PosX,int PosY,char *argv))
00091         m_WindowSizeX=SizeX;
00092         m_WindowSizeY=SizeY;
00093         m_WindowSizeXOld=SizeX;
00094         m_WindowSizeYOld=SizeY;
00095         m_WindowPosX=PosX;
00096         m_WindowPosY=PosY;
00097         glutInitWindowPosition(m_WindowPosX,m_WindowPosY);
00098         glutInitWindowSize(m_WindowSizeX,m_WindowSizeY);                
00099         m_WindowHandler=glutCreateWindow(m_Title);
00100         glutSetIconTitle(m_IconTitle);
00101         SetCursor(m_Cursor);
00102 UnGuard
00103 }

ExManagerWindow * CreateSingleton void    [static]
 

Definition at line 75 of file ExManagerWindow.cpp.

References CreateSingleton(), Guard, m_flag, and m_instance.

Referenced by CreateSingleton(), and main().

00075                                                      {
00076 Guard(ExManagerWindow* ExManagerWindow::CreateSingleton(void))
00077         if(!m_flag)
00078         {
00079                 m_flag = true; // We are creating the error log now, so set flag to true
00080                 m_instance = new ExManagerWindow; // Create the error log
00081         }else
00082         {
00083                 std::cout<<"Error singleton already created"<<std::endl;
00084         }
00085         return m_instance; 
00086 UnGuard
00087 }

int GetBits void    [inline]
 

Definition at line 92 of file ExManagerWindow.h.

References m_Rate.

00092 {return m_Rate;}

bool GetFpsState void    [inline]
 

Definition at line 99 of file ExManagerWindow.h.

References m_ShowFps.

Referenced by ExManagerOutput::DrawScene().

00099 {m_ShowFps=state;}

bool GetFullScreen void    [inline]
 

Definition at line 93 of file ExManagerWindow.h.

References m_Bits.

00093 {return m_Bits;}

bool GetGrilleState void    [inline]
 

Definition at line 97 of file ExManagerWindow.h.

References m_ShowGrille.

Referenced by ExManagerOutput::DrawScene(), and InputAction().

00097 {m_ShowGrille=state;}

int GetRate void    [inline]
 

Definition at line 91 of file ExManagerWindow.h.

References m_WindowSizeY.

00091 {return m_WindowSizeY;}

int GetResolutionX void    [inline]
 

Definition at line 89 of file ExManagerWindow.h.

Referenced by ExManagerConsole::Draw(), ExCInterface::InputCommand(), and ExManagerOutput::Reshape().

00090 {return m_WindowSizeX;}

int GetResolutionY void    [inline]
 

Definition at line 90 of file ExManagerWindow.h.

References m_WindowSizeX.

Referenced by ExManagerConsole::Draw(), ExCInterface::InputCommand(), and ExManagerOutput::Reshape().

00090 {return m_WindowSizeX;}

ExCAction InputAction ExCAction    Action [virtual]
 

Reimplemented from ExManager.

Definition at line 228 of file ExManagerWindow.cpp.

References Apply(), GetGrilleState(), Guard, InputAction(), ExCAction::m_Action, SET_POLYGONMODE_FILL, SET_POLYGONMODE_LINES, SET_POLYGONMODE_POINTS, SetBits(), SetFpsState(), SetFullScreen(), SetGrilleState(), and SetResolution().

Referenced by InputAction(), and ExManagerCommand::ProcesExCAction().

00229 {
00230 Guard(ExManagerWindow::InputAction(ExCAction Action))
00231         switch(Action.m_Action)
00232         {
00233         case SET_RESOLUTION_800_600_16:
00234                 SetResolution(800,600);
00235                 SetBits(16);
00236                 SetFullScreen(true);
00237                 Apply();
00238                 break;
00239         
00240         case SET_RESOLUTION_800_600_24:
00241                 SetResolution(800,600);
00242                 SetBits(24);
00243                 SetFullScreen(true);
00244                 Apply();
00245                 break;
00246 
00247         case SET_RESOLUTION_800_600_32:
00248                 SetResolution(800,600);
00249                 SetBits(32);
00250                 SetFullScreen(true);
00251                 Apply();
00252                 break;
00253 
00254         case SET_RESOLUTION_1024_768_16:
00255                 SetResolution(1024,768);
00256                 SetBits(16);
00257                 SetFullScreen(true);
00258                 Apply();
00259                 break;
00260         
00261         case SET_RESOLUTION_1024_768_24:
00262                 SetResolution(1024,768);
00263                 SetBits(24);
00264                 SetFullScreen(true);
00265                 Apply();
00266                 break;
00267         
00268         case SET_RESOLUTION_1024_768_32:
00269                 SetResolution(1024,768);
00270                 SetBits(32);
00271                 SetFullScreen(true);
00272                 Apply();
00273                 break;
00274         
00275         case SET_RESOLUTION_1600_1200_16:
00276                 SetResolution(1600,1200);
00277                 SetBits(16);
00278                 SetFullScreen(true);
00279                 Apply();
00280                 break;
00281         
00282         case SET_RESOLUTION_1600_1200_24:
00283                 SetResolution(1600,1200);
00284                 SetBits(24);
00285                 SetFullScreen(true);
00286                 Apply();
00287                 break;
00288         
00289         case SET_RESOLUTION_1600_1200_32:
00290                 SetResolution(1600,1200);
00291                 SetBits(32);
00292                 SetFullScreen(true);
00293                 Apply();
00294                 break;
00295         
00296         case SHOW_FPS_STAT:
00297                 SetFpsState(true);
00298                 break;
00299 
00300         case HIDE_FPS_STAT:
00301                 SetFpsState(false);
00302                 break;
00303 
00304         case ENABLE_GRIDE:
00305                 SetGrilleState(true);
00306                 break;
00307 
00308         case DISABLE_GRIDE:
00309                 SetGrilleState(false);
00310                 break;
00311 
00312         case SWITCH_GRIDE:
00313                 if(GetGrilleState())
00314                 {
00315                         InputAction(DISABLE_GRIDE);     
00316                 }else
00317                 {
00318                         InputAction(ENABLE_GRIDE);
00319                 }
00320                 break;
00321         case SET_POLYGONMODE_POINTS:
00322                 glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
00323                 break;
00324 
00325         case SET_POLYGONMODE_LINES:
00326                 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
00327                 break;
00328 
00329         case SET_POLYGONMODE_FILL:
00330                 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
00331                 break;
00332 
00333         default: return NOTHING;
00334         }
00335         return  NOTHING;
00336 UnGuard
00337 }

ExCAction InputCommand ExCCommand    Command [virtual]
 

Reimplemented from ExManager.

Definition at line 221 of file ExManagerWindow.cpp.

References Guard, and InputCommand().

Referenced by InputCommand().

00222 {
00223 Guard(ExManagerWindow::InputCommand(ExCCommand Command))
00224         return  NOTHING;
00225 UnGuard
00226 }

void Move int    Posx,
int    Posy
 

Definition at line 119 of file ExManagerWindow.cpp.

References Guard, m_WindowPosX, m_WindowPosY, and Move().

Referenced by Move().

00119                                            {
00120 Guard(ExManagerWindow::Move(int Posx,int Posy))
00121         m_WindowPosX=Posx;
00122         m_WindowPosY=Posy;
00123         glutPositionWindow(Posx,Posy);
00124 UnGuard
00125 }

void Reset void    [inline, virtual]
 

Reimplemented from ExManager.

Definition at line 104 of file ExManagerWindow.h.

00105 {return;}

void SetBits int    Bits [inline]
 

Definition at line 82 of file ExManagerWindow.h.

References m_Rate.

Referenced by InputAction().

00082 {m_Rate=Rate;}

void SetCursor int    Cursor
 

Definition at line 153 of file ExManagerWindow.cpp.

References Guard, and SetCursor().

Referenced by CreateNewWindow(), and SetCursor().

00153                                          {
00154 Guard(ExManagerWindow::SetCursor(int Cursor))
00155         glutSetCursor(Cursor);
00156 UnGuard
00157 }

void SetFpsState bool    state [inline]
 

Definition at line 98 of file ExManagerWindow.h.

References m_ShowGrille.

Referenced by InputAction().

00098 {return m_ShowGrille;}

void SetFullScreen bool    State [inline]
 

Definition at line 83 of file ExManagerWindow.h.

References m_Bits.

Referenced by InputAction(), and main().

00083 {m_Bits=Bits;}

void SetGrilleState bool    state [inline]
 

Definition at line 96 of file ExManagerWindow.h.

Referenced by InputAction().

00097 {m_ShowGrille=state;}

void SetIconTitle char *    Title
 

Definition at line 145 of file ExManagerWindow.cpp.

References Guard, m_IconTitle, and SetIconTitle().

Referenced by SetIconTitle().

00145                                              {
00146 Guard(ExManagerWindow::SetIconTitle(char *Title))
00147         m_IconTitle=new char[strlen(Title)];
00148         sprintf(m_IconTitle,"%s",Title);
00149         glutSetIconTitle(m_IconTitle);
00150 UnGuard
00151 }

void SetRate int    Rate [inline]
 

Definition at line 81 of file ExManagerWindow.h.

00082 {m_Rate=Rate;}

void SetResolution int    SizeX,
int    SizeY
 

Definition at line 128 of file ExManagerWindow.cpp.

References Guard, m_WindowSizeX, m_WindowSizeXOld, m_WindowSizeY, m_WindowSizeYOld, and SetResolution().

Referenced by InputAction(), ExManagerOutput::Reshape(), and SetResolution().

00128                                                       {
00129 Guard(ExManagerWindow::SetResolution(int SizeX,int SizeY))
00130         m_WindowSizeXOld=m_WindowSizeX;
00131         m_WindowSizeYOld=m_WindowSizeY; 
00132         m_WindowSizeX=SizeX;
00133         m_WindowSizeY=SizeY;
00134 UnGuard
00135 }

void SetWindowTitle char *    Title
 

Definition at line 137 of file ExManagerWindow.cpp.

References Guard, m_Title, and SetWindowTitle().

Referenced by SetWindowTitle().

00137                                                {
00138 Guard(ExManagerWindow::SetWindowTitle(char *Title))
00139         m_Title = new char[strlen(Title)];
00140         sprintf(m_Title,"%s",Title);
00141         glutSetWindowTitle(m_Title);
00142 UnGuard
00143 }

void ShowFps void   
 

Definition at line 200 of file ExManagerWindow.cpp.

References ExNihilo::DrawCadre(), frame, Guard, m_Title, s, ShowFps(), timebase, timeframe, and ExNihilo::WriteToScreen().

Referenced by ExManagerOutput::DrawScene(), and ShowFps().

00201 {
00202 Guard(void ExManagerWindow::ShowFps(void))
00203         frame++;
00204         timeframe=glutGet(GLUT_ELAPSED_TIME);
00205         if (timeframe - timebase > 1000) 
00206         {
00207                 sprintf(s,"FPS:%4.2f",frame*1000.0/(timeframe-timebase));
00208                 timebase = timeframe;           
00209                 frame = 0;
00210         }
00211         char TimeSinceStart[30];
00212         sprintf(TimeSinceStart,"Time since start:%f",(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000));
00213         ExNihilo::DrawCadre(15,10,165,50,0.2f,0.0f,0.6f,0.9f);
00214         ExNihilo::WriteToScreen(18,25,1,1,1,m_Title);
00215         ExNihilo::WriteToScreen(18,40,1,1,1,s);
00216         ExNihilo::WriteToScreen(18,55,1,1,1,TimeSinceStart);
00217         
00218 UnGuard
00219 }

void ShowNetStat void   
 


Field Documentation

int frame [private]
 

Definition at line 60 of file ExManagerWindow.h.

Referenced by ShowFps().

void(* GlutCallBack)()
 

Referenced by Apply(), and InitManager().

int m_Bits [private]
 

Definition at line 49 of file ExManagerWindow.h.

Referenced by Apply(), ExManagerWindow(), GetFullScreen(), and SetFullScreen().

int m_Cursor [private]
 

Definition at line 55 of file ExManagerWindow.h.

Referenced by CreateNewWindow(), and ExManagerWindow().

bool m_flag = false [static, private]
 

Definition at line 26 of file ExManagerWindow.cpp.

Referenced by CreateSingleton(), and ~ExManagerWindow().

bool m_FullScreen [private]
 

Definition at line 51 of file ExManagerWindow.h.

Referenced by ExManagerWindow().

char* m_IconTitle [private]
 

Definition at line 54 of file ExManagerWindow.h.

Referenced by CreateNewWindow(), ExManagerWindow(), and SetIconTitle().

ExManagerWindow * m_instance = NULL [static, private]
 

Definition at line 27 of file ExManagerWindow.cpp.

Referenced by CreateSingleton().

bool m_OldMode [private]
 

Definition at line 52 of file ExManagerWindow.h.

Referenced by ExManagerWindow().

int m_Rate [private]
 

Definition at line 50 of file ExManagerWindow.h.

Referenced by Apply(), ExManagerWindow(), GetBits(), and SetBits().

bool m_ShowFps [private]
 

Definition at line 58 of file ExManagerWindow.h.

Referenced by ExManagerWindow(), and GetFpsState().

bool m_ShowGrille [private]
 

Definition at line 57 of file ExManagerWindow.h.

Referenced by ExManagerWindow(), GetGrilleState(), and SetFpsState().

char* m_Title [private]
 

Definition at line 53 of file ExManagerWindow.h.

Referenced by Apply(), CreateNewWindow(), ExManagerWindow(), SetWindowTitle(), and ShowFps().

int m_WindowHandler [private]
 

Definition at line 42 of file ExManagerWindow.h.

Referenced by Apply(), and CreateNewWindow().

int m_WindowPosX [private]
 

Definition at line 47 of file ExManagerWindow.h.

Referenced by Apply(), CreateNewWindow(), ExManagerWindow(), and Move().

int m_WindowPosY [private]
 

Definition at line 48 of file ExManagerWindow.h.

Referenced by Apply(), CreateNewWindow(), ExManagerWindow(), and Move().

int m_WindowSizeX [private]
 

Definition at line 43 of file ExManagerWindow.h.

Referenced by Apply(), CreateNewWindow(), ExManagerWindow(), GetResolutionY(), and SetResolution().

int m_WindowSizeXOld [private]
 

Definition at line 45 of file ExManagerWindow.h.

Referenced by CreateNewWindow(), ExManagerWindow(), and SetResolution().

int m_WindowSizeY [private]
 

Definition at line 44 of file ExManagerWindow.h.

Referenced by Apply(), CreateNewWindow(), ExManagerWindow(), GetRate(), and SetResolution().

int m_WindowSizeYOld [private]
 

Definition at line 46 of file ExManagerWindow.h.

Referenced by CreateNewWindow(), ExManagerWindow(), and SetResolution().

ExCOptions* options [private]
 

Definition at line 40 of file ExManagerWindow.h.

char s[30] [private]
 

Definition at line 61 of file ExManagerWindow.h.

Referenced by ShowFps().

int timebase [private]
 

Definition at line 60 of file ExManagerWindow.h.

Referenced by ShowFps().

int timeframe [private]
 

Definition at line 60 of file ExManagerWindow.h.

Referenced by ShowFps().


The documentation for this class was generated from the following files:
Generated on Tue Dec 10 18:20:46 2002 for ExNihilo by doxygen1.3-rc1