265 | | = Engine Summary = |
266 | | |
267 | | This is basically the Main function a few twists and turns aside. |
268 | | |
269 | | MICROLOG() |
270 | | logs current activity, which is displayed after a crash. |
271 | | oglCheck() |
272 | | {{{ |
273 | | reports any errors that have occurred in OpenGL since the last call. |
274 | | }}} |
275 | | |
276 | | '''INIT''' |
277 | | |
278 | | I18n::!LoadLanguage(NULL); //Loads The Relevant Language Pack |
279 | | |
280 | | !InitVfs(argc?argv[0]:NULL); // Vfs creates a Virtual File System |
281 | | // Protecting the system & allowing access to archived files |
282 | | |
283 | | CConsole() //Create Console (also see !InitPs) |
284 | | |
285 | | SDL_Init(); //See SDL library |
286 | | |
287 | | !InitScripting(); //Init the script engine & init the //induvidual scripts |
288 | | |
289 | | !InitConfig(argc, argv); //Load Config Files "config/system.cfg" |
290 | | {{{ |
291 | | //and Parse Commandline Arguments |
292 | | }}} |
293 | | |
294 | | new CGUI; //Init GUI system |
295 | | |
296 | | !InitPs(); //This seems to be a miscellaneous set up. |
297 | | {{{ |
298 | | //Setup Console font |
299 | | //setup language |
300 | | //load hot keys |
301 | | //Set up Some GUI stuff |
302 | | }}} |
303 | | |
304 | | !InitRenderer(); //Create the following And set up lights |
305 | | ? new CTextureManager; //Containers for art resources, |
306 | | {{{ |
307 | | new CMaterialManager; //with caching and on-demand loading |
308 | | new CmeshManager; //where appropriate |
309 | | new CSkeletonAnimManager; |
310 | | new CObjectManager; |
311 | | new CUnitManager; |
312 | | new CbaseEntityCollection; |
313 | | }}} |
314 | | |
315 | | new CPathfindEngine; //Interface to Path Find Engine |
316 | | new CSelectedEntities; //Selected Entities |
317 | | new CMouseoverEntities; //Mouse over Entities |
318 | | new CSessionManager; //Network Object |
319 | | new CGameAttributes; //Contains The Players info Names etc. |
320 | | {{{ |
321 | | //and Number of players |
322 | | }}} |
323 | | |
324 | | |
325 | | //Add Handlers |
326 | | //These allow an object to receive message from the system I.e. Key presses, similar to the way the windows message loop works. |
327 | | in_add_handler(game_view_handler); |
328 | | in_add_handler(interactInputHandler); |
329 | | in_add_handler(conInputHandler); |
330 | | in_add_handler(hotkeyInputHandler); |
331 | | in_add_handler(gui_handler); |
332 | | in_add_handler(handler); |
333 | | |
334 | | |
335 | | g_GUI.!SendEventToAll("load"); //tell all GUI objects to load up |
336 | | !RenderNoCull(); //Forces engine to load up anything that�s needed |
337 | | {{{ |
338 | | //By drawing everything |
339 | | }}} |
340 | | |
341 | | '''MAIN LOOP "Frame()"''' |
342 | | |
343 | | !MusicPlayer.update(); //Call vorbis Music Library |
344 | | |
345 | | in_get_events(); //Read Keyboard/Mouse events |
346 | | |
347 | | g_SessionManager.Poll(); //Call Networking Code |
348 | | |
349 | | g_GUI.!TickObjects(); //Call GUI Code |
350 | | |
351 | | |
352 | | g_Game->Update(!TimeSinceLastFrame); |
353 | | // Update all Entities and Perform Game simulation |
354 | | |
355 | | if (!g_FixedFrameTiming) |
356 | | g_Game->!GetView()->Update(float(!TimeSinceLastFrame)); |
357 | | {{{ |
358 | | // Update Camera position view |
359 | | }}} |
360 | | |
361 | | //update for Mouse and selected Entities |
362 | | g_Mouseover.update( !TimeSinceLastFrame ); |
363 | | g_Selection.update(); |
364 | | |
365 | | |
366 | | snd_update(pos, dir, up) ? g_Game->!GetView()->!GetCamera(); // SOUND |
367 | | {{{ |
368 | | // Pass camera position to Open AL for 3d positional Sound |
369 | | }}} |
370 | | |
371 | | g_Console->Update(!TimeSinceLastFrame); // Call Console Code |
372 | | |
373 | | Render(); // Render Screen and display (see below) |
374 | | SDL_GL_SwapBuffers(); |
375 | | |
376 | | '''RENDER''' |
377 | | |
378 | | g_Renderer.!BeginFrame(); |
379 | | {{{ |
380 | | // calculate coefficients for terrain and unit lighting |
381 | | }}} |
382 | | m_ShadowBound.!SetEmpty(); //clear shaddows |
383 | | |
384 | | g_Game->!GetView()->Render(); //Create List of polys to draw. |
385 | | CGameView::!RenderTerrain(m_pWorld->!GetTerrain()); |
386 | | CGameView::!RenderModels(m_pWorld->!GetUnitManager()); |
387 | | |
388 | | g_Renderer.!FlushFrame(); //DO ACUTAL RENDER |
389 | | � g_TransparencyRenderer.Sort(); |
390 | | !RenderShadowMap(); //Create Shaddow Map |
391 | | {{{ |
392 | | glClear() |
393 | | }}} |
394 | | !RenderPatches(); //Acutally render Patches |
395 | | !RenderModels(); //Acutally render Models |
396 | | |
397 | | !ApplyShadowMap(); //Render Shaddows onto ground |
398 | | g_PlayerRenderer.Render(); |
399 | | g_TransparencyRenderer.Render(); |
400 | | //Render any Defered Tranparencys |
401 | | |
402 | | //Clear all lists |
403 | | g_TransparencyRenderer.Clear(); |
404 | | g_PlayerRenderer.Clear(); |
405 | | {{{ |
406 | | CPatchRData::ClearSubmissions(); |
407 | | CModelRData::ClearSubmissions(); |
408 | | }}} |
409 | | |
410 | | g_Mouseover.renderSelectionOutlines(); |
411 | | g_Selection.renderSelectionOutlines(); |
412 | | |
413 | | // overlay mode //Front end stuff. |
414 | | glOrtho(0.f, (float)g_xres, 0.f, (float)g_yres, -1.f, 1000.f); |
415 | | g_GUI.Draw(); |
416 | | CFont font("console"); |
417 | | font.Bind(); |
418 | | g_Console->Render(); |
419 | | g_Mouseover.renderOverlays(); |
420 | | g_Selection.renderOverlays(); |
421 | | cursor_draw(g_CursorName); |
422 | | g_Renderer.!EndFrame(); |
423 | | |