I'm a gameplay programmer
focused on developing
engaging and unique experiences!

My Resume Learn more

Assignment 04

This assignment had us move all mesh and effect instantiation into another project outside of Graphics. The target project was our own game project, where we can create different meshes with different effects without touching the Graphics code at all! The game project is also an application that takes real-time input so I've also added interactivity to turn of a mesh and change an effect by pressing F1 and F2. Try it out here!

This is what the game looks like with no input in a default state:

This is what the game looks like when you hold F2, the blue triangle uses a different effect that matches the white triangle.

This is what the game looks like when you hold down F1, the white triangle becomes missing.

Submitting Data for Caching

One process that makes this possible is the submission of the background color, meshes, and effects we want from the game to graphics. This submission process uses caching in the background so that we can multithread our game and graphics. The game thread submits colors, meshes, and effects it wants for frame N while the graphics thread uses cached data to render frame N-1.

Another change that had to be made for this was adding reference counting to the meshes and effects so that ownership could be represented correctly over multiple threads. Something that had to be accounted for was when to increment reference counts and especially when to decrement them as the Graphics and Game threads each have different times when that needs to happen.

The code for the background color is just one simple line in the SubmitDataToBeRendered function in cMyGame.cpp.

void eae6320::cMyGame::SubmitDataToBeRendered(const float i_elapsedSecondCount_systemTime, const float i_elapsedSecondCount_sinceLastSimulationUpdate)
{
	eae6320::Graphics::SubmitBackgroundColor(0.0f, 1.0f, 0.0f, 1.0f);
}

Submitting meshes and effects are also boiled down to a single line:

void eae6320::cMyGame::SubmitDataToBeRendered(const float i_elapsedSecondCount_systemTime, const float i_elapsedSecondCount_sinceLastSimulationUpdate)
{
        eae6320::Graphics::SubmitMeshAndEffect(s_Mesh1, s_Effect1);
}

Memory Usage

My mesh size was 40 bytes for Direct3D and 24 bytes for OpenGL. These sizes are notably larger from Assignnment 03 due to us adding reference counting to the class.

My effect size was 48 bytes for Direct3D and 20 bytes for OpenGL. The same effect happened here with reference counting.

My sDataRequiredToRenderAFrame struct was 200 bytes for Direct3D and 180 bytes for OpenGL. This is made out of storing 4 floats for the background color, 2 pointers to a mesh and effect array, and a counter for the length of the array. However, the length could be calculated from the array itself.

No Comments Yet.

Leave a comment