Game Engine Engineering Assignment - 3
- Vikram Venkatesh

- Sep 17, 2020
- 2 min read
Updated: Sep 25, 2023
This assignment was pretty much a smooth continuation of the previous assignment. It started out with addressing the questions left, from the previous one, which was how to create a platform independent Graphics class.
Now the few things remaining in the class which needed to go, were the views in the D3D version and the clear functions. I thought that placing these in the context class made the most sense, given most platform dependent initialization took place in that class. I put the platform specific stuff into the corresponding context.cpp files it worked out spectacularly for me and with an already clean implementation of my mesh class, I was able to shift all platform dependent code from Graphics.cpp. Great Success!

Since the 'render target clearing' was happening through the context class, Graphics.cpp is now completely independent.
Now let’s change the rendering method to indexed mode. Indexing saves a lot of memory given the number of floats its taking, every vertex. By indexing, we only have the minimum amount of vertices and an index array consisting of uint16_t types. I removed the AddTriangle() method and replaced it with an AddVertex and AddTriangleIndex() method to fill-up the vertex and index arrays.
I was also able to fix a convention for indexing(Left handed D3D for me) and added a platform dependent implementation of AddTriangleIndex() which will automatically convert to the left handed system.
The problem now I was left with was to have multiple meshes and effects and I’m kinda stuck on that a bit. With my current code, I think it overwrites a previous mesh, making only one mesh appear at a time. I have some ideas of overcoming that problem, but ran short on time here. Would definitely update my solution as soon as possible
*Edit: I was able to solve it by making some of the existing static variables like the vertex and index buffers, as private variables of the class, hence making every mesh have its own buffers instead of overwriting them. Behold this glorious scene with multiple meshes and effects bound to them:

Current sizeof(Mesh) = 72 and sizeof(Effect) = 80.
Also I was able to complete the optional objective of animating the background by passing the g_elapsedSecondCount_simulationTime variable as a parameter in the context clear background method.











Comments