Game Development Reference
In-Depth Information
Chapter 1
Plug-in-based Asset Compiler
Architecture
Nicu¸or Nedelcu
From the beginning of the game creation process to the end, developers have two things to worry about: code and
data (game art and other type of assets). In the past, data was formatted specifically for the one platform the game
was about to run on. Now we have to format the same data for many different platforms. In order to satisfy this new
requirement, we need access to source assets that can be compiled into a variety of targets. We also have more work to
do, since special care has to be taken for each format.
However, there are ways to reduce the pain involved in this more complex pipeline. To make this process as
streamlined as possible, I propose a plug-in-based asset compiler that can load converter plug-ins for the given asset
types. The plug-in-based nature of the compiler can also help developers create their own plug-ins for any other
special asset types they need. In this chapter, I describe how to set up and code such a compiler using an example of a
texture converter/compiler plug-in. The platform you are going to use is Windows and the language is C++; with few
modifications regarding the OS specifics, the code should work on other environments and can even be adapted to
other languages.
Design
The underlying plug-in loading system can be a “traditional” dynamic-link library (DLL 1 ) loading and querying for
the proper interfaces. You will be using the Windows DLL API, but the code is almost the same for other operating
systems. The DLL can export a special function that will return an instance of the converter interface (see Listing 1-1).
The same goes for other platforms (OS/X, Linux), using their specific dynamic link library API implementations.
Listing 1-1. Creating the Asset Converter Instance Using the Exported DLL Function
DLL_EXPORT AssetConverter* createAssetConverter();
The interface of the asset converter looks like Listing 1-2.
.
 
Search WWH ::




Custom Search