Game Engineering II Assignment 2
Last week, Tony talked about the graphics part of our engine and how it was separated using different source files to contain individual platform-specific codes.
So, I followed the instructions and separated the Graphic.cpp into a cMesh and cEffect. In the beginning, I only needed to create a mesh class that only defined the data structure of the mesh. So, I chose the preprocessor to split the platform-specific codes because the class has more common codes than platform-specific codes. However, I realized I should also put functions that related to the mesh class, so it will definitely not suit preprocessor-only. Ultimately, I chose a hybrid way that creates three source files, cMesh.cpp, cMesh.gl.cpp, and cMesh.d3d.cpp while using preprocessors in the cMesh.cpp to make some platform-specific functions universal.
I doubted if creating a cEffect.cpp was necessary for the effect class because it only shares a few common codes. In the last lesson this Wednesday, Tony told us it would be critical to have three source files because we inevitably do this after the engine grows more complicated. That makes a lot of sense.
After that, I had a hard time showing the tetragon on the screen. Even if I double-checked the codes and mesh file, I still can't find a reason. Because I used an indices list and vertex list to represent triangles, I created a function that converts the indices list and vertex list into a vertex array, and it didn't work either. Finally, I chose the ultimate solution: deleting everything new and adding one thing at a time. Then I realized one thing: the normal vector does matter in the 2D game. A triangle with a negative normal vector won't show on the screen. Damn, I should realize it earlier.
The remaining differences are between Graphics.d3d.cpp and Graphics.gl.cpp are render initialization, and buffer creatingI think all of them can combine into a class called cRender and one function collection namespace called Buffer.
After that, everything goes smoothly and nicely. There are some screenshots of the requirements below.
Controls:
Press Enter to slow the time by 66% and release it to return to the normal rate.
Press ESC to exit the game.
Oscar Zuo
U1418006