Game Engine Architecture 8

1、Differences across Operating Systems

  • UNIX uses a forward slash (/) as its path component separator, while DOS and older versions of Windows used a backslash (\) as the path separator. Recent versions of Windows allow either forward or backward slashes to be used to separate    path components, although some applications still fail to accept forward slashes.

  • Some filesystems consider paths and filenames to be case-sensitive (like UNIX and its variants), while others are case-insensitive (like Windows).

  • UNIX and its variants don’t support volumes as separate directory hierarchies.

  • On Microsoft Windows, volumes can be specified in two ways. A local disk drive is specified using a single letter followed by a colon (e.g., the ubiquitous C:). A remote network share can either be mounted so that it looks like a local disk, or it can be referenced via a volume specifier consisting of two backslashes followed by the remote computer name and the name of a shared directory or resource on that machine (e.g., \\some-computer\some-share).

2、Search Paths

  A search path is a string containing a list of paths, each separated by a special character such as a colon or semicolon, which is searched when looking for a file. 

3、Basic File I/O

  Every file I/O API requires data blocks known as buffers to serve as the source or destination of the bytes passing between the program and the file on disk. We say a file I/O API is buffered when the API manages the necessary input and output data buffers for you. With an unbuffered API, it is the responsibility of the programmer using the API to allocate and manage the data buffers.

  Buffered API 由API来管理buffer,Unbuffered API 由非API来管理。

    Game Engine Architecture 8

  Game Engine Architecture 8

4、The Resource Manager

  Every resource manager is comprised of two distinct but integrated components. One component manages the chain of offline tools used to create the assets and transform them into their engine-ready form. The other component manages the resources at runtime, ensuring that they are loaded into memory in advance of being needed by the game and making sure they are unloaded from memory when no longer needed.

5、OGRE’s Resource Manager System

  OGRE lacks any kind of offline resource database

6、Resource Dependencies and Build Rules

  If the format of the files used to store triangle meshes changes, for instance, all meshes in the entire game may need to be reexported and/or rebuilt. Some game engines employ data formats that are robust to version changes. For example, an asset may contain a version number, and the game engine may include code that “knows” how to load and make use of legacy assets. The downside of such a policy is that asset files and engine code tend to become bulky. When data format changes are relatively rare, it may be better to just bite the bullet and reprocess all the files when format changes do occur.

  给每个 asset format  一个 version,从而保证老的 format 能够被兼容。

7、Stack-Based Resource Allocation

  On Hydro Thunder, Midway used a double-ended stack allocator. The lower stack was used for persistent data loads, while the upper was used for temporary allocations that were freed every frame. Another way a double ended stack allocator can be used is to ping-pong level loads. Such an approach was used at Bionic Games, Inc. for one of their projects. The basic idea is to load a compressed version of level B into the upper stack, while the currently active level A resides (in uncompressed form) in the lower stack. To switch from level A to level B, we simply free level A’s resources (by clearing the lower stack) and then decompress level B from the upper stack into the lower stack. Decompression is generally much faster than loading data from disk, so this approach effectively eliminates the load time that would otherwise be experienced by the player between levels.

7.1、Sectioned Resource Files

  A typical resource file might contain between one and four sections, each of which is divided into one or more chunks for the purposes of pool allocation as described above. 

  1)One section might contain data that is destined for main RAM,

  2)while another section might contain video RAM data.

  3)Another section could contain temporary data that is needed during the loading process but is discarded once the resource has been completely loaded.

  4)Yet another section might contain debugging information.

8、Handling Cross-References between Resources

  1)GUIDs as Cross-References

  2)Pointer Fix-Up Tables

    Another approach that is often used when storing data objects into a binary file is to convert the pointers into file offsets.

  Game Engine Architecture 8

8.1、Windows Message Pumps  

while (true)
{
    // Service any and all pending Windows messages.
    MSG msg;
    while (PeekMessage(&msg, nullptr, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    
    // No more Windows messages to process -- run one
    // iteration of our "real" game loop.
    RunOneIterationOfGameLoop();
}
View Code

相关文章:

  • 2022-02-28
  • 2022-01-30
  • 2021-08-06
  • 2021-09-25
  • 2021-12-14
  • 2021-06-27
  • 2021-08-23
  • 2021-08-12
猜你喜欢
  • 2021-07-28
  • 2021-09-16
  • 2022-02-24
  • 2021-10-24
  • 2021-10-10
  • 2021-10-10
  • 2021-08-11
相关资源
相似解决方案