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 InitFlux();
00031 glutInit(&argc,argv);
00032
00033
00034
00035
00036
00037
00038 glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
00039
00040 CreateManager();
00041 SetManagerLink();
00042
00043 *Consol<<"****************************************"<<std::endl;
00044 *Consol<<"*Starting ExNihilo Engine *"<<std::endl;
00045 *Consol<<"****************************************"<<std::endl;
00046
00047
00048
00049
00050 try
00051 {
00052
00053 int x=1024,y=768;
00054 for(int i = 1; i < argc; i++)
00055 {
00056 if(argv[i])
00057 {
00058 std::cout<<argv[i]<<std::endl;
00059
00060 }
00061 }
00062 if(argc>2)
00063 {
00064 ManagerWindow->CreateNewWindow (atoi(argv[1]),atoi(argv[2]),argv[0]);
00065 }else ManagerWindow->CreateNewWindow (x,y,argv[0]);
00066
00067 if(atoi(argv[3])==1)m_FullScreen=true;
00068 else m_FullScreen=false;
00069
00070 ManagerWindow->SetFullScreen(m_FullScreen);
00071
00072
00073
00074
00075 }catch (...)
00076 {
00077 std::cout<<"Full screen fail start in window mode"<<std::endl;
00078 }
00079 PreInitManager();
00080 SetGlutCallBack();
00081 PostInitManager();
00082
00083 *Consol<<"****************************************"<<std::endl;
00084 *Consol<<"*Lauching Engine *"<<std::endl;
00085 *Consol<<"****************************************"<<std::endl;
00086
00087 for(int i = 1; i < argc; i++) {
00088 if(argv[i]) {
00089
00090 ManagerCommand->LoadFile(argv[i]);
00091 }
00092 }
00093 glutMainLoop();
00094 return 0;
00095 UnGuard
00096 }
00097 void InitFlux(void)
00098 {
00099 Guard(void InitFlux(void))
00100 Consol = new std::ostrstream;
00101 FluxAction = new ExCFluxAction;
00102 UnGuard
00103 }
00104
00105
00106 void CreateManager(void)
00107 {
00108 Guard(void CreateManager(void))
00109
00110
00111
00112 ManagerInputGLUT = ExManagerInputGLUT::CreateSingleton();
00113 ManagerWindow = ExManagerWindow::CreateSingleton();
00114 ManagerOutPut = ExManagerOutput::CreateSingleton();
00115 ManagerCommand = ExManagerCommand::CreateSingleton();
00116 ManagerId = ExManagerId::CreateSingleton();
00117 ManagerCamera = ExManagerCamera::CreateSingleton();
00118 ManagerConsole = ExManagerConsole::CreateSingleton();
00119 ManagerTexture = ExManagerTexture::CreateSingleton();
00120 ManagerCollision = ExManagerCollision::CreateSingleton();
00121 ManagerInterface = ExManagerInterface::CreateSingleton();
00122 ManagerMap = ExManagerMap::CreateSingleton();
00123 ManagerParticuleSystem = ExManagerParticuleSystem::CreateSingleton();
00124 ManagerGizmo = ExManagerGizmo::CreateSingleton();
00125 ManagerLight = ExManagerLight::CreateSingleton();
00126 ManagerFog = ExManagerFog::CreateSingleton();
00127 ManagerAnimation = ExManagerAnimation::CreateSingleton();
00128 ManagerSound = ExManagerSound::CreateSingleton();
00129 ManagerSpirit = ExManagerSpirit::CreateSingleton();
00130 ManagerNetwork = ExManagerNetwork::CreateSingleton();
00131 ManagerModele = ExManagerModel::CreateSingleton();
00132 ManagerFont = ExManagerFont::CreateSingleton();
00133 ManagerSpecialEffect = ExManagerSpecialEffect::CreateSingleton();
00134 ManagerVertexArrays = ExManagerVertexArrays::CreateSingleton();
00135 ManagerVertexProgram = ExManagerVertexProgram::CreateSingleton();
00136 ManagerObjectWindow = ExManagerObjectWindow::CreateSingleton();
00137 ManagerMesh = ExManagerMesh::CreateSingleton();
00138 ManagerLoad = ExManagerLoad::CreateSingleton();
00139 ManagerPVS = ExManagerPVS::CreateSingleton();
00140 ManagerEntity = ExManagerEntity::CreateSingleton();
00141 UnGuard
00142 }
00143
00144 void SetManagerLink(void)
00145 {
00146 Guard(void SetManagerLink(void))
00147
00148
00149
00150 ManagerWindow->SetFlux(Consol,FluxAction);
00151 ManagerOutPut->SetFlux(Consol,FluxAction);
00152 ManagerId->SetFlux(Consol,FluxAction);
00153 ManagerCommand->SetFlux(Consol,FluxAction);
00154 ManagerInputGLUT->SetFlux(Consol,FluxAction);
00155 ManagerCamera->SetFlux(Consol,FluxAction);
00156 ManagerConsole->SetFlux(Consol,FluxAction);
00157 ManagerTexture->SetFlux(Consol,FluxAction);
00158 ManagerCollision->SetFlux(Consol,FluxAction);
00159 ManagerInterface->SetFlux(Consol,FluxAction);
00160 ManagerMap->SetFlux(Consol,FluxAction);
00161 ManagerParticuleSystem->SetFlux(Consol,FluxAction);
00162 ManagerGizmo->SetFlux(Consol,FluxAction);
00163 ManagerLight->SetFlux(Consol,FluxAction);
00164 ManagerFog->SetFlux(Consol,FluxAction);
00165 ManagerAnimation->SetFlux(Consol,FluxAction);
00166 ManagerSpirit->SetFlux(Consol,FluxAction);
00167 ManagerSound->SetFlux(Consol,FluxAction);
00168 ManagerModele->SetFlux(Consol,FluxAction);
00169 ManagerFont->SetFlux(Consol,FluxAction);
00170 ManagerSpecialEffect->SetFlux(Consol,FluxAction);
00171 ManagerVertexArrays->SetFlux(Consol,FluxAction);
00172 ManagerVertexProgram->SetFlux(Consol,FluxAction);
00173 ManagerObjectWindow->SetFlux(Consol,FluxAction);
00174 ManagerPVS->SetFlux(Consol,FluxAction);
00175 ManagerLoad->SetFlux(Consol,FluxAction);
00176 ManagerMesh->SetFlux(Consol,FluxAction);
00177 ManagerEntity->SetFlux(Consol,FluxAction);
00178
00179
00180
00181 ManagerCommand->SetManagerId (ManagerId );
00182 ManagerCamera->SetManagerId(ManagerId);
00183 ManagerTexture->SetManagerId (ManagerId );
00184 ManagerCollision->SetManagerId (ManagerId );
00185 ManagerInterface->SetManagerId (ManagerId );
00186 ManagerMap->SetManagerId (ManagerId );
00187 ManagerGizmo->SetManagerId (ManagerId );
00188 ManagerLight->SetManagerId (ManagerId );
00189 ManagerAnimation->SetManagerId (ManagerId );
00190 ManagerSpirit->SetManagerId (ManagerId );
00191 ManagerSound->SetManagerId (ManagerId );
00192 ManagerParticuleSystem->SetManagerId (ManagerId );
00193 ManagerFont->SetManagerId (ManagerId );
00194 ManagerObjectWindow->SetManagerId(ManagerId);
00195 ManagerModele->SetManagerId(ManagerId);
00196 ManagerMesh->SetManagerId(ManagerId);
00197 ManagerLoad->SetManagerId(ManagerId);
00198 ManagerEntity->SetManagerId(ManagerId);
00199
00200 ManagerCamera->SetManagerModel(ManagerModele);
00201
00202 ManagerModele->SetManagerTexture(ManagerTexture);
00203 ManagerModele->SetManagerVertexArrays(ManagerVertexArrays);
00204
00205 ManagerCollision->SetManagerModel(ManagerModele);
00206
00207 ManagerInputGLUT->SetManagerCommand(ManagerCommand);
00208
00209
00210
00211 ManagerCommand->SetManagerAnim(ManagerAnimation);
00212 ManagerCommand->SetManagerCollision(ManagerCollision);
00213 ManagerCommand->SetManagerFog(ManagerFog);
00214 ManagerCommand->SetManagerGizmo(ManagerGizmo);
00215 ManagerCommand->SetManagerLight(ManagerLight);
00216 ManagerCommand->SetManagerMap(ManagerMap);
00217 ManagerCommand->SetManagerParticuleSystem(ManagerParticuleSystem);
00218 ManagerCommand->SetManagerTexture(ManagerTexture);
00219 ManagerCommand->SetManagerWindow(ManagerWindow);
00220 ManagerCommand->SetManagerCamera(ManagerCamera);
00221 ManagerCommand->SetManagerGizmo(ManagerGizmo);
00222 ManagerCommand->SetManagerInterface(ManagerInterface);
00223 ManagerCommand->SetManagerConsole(ManagerConsole);
00224 ManagerCommand->SetManagerSound(ManagerSound);
00225 ManagerCommand->SetManagerSpirit(ManagerSpirit);
00226 ManagerCommand->SetManagerModel(ManagerModele);
00227 ManagerCommand->SetManagerNetwork(ManagerNetwork);
00228 ManagerCommand->SetManagerObjectWindow(ManagerObjectWindow);
00229 ManagerCommand->SetManagerSpecialEffect(ManagerSpecialEffect);
00230 ManagerCommand->SetManagerLoad(ManagerLoad);
00231 ManagerCommand->SetManagerPVS(ManagerPVS);
00232 ManagerCommand->SetManagerMesh(ManagerMesh);
00233 ManagerCommand->SetManagerEntity(ManagerEntity);
00234
00235 ManagerMap->SetManagerTexture(ManagerTexture);
00236 ManagerMap->SetManagerFog(ManagerFog);
00237
00238 ManagerParticuleSystem->SetManagerTexture(ManagerTexture);
00239 ManagerParticuleSystem->SetManagerCollision(ManagerCollision);
00240
00241
00242
00243 ManagerOutPut->SetManagerWindow(ManagerWindow);
00244 ManagerOutPut->SetManagerCommand(ManagerCommand);
00245 ManagerOutPut->SetManagerCamera(ManagerCamera);
00246 ManagerOutPut->SetManagerAnim(ManagerAnimation);
00247 ManagerOutPut->SetManagerCollision(ManagerCollision);
00248 ManagerOutPut->SetManagerFog(ManagerFog);
00249 ManagerOutPut->SetManagerConsole(ManagerConsole);
00250 ManagerOutPut->SetManagerInterface(ManagerInterface);
00251 ManagerOutPut->SetManagerSpirit(ManagerSpirit);
00252 ManagerOutPut->SetManagerMap(ManagerMap);
00253 ManagerOutPut->SetManagerModel(ManagerModele);
00254 ManagerOutPut->SetManagerGizmo(ManagerGizmo);
00255 ManagerOutPut->SetManagerParticuleSystem(ManagerParticuleSystem);
00256 ManagerOutPut->SetManagerLight(ManagerLight);
00257 ManagerOutPut->SetManagerNetwork(ManagerNetwork);
00258 ManagerOutPut->SetManagerCollision(ManagerCollision);
00259 ManagerOutPut->SetManagerVertexProgram(ManagerVertexProgram);
00260 ManagerOutPut->SetManagerObjectWindow(ManagerObjectWindow);
00261 ManagerOutPut->SetManagerSpecialEffect(ManagerSpecialEffect);
00262 ManagerOutPut->SetManagerPVS(ManagerPVS);
00263 ManagerOutPut->SetManagerLoad(ManagerLoad);
00264 ManagerOutPut->SetManagerLight(ManagerLight);
00265
00266 ManagerInterface->SetManagerTexture(ManagerTexture);
00267
00268 ManagerConsole->SetManagerWindow(ManagerWindow);
00269 ManagerConsole->SetManagerTexture(ManagerTexture);
00270
00271 ManagerObjectWindow->SetManagerTexture(ManagerTexture);
00272 ManagerObjectWindow->SetManagerWindow(ManagerWindow);
00273
00274 ManagerAnimation->SetManagerCamera(ManagerCamera);
00275 ManagerAnimation->SetManagerGizmo(ManagerGizmo);
00276 ManagerAnimation->SetManagerLight(ManagerLight);
00277 ManagerAnimation->SetManagerModel(ManagerModele);
00278 ManagerAnimation->SetManagerParticuleSystem(ManagerParticuleSystem);
00279 ManagerAnimation->SetManagerEntity(ManagerEntity);
00280
00281 ManagerLoad->SetManagerCamera(ManagerCamera);
00282 ManagerLoad->SetManagerAnim(ManagerAnimation);
00283 ManagerLoad->SetManagerConsole(ManagerConsole);
00284 ManagerLoad->SetManagerInterface(ManagerInterface);
00285 ManagerLoad->SetManagerSpirit(ManagerSpirit);
00286 ManagerLoad->SetManagerMap(ManagerMap);
00287 ManagerLoad->SetManagerModel(ManagerModele);
00288 ManagerLoad->SetManagerGizmo(ManagerGizmo);
00289 ManagerLoad->SetManagerParticuleSystem(ManagerParticuleSystem);
00290 ManagerLoad->SetManagerLight(ManagerLight);
00291 ManagerLoad->SetManagerVertexProgram(ManagerVertexProgram);
00292 ManagerLoad->SetManagerObjectWindow(ManagerObjectWindow);
00293 ManagerLoad->SetManagerSpecialEffect(ManagerSpecialEffect);
00294 ManagerLoad->SetManagerMesh(ManagerMesh);
00295 ManagerLoad->SetManagerSound(ManagerSound);
00296 ManagerLoad->SetManagerTexture(ManagerTexture);
00297 ManagerLoad->SetManagerEntity(ManagerEntity);
00298
00299 ManagerPVS->SetManagerCamera(ManagerCamera);
00300 ManagerPVS->SetManagerMap(ManagerMap);
00301 ManagerPVS->SetManagerModel(ManagerModele);
00302 ManagerPVS->SetManagerGizmo(ManagerGizmo);
00303 ManagerPVS->SetManagerParticuleSystem(ManagerParticuleSystem);
00304 ManagerPVS->SetManagerLight(ManagerLight);
00305 ManagerPVS->SetManagerMesh(ManagerMesh);
00306 ManagerPVS->SetManagerEntity(ManagerEntity);
00307
00308 ManagerMesh->SetManagerTexture(ManagerTexture);
00309 ManagerMesh->SetManagerModel(ManagerModele);
00310
00311 ManagerEntity->SetManagerGizmo(ManagerGizmo);
00312 ManagerEntity->SetManagerMesh(ManagerMesh);
00313 ManagerEntity->SetManagerModel(ManagerModele);
00314 UnGuard
00315 }
00316
00317 void PreInitManager(void)
00318 {
00319 Guard(void PreInitManager(void))
00320
00321
00322
00323 try{
00324 ManagerInputGLUT->Init();
00325 ManagerInputGLUT->CheckInput();
00326 ManagerInputGLUT->DisplayAviableInput();
00327 }catch(...){std::cout<<"Unknow error in ManagerInputGLUT Init "<<std::endl;}
00328 try{ManagerId->Init();}
00329 catch(...){std::cout<<"Unknow error in ManagerId Init "<<std::endl;}
00330 try{ManagerVertexArrays->Init();}
00331 catch(...){std::cout<<"Unknow error in ManagerVertexArrays Init "<<std::endl;}
00332 try{ManagerVertexProgram->Init();}
00333 catch(...){std::cout<<"Unknow error in ManagerVertexProgram Init "<<std::endl;}
00334 try{ManagerTexture->Init();}
00335 catch (ExCExpMultitexturing)
00336 {
00337 std::cout<<"GL_ARB_multitexture is missing unable to launch engine"<<std::endl;
00338 }
00339 catch(...){std::cout<<"Unknow error in ManagerTexture Init "<<std::endl;}
00340 try{
00341 ManagerSound->Init();
00342 ManagerSound->DisplayAviableInput();}
00343 catch(...){std::cout<<"Unknow error in ManagerSound Init "<<std::endl;}
00344
00345 try{ManagerInterface->Init();}
00346 catch(...){std::cout<<"Unknow error in ManagerInterface Init "<<std::endl;}
00347 try{ManagerSpirit->Init();}
00348 catch(...){std::cout<<"Unknow error in ManagerSpirit Init "<<std::endl;}
00349 try{ManagerMesh->Init();}
00350 catch(...){std::cout<<"Unknow error in ManagerMesh Init "<<std::endl;}
00351 try{ManagerFont->Init();}
00352 catch(...){std::cout<<"Unknow error in ManagerFont Init "<<std::endl;}
00353 try{ManagerMap->Init();}
00354 catch(...){std::cout<<"Unknow error in ManagerMap Init "<<std::endl;}
00355 try{ManagerCamera->Init();}
00356 catch(...){std::cout<<"Unknow error in ManagerCamera Init "<<std::endl;}
00357 try{ManagerGizmo->Init();}
00358 catch(...){std::cout<<"Unknow error in ManagerGizmo Init "<<std::endl;}
00359 try{ManagerParticuleSystem->Init();}
00360 catch(...){std::cout<<"Unknow error in ManagerParticuleSystem Init "<<std::endl;}
00361 try{ManagerLight->Init();}
00362 catch(...){std::cout<<"Unknow error in ManagerLight Init "<<std::endl;}
00363
00364 try{ManagerWindow->GlutCallBack=&SetGlutCallBack;
00365 if(m_FullScreen)ManagerWindow->Apply();}
00366 catch(...){std::cout<<"Unknow error in ManagerWindow Init "<<std::endl;}
00367 try{ManagerModele->Init();}
00368 catch(...){std::cout<<"Unknow error in ManagerModele Init "<<std::endl;}
00369 try{ManagerObjectWindow->Init();}
00370 catch(...){std::cout<<"Unknow error in ManagerObjectWindow Init "<<std::endl;}
00371 try{ManagerOutPut->Init();}
00372 catch(...){std::cout<<"Unknow error in ManagerOutPut Init "<<std::endl;}
00373 try{ManagerCommand->Init();}
00374 catch(...){std::cout<<"Unknow error in ManagerCommand Init "<<std::endl;}
00375 try{ManagerConsole->Init();}
00376 catch(...){std::cout<<"Unknow error in ManagerConsole Init "<<std::endl;}
00377 try{ManagerNetwork->Init();}
00378 catch(...){std::cout<<"Unknow error in ManagerNetwork Init "<<std::endl;}
00379 try{ManagerFog->Init();}
00380 catch(...){std::cout<<"Unknow error in ManagerFog Init "<<std::endl;}
00381 try{ManagerAnimation->Init();}
00382 catch(...){std::cout<<"Unknow error in ManagerAnimation Init "<<std::endl;}
00383 try{ManagerEntity->Init();}
00384 catch(...){std::cout<<"Unknow error in ManagerEntity Init "<<std::endl;}
00385 try{ManagerLoad->Init();}
00386 catch(...){std::cout<<"Unknow error in ManagerLoad Init "<<std::endl;}
00387 try{ManagerPVS->Init();}
00388 catch(...){std::cout<<"Unknow error in ManagerPVS Init "<<std::endl;}
00389 UnGuard
00390 }
00391
00392 void PostInitManager(void)
00393 {
00394 Guard(void PostInitManager(void))
00395 ManagerConsole->Init();
00396 ExNihilo::InitBasicObjectList();
00397 ManagerOutPut->Init();
00398 ManagerInterface->Reset();
00399 ManagerInterface->Init();
00400 UnGuard
00401 }
00402
00403 void SetGlutCallBack(void)
00404 {
00405 Guard(SetGlutCallBack(void))
00406
00407
00408
00409 if(ManagerInputGLUT->IsKeyboard())
00410 {
00411 glutKeyboardFunc(keyboard);
00412 glutKeyboardUpFunc(keyboardup);
00413 glutSpecialFunc(spekeyboard);
00414 glutSpecialUpFunc(spekeyboardup);
00415 }else
00416 {
00417 glutKeyboardFunc(NULL);
00418 glutKeyboardUpFunc(NULL);
00419 glutSpecialFunc(NULL);
00420 glutSpecialUpFunc(NULL);
00421 }
00422
00423
00424
00425 if(ManagerInputGLUT->IsMouse())
00426 {
00427 glutMouseFunc(Mouse);
00428 glutEntryFunc(Focus);
00429 glutMotionFunc(MotionFunc);
00430 glutPassiveMotionFunc(PassiveMotionFunc);
00431 }
00432 else
00433 {
00434 glutMouseFunc(NULL);
00435 glutEntryFunc(NULL);
00436 glutMotionFunc(NULL);
00437 glutPassiveMotionFunc(NULL);
00438 }
00439
00440
00441
00442 if(ManagerInputGLUT->IsJoystick())
00443 {
00444 }
00445 else
00446 {
00447 }
00448
00449
00450
00451 if(ManagerInputGLUT->IsSpaceBall())
00452 {
00453 glutSpaceballMotionFunc(SpaceballMotionFunc);
00454 glutSpaceballRotateFunc(SpaceballRotateFunc);
00455 }
00456 else
00457 {
00458 glutSpaceballRotateFunc(NULL);
00459 glutSpaceballMotionFunc(NULL);
00460 }
00461
00462
00463
00464 if(ManagerInputGLUT->IsTablet())
00465 {
00466 glutTabletMotionFunc(TabletMotionFunc);
00467 glutTabletButtonFunc(TabletButtonFunc);
00468 }
00469 else
00470 {
00471 glutTabletMotionFunc(NULL);
00472 glutTabletButtonFunc(NULL);
00473 }
00474
00475
00476
00477 glutDisplayFunc(display);
00478 glutIdleFunc(display);
00479 glutReshapeFunc(reshape);
00480
00481 UnGuard
00482 }
00483
00484 void keyboard(unsigned char key,int x,int y){ManagerInputGLUT->Key(key,x,y);}
00485 void keyboardup(unsigned char key, int x, int y){ManagerInputGLUT->KeyUp(key,x,y);}
00486 void spekeyboard(int key,int x,int y){ManagerInputGLUT->KeySpe(key,x,y);}
00487 void spekeyboardup(int key, int x, int y){ManagerInputGLUT->KeySpeUp(key,x,y);}
00488 void Mouse(int button, int state, int x, int y){ManagerInputGLUT->Mouse(button,state,x,y);}
00489 void Focus(int state){ManagerInputGLUT->Focus(state);}
00490 void MotionFunc(int x, int y){ManagerInputGLUT->MouseMotion(x,y);}
00491 void PassiveMotionFunc(int x, int y){ManagerInputGLUT->MousePassiveMotion(x,y);}
00492 void SpaceballMotionFunc(int x, int y, int z){ManagerInputGLUT->SpaceballMotion(x,y,z);}
00493 void SpaceballRotateFunc(int x, int y, int z){ManagerInputGLUT->SpaceballRotate(x,y,z);}
00494 void TabletMotionFunc(int x, int y){ManagerInputGLUT->TabletMotion(x,y);}
00495 void TabletButtonFunc(int button, int state, int x, int y) {ManagerInputGLUT->TabletButton(button,state,x,y);}
00496 void display(void){ManagerOutPut->DrawScene();}
00497 void reshape(int w,int h){ManagerOutPut->Reshape(w,h);}
00498
00499
00500