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 ExCOptions *options = new ExCOptions;
00033 options->init ();
00034
00035 glutInit(&argc,argv);
00036 glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
00037
00038 ManagerWindow = new ExManagerWindow;
00039 ManagerConsole = new ExManagerConsole;
00040 ManagerOutPut = new ExManagerOutput;
00041 ManagerTexture = new ExManagerTexture;
00042 ManagerPVS = new ExManagerPVS;
00043 ManagerCollision = new ExManagerCollision;
00044 ManagerEntite = new ExManagerEntite;
00045 ManagerCam = new ExManagerCam;
00046 ManagerMenu = new ExManagerMenu;
00047 ManagerInterface = new ExManagerInterface;
00048 ManagerMap = new ExManagerMap;
00049 ManagerCommand = new ExManagerCommand;
00050 ManagerParticuleSystem = new ExManagerParticuleSystem;
00051 ManagerGizmo = new ExManagerGizmo;
00052 ManagerLight = new ExManagerLight;
00053 ManagerFog = new ExManagerFog;
00054 ManagerAnimation = new ExManagerAnimation;
00055 ManagerInputGLUT = new ExManagerInputGLUT;
00056 ManagerId = new ExManagerId;
00057 ManagerSound = new ExManagerSound;
00058 ManagerSpirit = new ExManagerSpirit;
00059
00060 SetManagerLink();
00061
00062 *Consol<<"****************************************"<<std::endl;
00063 *Consol<<"*Starting ExNihilo Engine *"<<std::endl;
00064 *Consol<<"****************************************"<<std::endl;
00065 ManagerWindow->Create (options->getWindowResolutionX(), options->getWindowResolutionY (), 200, 200, argv[0]);
00066 ManagerWindow->SetFpsState (options->getWindowShowfps ());
00067 InitGlExtension();
00068 InitManager();
00069 ManagerInputGLUT->CheckInput();
00070 ManagerInputGLUT->DisplayAviableInput();
00071 ManagerSound->DisplayAviableInput();
00072 SetGlutCallBack();
00073 glutSetKeyRepeat(GLUT_KEY_REPEAT_ON);
00074 *Consol<<"****************************************"<<std::endl;
00075 *Consol<<"*Lauching Engine *"<<std::endl;
00076 *Consol<<"****************************************"<<std::endl;
00077
00078 for(int i = 1; i < argc; i++) {
00079 if(argv[i]) {
00080
00081 ManagerCommand->LoadFile(argv[i]);
00082 }
00083 }
00084 glutMainLoop();
00085 UnGuard
00086 return 0;
00087 }
00088
00089 void RoutingtoConsole(const char *Label)
00090 {
00091 Guard(void RoutingtoConsole(const char *Label))
00092 ManagerConsole->Write(Label);
00093 UnGuard
00094 }
00095
00096 void SetManagerLink(void)
00097 {
00098 Guard(void SetManagerLink(void))
00099 ManagerConsole->Consol=Consol;
00100 ManagerWindow->Consol=Consol;
00101 ManagerOutPut->Consol=Consol;
00102 ManagerTexture->Consol=Consol;
00103 ManagerPVS->Consol=Consol;
00104 ManagerCollision->Consol=Consol;
00105 ManagerEntite->Consol=Consol;
00106 ManagerCam->Consol=Consol;
00107 ManagerMenu->Consol=Consol;
00108 ManagerInterface->Consol=Consol;
00109 ManagerMap->Consol=Consol;
00110 ManagerParticuleSystem->Consol=Consol;
00111 ManagerGizmo->Consol=Consol;
00112 ManagerLight->Consol=Consol;
00113 ManagerFog->Consol=Consol;
00114 ManagerAnimation->Consol=Consol;
00115 ManagerInputGLUT->Consol=Consol;
00116 ManagerId->Consol=Consol;
00117 ManagerSpirit->Consol=Consol;
00118 ManagerSound->Consol=Consol;
00119 ManagerCommand->Consol=Consol;
00120
00121 ManagerWindow->WriteToConsol=&RoutingtoConsole;
00122 ManagerConsole->WriteToConsol=&RoutingtoConsole;
00123 ManagerOutPut->WriteToConsol=&RoutingtoConsole;
00124 ManagerTexture->WriteToConsol=&RoutingtoConsole;
00125 ManagerPVS->WriteToConsol=&RoutingtoConsole;
00126 ManagerCollision->WriteToConsol=&RoutingtoConsole;
00127 ManagerEntite->WriteToConsol=&RoutingtoConsole;
00128 ManagerCam->WriteToConsol=&RoutingtoConsole;
00129 ManagerMenu->WriteToConsol=&RoutingtoConsole;
00130 ManagerInterface->WriteToConsol=&RoutingtoConsole;
00131 ManagerMap->WriteToConsol=&RoutingtoConsole;
00132 ManagerCommand->WriteToConsol=&RoutingtoConsole;
00133 ManagerParticuleSystem->WriteToConsol=&RoutingtoConsole;
00134 ManagerGizmo->WriteToConsol=&RoutingtoConsole;
00135 ManagerLight->WriteToConsol=&RoutingtoConsole;
00136 ManagerFog->WriteToConsol=&RoutingtoConsole;
00137 ManagerAnimation->WriteToConsol=&RoutingtoConsole;
00138 ManagerInputGLUT->WriteToConsol=&RoutingtoConsole;
00139 ManagerId->WriteToConsol=&RoutingtoConsole;
00140 ManagerSpirit->WriteToConsol=&RoutingtoConsole;
00141 ManagerSound->WriteToConsol=&RoutingtoConsole;
00142
00143 ManagerWindow->SetManagerId (ManagerId );
00144 ManagerTexture->SetManagerId (ManagerId );
00145 ManagerPVS->SetManagerId (ManagerId );
00146 ManagerCollision->SetManagerId (ManagerId );
00147 ManagerEntite->SetManagerId (ManagerId );
00148 ManagerCam->SetManagerId (ManagerId );
00149 ManagerMenu->SetManagerId (ManagerId );
00150 ManagerInterface->SetManagerId (ManagerId );
00151 ManagerMap->SetManagerId (ManagerId );
00152 ManagerCommand->SetManagerId (ManagerId );
00153 ManagerGizmo->SetManagerId (ManagerId );
00154 ManagerLight->SetManagerId (ManagerId );
00155 ManagerFog->SetManagerId (ManagerId );
00156 ManagerAnimation->SetManagerId (ManagerId );
00157 ManagerSpirit->SetManagerId (ManagerId );
00158 ManagerSound->SetManagerId (ManagerId );
00159
00160 ManagerInputGLUT->SetManagerCommand(ManagerCommand);
00161
00162 ManagerCommand->SetManagerAnim(ManagerAnimation);
00163 ManagerCommand->SetManagerCam(ManagerCam);
00164 ManagerCommand->SetManagerCollision(ManagerCollision);
00165 ManagerCommand->SetManagerEntite(ManagerEntite);
00166 ManagerCommand->SetManagerFog(ManagerFog);
00167 ManagerCommand->SetManagerGizmo(ManagerGizmo);
00168 ManagerCommand->SetManagerLight(ManagerLight);
00169 ManagerCommand->SetManagerMap(ManagerMap);
00170 ManagerCommand->SetManagerParticuleSystem(ManagerParticuleSystem);
00171 ManagerCommand->SetManagerPVS(ManagerPVS);
00172 ManagerCommand->SetManagerTexture(ManagerTexture);
00173 ManagerCommand->SetManagerWindow(ManagerWindow);
00174 ManagerCommand->SetManagerGizmo(ManagerGizmo);
00175 ManagerCommand->SetManagerMenu(ManagerMenu);
00176 ManagerCommand->SetManagerInterface(ManagerInterface);
00177 ManagerCommand->SetManagerConsole(ManagerConsole);
00178 ManagerCommand->SetManagerSound(ManagerSound);
00179 ManagerCommand->SetManagerSpirit(ManagerSpirit);
00180
00181 ManagerMap->SetManagerTexture(ManagerTexture);
00182
00183 ManagerEntite->SetManagerCollision(ManagerCollision);
00184 ManagerEntite->SetManagerPVS(ManagerPVS);
00185 ManagerEntite->SetManagerTexture(ManagerTexture);
00186
00187 ManagerParticuleSystem->SetManagerCollision(ManagerCollision);
00188 ManagerParticuleSystem->SetManagerPVS(ManagerPVS);
00189 ManagerParticuleSystem->SetManagerTexture(ManagerTexture);
00190
00191 ManagerGizmo->SetManagerCollision(ManagerCollision);
00192 ManagerGizmo->SetManagerPVS(ManagerPVS);
00193
00194 ManagerLight->SetManagerCollision(ManagerCollision);
00195 ManagerLight->SetManagerPVS(ManagerPVS);
00196
00197 ManagerCam->SetManagerCollision(ManagerCollision);
00198 ManagerCam->SetManagerPVS(ManagerPVS);
00199
00200 ManagerOutPut->SetManagerWindow(ManagerWindow);
00201 ManagerOutPut->SetManagerPVS(ManagerPVS);
00202 ManagerOutPut->SetManagerCam(ManagerCam);
00203 ManagerOutPut->SetManagerAnim(ManagerAnimation);
00204 ManagerOutPut->SetManagerCollision(ManagerCollision);
00205 ManagerOutPut->SetManagerFog(ManagerFog);
00206 ManagerOutPut->SetManagerCommand(ManagerCommand);
00207 ManagerOutPut->SetManagerMenu(ManagerMenu);
00208 ManagerOutPut->SetManagerInterface(ManagerInterface);
00209 ManagerOutPut->SetManagerConsole(ManagerConsole);
00210 ManagerOutPut->SetManagerMap(ManagerMap);
00211
00212 ManagerInterface->SetManagerTexture(ManagerTexture);
00213 ManagerInterface->SetManagerWindow(ManagerWindow);
00214
00215 ManagerConsole->SetManagerWindow(ManagerWindow);
00216 ManagerConsole->SetManagerTexture(ManagerTexture);
00217
00218
00219
00220
00221 ManagerEntite->RecordToManagerPVS();
00222 ManagerParticuleSystem->RecordToManagerPVS();
00223 UnGuard
00224 }
00225
00226 void InitGlExtension(void)
00227 {
00228 Guard(void InitGlExtension(void))
00229 char *extList = (char *) glGetString(GL_EXTENSIONS);
00230
00231
00232 if(extList && strstr(extList,"GL_EXT_compiled_vertex_array"))
00233 {
00234 #ifdef UNIX_SRC
00235
00236 #else
00237 glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC) wglGetProcAddress("glLockArraysEXT");
00238 glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC) wglGetProcAddress("glUnLockArraysEXT");
00239 #endif
00240 }
00241
00242 UnGuard
00243 }
00244
00245 void InitManager(void)
00246 {
00247 Guard(void InitManager(void))
00248 ManagerWindow->GlutCallBack=&SetGlutCallBack;
00249 ManagerOutPut->Init();
00250 ManagerEntite->Init();
00251 ManagerCam->Init();
00252 ManagerCommand->Init();
00253 ManagerConsole->Init();
00254 ManagerTexture->Init();
00255 ManagerSound->Init();
00256
00257 UnGuard
00258 }
00259
00260 void SetGlutCallBack(void)
00261 {
00262
00263
00264
00265 if(ManagerInputGLUT->IsKeyboard())
00266 {
00267 glutKeyboardFunc(keyboard);
00268 glutKeyboardUpFunc(keyboardup);
00269 glutSpecialFunc(spekeyboard);
00270 glutSpecialUpFunc(spekeyboardup);
00271 }else
00272 {
00273 glutKeyboardFunc(NULL);
00274 glutKeyboardUpFunc(NULL);
00275 glutSpecialFunc(NULL);
00276 glutSpecialUpFunc(NULL);
00277 }
00278
00279
00280
00281 if(ManagerInputGLUT->IsMouse())
00282 {
00283 glutMouseFunc(Mouse);
00284 glutEntryFunc(Focus);
00285 glutMotionFunc(MotionFunc);
00286 glutPassiveMotionFunc(PassiveMotionFunc);
00287 }
00288 else
00289 {
00290 glutMouseFunc(NULL);
00291 glutEntryFunc(NULL);
00292 glutMotionFunc(NULL);
00293 glutPassiveMotionFunc(NULL);
00294 }
00295
00296
00297
00298 if(ManagerInputGLUT->IsJoystick())
00299 {
00300 }
00301 else
00302 {
00303 }
00304
00305
00306
00307 if(ManagerInputGLUT->IsSpaceBall())
00308 {
00309 glutSpaceballMotionFunc(SpaceballMotionFunc);
00310 glutSpaceballRotateFunc(SpaceballRotateFunc);
00311 }
00312 else
00313 {
00314 glutSpaceballRotateFunc(NULL);
00315 glutSpaceballMotionFunc(NULL);
00316 }
00317
00318
00319
00320 if(ManagerInputGLUT->IsTablet())
00321 {
00322 glutTabletMotionFunc(TabletMotionFunc);
00323 glutTabletButtonFunc(TabletButtonFunc);
00324 }
00325 else
00326 {
00327 glutTabletMotionFunc(NULL);
00328 glutTabletButtonFunc(NULL);
00329 }
00330
00331
00332
00333 glutDisplayFunc(display);
00334 glutIdleFunc(display);
00335 glutReshapeFunc(reshape);
00336
00337
00338
00339 ManagerConsole->Init();
00340 ManagerEntite->MakeGlListForAll();
00341 InitBasicObjectList();
00342 ManagerOutPut->Init();
00343 ManagerInterface->Reset();
00344 ManagerInterface->init();
00345
00346 }
00347
00348 void keyboard(unsigned char key,int x,int y){ManagerInputGLUT->Key(key,x,y);}
00349 void keyboardup(unsigned char key, int x, int y){ManagerInputGLUT->KeyUp(key,x,y);}
00350 void spekeyboard(int key,int x,int y){ManagerInputGLUT->KeySpe(key,x,y);}
00351 void spekeyboardup(int key, int x, int y){ManagerInputGLUT->KeySpeUp(key,x,y);}
00352 void Mouse(int button, int state, int x, int y){ManagerInputGLUT->Mouse(button,state,x,y);}
00353 void Focus(int state){ManagerInputGLUT->Focus(state);}
00354 void MotionFunc(int x, int y){ManagerInputGLUT->MouseMotion(x,y);}
00355 void PassiveMotionFunc(int x, int y){ManagerInputGLUT->MousePassiveMotion(x,y);}
00356 void SpaceballMotionFunc(int x, int y, int z){ManagerInputGLUT->SpaceballMotion(x,y,z);}
00357 void SpaceballRotateFunc(int x, int y, int z){ManagerInputGLUT->SpaceballRotate(x,y,z);}
00358 void TabletMotionFunc(int x, int y){ManagerInputGLUT->TabletMotion(x,y);}
00359 void TabletButtonFunc(int button, int state, int x, int y) {ManagerInputGLUT->TabletButton(button,state,x,y);}
00360 void display(void){ManagerOutPut->DrawScene();}
00361 void reshape(int w,int h){ManagerOutPut->Reshape(w,h);}
00362
00363
00364