Assignment 02

The assignment consisted of two parts; integrating Lua into the project and drawing a second triangle in order to form a square. We already had used Lua in the past, in EAE 6310, to process input for the game objects in the engine. Now we use it more extensively in our build pipeline. Currently Lua replaces some of the C++ code from our Asset Builder project, and calls some predefined C functions form the project.
The image shows the desired result in Direct3D. Even though the output is similar for OpenGL, the way we represent vertices and primitives (triangles) is completely opposite. Direct3D follows the Left hand orientation while OpenGL follows the Right hand orientation. Previously we had a single triangle, but now we have two triangles making a square (actually a rectangle depending on the resolution). I was stuck at a point in adding new vertices for the second triangle in OpenGL. I did add new values to the buffer in the code but missed the line where we write into the internal buffer. This mistake stopped me from getting the second triangle rendered on the screen. This forced me to read through most of the code in both Direct3D and OpenGL files. This will now help me in the next assignment.


The Lua script builds all the authored assets in the Assets folder and copies them to the data folder in the Game directory. The script is accessed from the ScriptDir macro. So we create a new folder called Scripts in the main directory. In Visual Studio, instead of adding it to a specific project, I created a separate solution folder. I do this because we will change the way we are building assets later in the development process. I shouldn’t have to reload any project for making changes in a script which is supposed to be independent of the engine. Also it is better to have all the scripts in a central point, instead of having them separated in different projects.

Building Assets

  • The environment variables AuthoredAssetsDir and BuiltAssetsDir are computed, by expanding the corresponding macros in the solution property pages.
  • Some processing is done to convert from source (Authored Assets) to target (Built Assets). Currently we are just simply copying files from one to the other.
  • The source files are in a format which are easy for authoring.
  • The target files are in a format which is useful for real time rendering.

Role of AssetBuilder and Lua script

  • The Lua file’s goal is to build assets as per the process above. It contains the code to do so.
  • The Asset Builder project, with help of static library Lua.lib, aims to interpret the script file and execute it. It also contains some helper functions required in the BuildAssets.lua file.
  • After building the project, AssetBuilder.exe is created.
  • Then BuildAssets project executes the created exe file in its custom build step.


Some of the strengths of Lua as a scripting language are:

  • Small code base and a small library.
  • Compiled on anything with a ANSI C compiler.
  • Fast as compared to other scripting languages.
  • Embedded and Extensible language with easy interface to/from C/C++.
  • Well Documented.
  • Simple Syntax.

Lua in EAE6320

What Lua provides to the game can’t be offered by any other scripting language. We use Lua in this course so that we can learn more about it and its usage. Lua is popular in medium sized games as the advantages listed above can be used to the full extent. Smaller games may not require the use of a separate scripting language and all the work can be handled by the primary coding languages. Bigger games and studios can afford scripting languages which use CPU and memory more extensively and can do much advanced things than what Lua can.

Time Estimate

Reading: 1 hours
Coding: 3 hours
Testing and Fixes: 1 hour
Writeup: 1 hour