top of page

Controls: Esc - To quit game

I chose a class to encapsulate the required data. It was a personal bias choice.

I made two files Mesh.[platform].cpp and added a RenderMesh() function in both of them. Then I copied the required blocks of code.

 

For D3D:

  1. Bind a specific vertex buffer to the device as a data source

  2. Specify what kind of data the vertex buffer holds

  3. Render triangles from the currently-bound vertex buffer

For OpenGL:

  1. Bind a specific vertex buffer to the device as a data source

  2. Render triangles from the currently-bound vertex buffer

Also I created a CommonData class and copied the required common variables for D3D in that class. OpenGL had nothing in common except _sVertex struct which is common for both platforms.

I made the CommonData class use the singleton paradigm.

The draw mesh submits the mesh to be drawn to the renderer. The mesh object encapsulates the required data and calls appropriate functions as per the configuration.

The purpose of this assignment was to make platform agnostic mesh interface with platform dependent implementation.

So I started by copying code for one platform and populating it in the required cpp. I took some time to figure out what was necessary and what was not. I read through the whole implementation in Graphics.[platform].cpp and cherry picked the code.

Then I created the required virtual function and setup the required calls in myGame.cpp. Then I made a common data class to hold common data.

Afterwards I wrote the agnostic code that was necessary in each RenderFrame() function to call the mesh renderer.

I also took care not to call cleanup when initialization failed when the assets are not built.

MESH ENCAPSULATION

bottom of page