00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "Main.h"
00025
00026 int fen;
00027 int main(int argc, char* argv[])
00028 {
00029 Guard(int main(...))
00030 Consol = new std::ostrstream;
00031
00032
00033
00034
00035 glutInit(&argc,argv);
00036
00037
00038
00039
00040
00041 glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
00042
00043
00044 ManagerInputGLUT = ExManagerInputGLUT::CreateSingleton();
00045 ManagerWindow = ExManagerWindow::CreateSingleton();
00046 ManagerOutPut = ExManagerOutput::CreateSingleton();
00047 ManagerCommand = ExManagerCommand::CreateSingleton();
00048
00049 ManagerId = ExManagerId::CreateSingleton();
00050
00051 ManagerCamera = ExManagerCamera::CreateSingleton();
00052 ManagerConsole = ExManagerConsole::CreateSingleton();
00053 ManagerTexture = ExManagerTexture::CreateSingleton();
00054 ManagerCollision = ExManagerCollision::CreateSingleton();
00055 ManagerMenu = ExManagerMenu::CreateSingleton();
00056 ManagerInterface = ExManagerInterface::CreateSingleton();
00057 ManagerMap = ExManagerMap::CreateSingleton();
00058 ManagerParticuleSystem = ExManagerParticuleSystem::CreateSingleton();
00059 ManagerGizmo = ExManagerGizmo::CreateSingleton();
00060 ManagerLight = ExManagerLight::CreateSingleton();
00061 ManagerFog = ExManagerFog::CreateSingleton();
00062 ManagerAnimation = ExManagerAnimation::CreateSingleton();
00063 ManagerSound = ExManagerSound::CreateSingleton();
00064 ManagerSpirit = ExManagerSpirit::CreateSingleton();
00065 ManagerNetwork = ExManagerNetwork::CreateSingleton();
00066 ManagerModele = ExManagerModel::CreateSingleton();
00067
00068 ManagerFont = ExManagerFont::CreateSingleton();
00069 ManagerSpecialEffect = ExManagerSpecialEffect::CreateSingleton();
00070 ManagerVertexArrays = ExManagerVertexArrays::CreateSingleton();
00071
00072 SetManagerLink();
00073
00074 *Consol<<"****************************************"<<std::endl;
00075 *Consol<<"*Starting ExNihilo Engine *"<<std::endl;
00076 *Consol<<"****************************************"<<std::endl;
00077
00078
00079
00080 int x=1024,y=768;
00081 for(int i = 1; i < argc; i++)
00082 {
00083 if(argv[i])
00084 {
00085 std::cout<<argv[i]<<std::endl;
00086
00087 }
00088 }
00089 if(argc>2)
00090 {
00091 ManagerWindow->CreateNewWindow (atoi(argv[1]),atoi(argv[2]),argv[0]);
00092 }else ManagerWindow->CreateNewWindow (x,y,argv[0]);
00093
00094 if(atoi(argv[3])==1)m_FullScreen=true;
00095 else m_FullScreen=false;
00096
00097 ManagerWindow->SetFullScreen(m_FullScreen);
00098
00099
00100
00101 InitGlExtension();
00102 InitManager();
00103 SetGlutCallBack();
00104
00105 glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);
00106 *Consol<<"****************************************"<<std::endl;
00107 *Consol<<"*Lauching Engine *"<<std::endl;
00108 *Consol<<"****************************************"<<std::endl;
00109
00110 for(int i = 1; i < argc; i++) {
00111 if(argv[i]) {
00112
00113 ManagerCommand->LoadFile(argv[i]);
00114 }
00115 }
00116 glutMainLoop();
00117 return 0;
00118 UnGuard
00119 }
00120
00121
00122 void RoutingtoConsole(const char *Label)
00123 {
00124 Guard(void RoutingtoConsole(const char *Label))
00125 ManagerConsole->Write(Label);
00126 UnGuard
00127 }
00128
00129 void SetManagerLink(void)
00130 {
00131 Guard(void SetManagerLink(void))
00132
00133 ManagerWindow->SetConsolFlux(Consol);
00134 ManagerOutPut->SetConsolFlux(Consol);
00135 ManagerId->SetConsolFlux(Consol);
00136 ManagerCommand->SetConsolFlux(Consol);
00137 ManagerInputGLUT->SetConsolFlux(Consol);
00138 ManagerCamera->SetConsolFlux(Consol);
00139
00140 ManagerConsole->SetConsolFlux(Consol);
00141 ManagerTexture->SetConsolFlux(Consol);
00142 ManagerCollision->SetConsolFlux(Consol);
00143 ManagerMenu->SetConsolFlux(Consol);
00144 ManagerInterface->SetConsolFlux(Consol);
00145 ManagerMap->SetConsolFlux(Consol);
00146 ManagerParticuleSystem->SetConsolFlux(Consol);
00147 ManagerGizmo->SetConsolFlux(Consol);
00148 ManagerLight->SetConsolFlux(Consol);
00149 ManagerFog->SetConsolFlux(Consol);
00150 ManagerAnimation->SetConsolFlux(Consol);
00151 ManagerSpirit->SetConsolFlux(Consol);
00152 ManagerSound->SetConsolFlux(Consol);
00153
00154 ManagerModele->SetConsolFlux(Consol);
00155 ManagerFont->SetConsolFlux(Consol);
00156 ManagerSpecialEffect->SetConsolFlux(Consol);
00157 ManagerVertexArrays->SetConsolFlux(Consol);
00158
00159
00160 ManagerCommand->SetManagerId (ManagerId );
00161 ManagerCamera->SetManagerId(ManagerId);
00162
00163 ManagerTexture->SetManagerId (ManagerId );
00164 ManagerCollision->SetManagerId (ManagerId );
00165 ManagerMenu->SetManagerId (ManagerId );
00166 ManagerInterface->SetManagerId (ManagerId );
00167 ManagerMap->SetManagerId (ManagerId );
00168 ManagerGizmo->SetManagerId (ManagerId );
00169 ManagerLight->SetManagerId (ManagerId );
00170 ManagerAnimation->SetManagerId (ManagerId );
00171 ManagerSpirit->SetManagerId (ManagerId );
00172 ManagerSound->SetManagerId (ManagerId );
00173 ManagerParticuleSystem->SetManagerId (ManagerId );
00174 ManagerFont->SetManagerId (ManagerId );
00175
00176 ManagerModele->SetManagerId(ManagerId);
00177
00178 ManagerCamera->SetManagerModel(ManagerModele);
00179 ManagerModele->SetManagerTexture(ManagerTexture);
00180 ManagerModele->SetManagerVertexArrays(ManagerVertexArrays);
00181
00182 ManagerInputGLUT->SetManagerCommand(ManagerCommand);
00183
00184 ManagerCommand->SetManagerAnim(ManagerAnimation);
00185 ManagerCommand->SetManagerCollision(ManagerCollision);
00186 ManagerCommand->SetManagerFog(ManagerFog);
00187 ManagerCommand->SetManagerGizmo(ManagerGizmo);
00188 ManagerCommand->SetManagerLight(ManagerLight);
00189 ManagerCommand->SetManagerMap(ManagerMap);
00190 ManagerCommand->SetManagerParticuleSystem(ManagerParticuleSystem);
00191 ManagerCommand->SetManagerTexture(ManagerTexture);
00192 ManagerCommand->SetManagerWindow(ManagerWindow);
00193 ManagerCommand->SetManagerCamera(ManagerCamera);
00194 ManagerCommand->SetManagerGizmo(ManagerGizmo);
00195 ManagerCommand->SetManagerMenu(ManagerMenu);
00196 ManagerCommand->SetManagerInterface(ManagerInterface);
00197 ManagerCommand->SetManagerConsole(ManagerConsole);
00198 ManagerCommand->SetManagerSound(ManagerSound);
00199 ManagerCommand->SetManagerSpirit(ManagerSpirit);
00200
00201 ManagerCommand->SetManagerModel(ManagerModele);
00202 ManagerCommand->SetManagerNetwork(ManagerNetwork);
00203
00204 ManagerMap->SetManagerTexture(ManagerTexture);
00205
00206 ManagerParticuleSystem->SetManagerTexture(ManagerTexture);
00207
00208 ManagerOutPut->SetManagerWindow(ManagerWindow);
00209 ManagerOutPut->SetManagerCommand(ManagerCommand);
00210 ManagerOutPut->SetManagerCamera(ManagerCamera);
00211
00212 ManagerOutPut->SetManagerAnim(ManagerAnimation);
00213 ManagerOutPut->SetManagerCollision(ManagerCollision);
00214 ManagerOutPut->SetManagerFog(ManagerFog);
00215 ManagerOutPut->SetManagerConsole(ManagerConsole);
00216 ManagerOutPut->SetManagerMenu(ManagerMenu);
00217 ManagerOutPut->SetManagerInterface(ManagerInterface);
00218 ManagerOutPut->SetManagerSpirit(ManagerSpirit);
00219 ManagerOutPut->SetManagerMap(ManagerMap);
00220
00221 ManagerOutPut->SetManagerModel(ManagerModele);
00222 ManagerOutPut->SetManagerGizmo(ManagerGizmo);
00223 ManagerOutPut->SetManagerParticuleSystem(ManagerParticuleSystem);
00224 ManagerOutPut->SetManagerLight(ManagerLight);
00225 ManagerOutPut->SetManagerNetwork(ManagerNetwork);
00226
00227
00228
00229
00230 ManagerInterface->SetManagerTexture(ManagerTexture);
00231
00232 ManagerConsole->SetManagerWindow(ManagerWindow);
00233 ManagerConsole->SetManagerTexture(ManagerTexture);
00234
00235 UnGuard
00236 }
00237
00238 void InitGlExtension(void)
00239 {
00240 Guard(void InitGlExtension(void))
00241
00242
00243
00244
00245
00246
00247
00248
00249 UnGuard
00250 }
00251
00252 void InitManager(void)
00253 {
00254 Guard(void InitManager(void))
00255 ManagerInputGLUT->CheckInput();
00256 ManagerInputGLUT->DisplayAviableInput();
00257 ManagerId->Init();
00258 ManagerVertexArrays->Init();
00259
00260
00261 ManagerTexture->Init();
00262 ManagerSound->Init();
00263 ManagerSound->DisplayAviableInput();
00264
00265
00266 ManagerInterface->Init();
00267 ManagerSpirit->Init();
00268
00269 ManagerFont->Init();
00270 ManagerMenu->Init();
00271
00272 ManagerCamera->Init();
00273 ManagerGizmo->Init();
00274 ManagerParticuleSystem->Init();
00275 ManagerLight->Init();
00276
00277 ManagerWindow->GlutCallBack=&SetGlutCallBack;
00278 if(m_FullScreen)ManagerWindow->Apply();
00279 ManagerModele->Init();
00280
00281 ManagerOutPut->Init();
00282 ManagerCommand->Init();
00283 ManagerConsole->Init();
00284 ManagerNetwork->Init();
00285
00286
00287
00288 UnGuard
00289 }
00290
00291 void SetGlutCallBack(void)
00292 {
00293 Guard(SetGlutCallBack(void))
00294
00295
00296
00297 if(ManagerInputGLUT->IsKeyboard())
00298 {
00299 glutKeyboardFunc(keyboard);
00300 glutKeyboardUpFunc(keyboardup);
00301 glutSpecialFunc(spekeyboard);
00302 glutSpecialUpFunc(spekeyboardup);
00303 }else
00304 {
00305 glutKeyboardFunc(NULL);
00306 glutKeyboardUpFunc(NULL);
00307 glutSpecialFunc(NULL);
00308 glutSpecialUpFunc(NULL);
00309 }
00310
00311
00312
00313 if(ManagerInputGLUT->IsMouse())
00314 {
00315 glutMouseFunc(Mouse);
00316 glutEntryFunc(Focus);
00317 glutMotionFunc(MotionFunc);
00318 glutPassiveMotionFunc(PassiveMotionFunc);
00319 }
00320 else
00321 {
00322 glutMouseFunc(NULL);
00323 glutEntryFunc(NULL);
00324 glutMotionFunc(NULL);
00325 glutPassiveMotionFunc(NULL);
00326 }
00327
00328
00329
00330 if(ManagerInputGLUT->IsJoystick())
00331 {
00332 }
00333 else
00334 {
00335 }
00336
00337
00338
00339 if(ManagerInputGLUT->IsSpaceBall())
00340 {
00341 glutSpaceballMotionFunc(SpaceballMotionFunc);
00342 glutSpaceballRotateFunc(SpaceballRotateFunc);
00343 }
00344 else
00345 {
00346 glutSpaceballRotateFunc(NULL);
00347 glutSpaceballMotionFunc(NULL);
00348 }
00349
00350
00351
00352 if(ManagerInputGLUT->IsTablet())
00353 {
00354 glutTabletMotionFunc(TabletMotionFunc);
00355 glutTabletButtonFunc(TabletButtonFunc);
00356 }
00357 else
00358 {
00359 glutTabletMotionFunc(NULL);
00360 glutTabletButtonFunc(NULL);
00361 }
00362
00363
00364
00365 glutDisplayFunc(display);
00366 glutIdleFunc(display);
00367 glutReshapeFunc(reshape);
00368
00369
00370
00371 ManagerConsole->Init();
00372 ExNihilo::InitBasicObjectList();
00373 ManagerOutPut->Init();
00374 ManagerInterface->Reset();
00375 ManagerInterface->Init();
00376 UnGuard
00377 }
00378
00379 void keyboard(unsigned char key,int x,int y){ManagerInputGLUT->Key(key,x,y);}
00380 void keyboardup(unsigned char key, int x, int y){ManagerInputGLUT->KeyUp(key,x,y);}
00381 void spekeyboard(int key,int x,int y){ManagerInputGLUT->KeySpe(key,x,y);}
00382 void spekeyboardup(int key, int x, int y){ManagerInputGLUT->KeySpeUp(key,x,y);}
00383 void Mouse(int button, int state, int x, int y){ManagerInputGLUT->Mouse(button,state,x,y);}
00384 void Focus(int state){ManagerInputGLUT->Focus(state);}
00385 void MotionFunc(int x, int y){ManagerInputGLUT->MouseMotion(x,y);}
00386 void PassiveMotionFunc(int x, int y){ManagerInputGLUT->MousePassiveMotion(x,y);}
00387 void SpaceballMotionFunc(int x, int y, int z){ManagerInputGLUT->SpaceballMotion(x,y,z);}
00388 void SpaceballRotateFunc(int x, int y, int z){ManagerInputGLUT->SpaceballRotate(x,y,z);}
00389 void TabletMotionFunc(int x, int y){ManagerInputGLUT->TabletMotion(x,y);}
00390 void TabletButtonFunc(int button, int state, int x, int y) {ManagerInputGLUT->TabletButton(button,state,x,y);}
00391 void display(void){ManagerOutPut->DrawScene();}
00392 void reshape(int w,int h){ManagerOutPut->Reshape(w,h);}
00393
00394
00395