Assignment 3
1. Show a screenshot of your game running.
2. Explain how you made Graphics.cpp platform-independent:
​Except the cMesh and cEffect class added for the previous assignment, a new class cView ​was added. For both platforms, it deals with clearing background and swapping the back buffer to front. For Direct3D, it deals with initialization and cleaning up member variables.

Since the clearView and SwapBackBuffer is significantly different for two platforms, I separated the implementation codes into cView.gl.cpp and cView.d3d.cpp.
For OpenGL, the cView does not need member variables, and thus does not need to implement InitializeViews and CleanUp. Therefore, in cView.gl.cpp, these two functions dirrectly returns cResult::Success.​​​
3. Show us your code in the Graphics.cpp file that clears the back buffer color:
First initialize the s_View.

Then use the interface to clear the view. After drawing the mesh, swap the back buffer to front.

4. Show a screenshot of your game with a clear color (i.e. background) other than black:
As shown in the recording of the game running (Q1), the background color is blue. The screenshot below shows a clear color from the graphics debugger.

5. Show code from your Graphics.cpp file that initializes an effect:
The constructor takes two arguments: the vertex shader's name and the fragment shader's name.


6. Tell us how much memory a single effect takes up in both platforms. Is there any way to make it smaller?
For Direct3D, a single effect takes up 64 bytes. For OpenGL, it takes up 24 bytes. Codes below are data stored for cEffect and cRenderState. I don't think it can be smaller. Actually it can be smaller by deleting two char*. I didn't realize at that time. I corrected it in the next assignment.


For Direct3D (64bit), the size of cEffect consists of:
2 pointers to cShader: 2 * 8 = 16
cRenderState:
3 pointers + 1 uint8_t (with padding) = 3 * 8 + 1 * 1 + (padding) 7 = 32
2 pointers to char: 2 * 8 = 16
In total 16 + 32 + 16 = 64 bytes.
For OpenGL (32bit), the size of cEffect consists of:
2 pointers to cShader: 2 * 4 = 8
cRenderState:
1 uint8_t (with padding) = 1 * 1 + (padding) 3 = 4
2 pointers to char: 2 * 4 = 8
1 GLunit: 4
In total 8 + 4 + 8 + 4 = 24 bytes.
7. Show code from your Graphics.cpp file that initializes a mesh:
The constructor takes four arguments: the triangle count, the vertex count per triangle, the vertex data array, and the indice array.


8. Tell us how much memory a single mesh takes up in both platforms. Is there any way to make it smaller?
For Direct3D, a single mesh takes up 48 bytes. For OpenGL, it takes up 28 bytes. I don't think it can be smaller.

For Direct3D (64bit), the size of cMesh consists of:
2 unsigned int: 2 * 4 = 8
1 pointer to m_vertexData array: 8
1 pointer to m_indices array: 8
1 pointer to vertex format: 8
2 pointers to D3D buffer: 2 * 8 = 16
In total 8 + 8 + 8 + 8 + 16 = 48 bytes.
For OpenGL (32bit), the size of cMesh consists of:
2 unsigned int: 2 * 4 = 8
1 pointer to m_vertexData array: 4
1 pointer to m_indices array: 4
3 GLuint: 3 * 4 = 12
In total 8 + 4 + 4 + 12 = 28 bytes.