Skip navigation

File Link(.exe)


Click Me

Objective


This assignment has two main objectives. The first one is to render a triangle with colors on the screen and understand the knowledge of it. Besides it, we need to add Lua into the project and replace the old assets builder with the new lua version.

Colored Triangle


Colored Triangle

That’s the triangle that I rendered. In order to make it looks not like a “Hello World”, I asked my artist friend to help me pick colors :D.

 

Capture1

 

It’s very simple to create a colored triangle like this, but a little background knowledge is still needed to understand this. As the minimum unit in the rendering process, a triangle is formed by 3 vertices. a vertex basically is a variable to indicate the position information, (x,y) in 2D for example. But it as well as is a container for more extended data for rendering, such as color, normal vector, texture coordinate and weight. In this case, I added color data for my triangle. As we can see in the PIX, a buffer that contains the vertices of the triangle is passed when the Draw function is called. Each vertex has information about it’s position and color.  And each color data is indicated as ARGB model and is stored in a 16-bit memory space.

Build assets with Lua


Lua is a very useful language to build the script system in game development. Basically, In the game code, we create functions in the format that Lua engine can recognize and register them to Lua engine, and then call the functions that we registered in the script to implement what we want.  In this assignment, Instead of implementing every details in the cpp file, the AssetsBuilder publics several core functions ( such as copyfile ) to the Lua engine, and created lua script for the rest implementations.

time estimation


Reading and searching — 1 h
Setting up solution / Coding / Debugging — 1 h
Bug Fixing — 0.5 h
Writing blog — 1 h
Total — 3.5 h

Leave a Reply