Game Engine Architecture
319 // Measure the duration. U64 tEnd = readHiResTimer(); U32 dtCycles = static_cast<U32>(tEnd – tBegin); // Now use or ca ...
320 7. The Game Loop and Real-Time Simulation of the exponent (see Section 3.2.1.4). Small magnitudes require only a few bits, l ...
321 to continue, this can lead to a measured frame time many seconds, or even minutes or hours in duration! Clearly if we allow ...
322 7. The Game Loop and Real-Time Simulation 7.5.6. A Simple Clock Class Some game engines encapsulate their clock variables in ...
323 public: // Call this when the game first starts up. static void init() { s_cyclesPerSecond = (F32)readHiResTimerFrequency(); ...
324 7. The Game Loop and Real-Time Simulation void setPaused(bool isPaused) { m_isPaused = isPaused; } bool isPaused() const { r ...
325 CPUs. Moore’s Law , which predicts an approximate doubling in transistor counts every 18 to 24 months, still holds true. But ...
326 7. The Game Loop and Real-Time Simulation Main RAM (512 MB) PowerPC Core 0 PowerPC Core 1 PowerPC Core 2 L1 Data L1 Instr L1 ...
327 The SPUs never read directly from main RAM. Instead, a direct memory access (DMA) controller allows blocks of data to be cop ...
328 7. The Game Loop and Real-Time Simulation 3D math library, without having to modify much if any of the calling code (except ...
329 able processing resources. (On the Xbox 360, N should probably be 3 or 6, because the console has three cores with two hardw ...
330 7. The Game Loop and Real-Time Simulation 7.6.5. Jobs One problem with the multithreaded approach is that each thread repres ...
331 As shown in Figure 7.8, the fact that jobs are relatively fi ne-grained and independent of one another helps to maximize pro ...
332 7. The Game Loop and Real-Time Simulation while (true) // main game loop { // ... // Cast a ray to see if the player has lin ...
333 // ... } In many instances, asynchronous code can kick off a request on one frame, and pick up the results on the next. In t ...
334 7. The Game Loop and Real-Time Simulation 7.7.1. Client-Server In the client-server model, the vast majority of the game’s l ...
335 U64 tBegin = readHiResTimer(); while (true) // main game loop { // Run the server at 50 ms intervals. dtServer += dtReal; if ...
336 7. The Game Loop and Real-Time Simulation ject, over which the local machine has authority and a “proxy ” version that conta ...
337 TranslateMessage (&msg); DispatchMessage (&msg); } // Measure real delta time in milliseconds. do { newtime = Sys_Mi ...
338 7. The Game Loop and Real-Time Simulation // Run a server frame. SV_Frame (msec); // Run a client frame. CL_Frame (msec); // ...
«
13
14
15
16
17
18
19
20
21
22
»
Free download pdf