Write Up 06

 

 

 

 

Game in default state:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Game with texture changes:

Controls:

Press Escape to quit the application.

Press the right arrow key to switch the texture of the two largest sprites.

The main objective of Assignment06 was to build textures and assign them to different sprites and effects while using keyboard driven and time driven events.

In order to calculate the UVs automatically without the user having to specify them in this case is simple because the whole width and height of the texture is being used. Had we needed to only show a specific area of the texture, then UVs would have to be specified by the user.

I wrote two functions for the Sprite class:

void CalculateXYRemainingVertices(float centerPosX, float centerPosY, float width, float height,eae6320::Graphics::VertexFormats::sSprite vertexData[]);

 

void CalculateUVRemainingVertices(eae6320::Graphics::VertexFormats::sSprite vertexData[]);

Each function abstracts the platform differences for calculating the XY components as well as the UVs of each sprite. In the definition of each function, I added small calculation differences of the XY components and the UVs that are different between D3D and OpenGL. I separated all the U components and checked the x component value of the second and third vertices against the width of the sprite to determine if the vertices were of U value 0 or 1. For the platform differences of the V component, I separated the V component of the second and third vertices because they had the same value on both platforms. The first and fourth vertices are within the CalculateUVRemainingVertices() function because their V component has a different value per platform. To summarize, these function hold the platform specific differences for calculating XY components and UV components while the code that fills the vertex buffer with the XY values and UV values is the same for both D3D and OpenGL platforms.

The handle does not provide a way to increment the reference count because a handle is in charge of returning a single pointer to an asset when it is initially loaded by the Load() function. We do not want to load and asset every time it is needed which is why in the Graphics project the reference count of the pointer to the texture is incremented and not the handle.

The handle’s provided way to decrement a reference count is used because ultimately it is up to the handle’s manager to release the pointer to the asset once it is no longer needed by the game program. If the reference count is decremented otherwise, the asset (the texture) will not be released and destroyed and the clean up of the handle will not happen.

The project dependency that I had to add which was not a reference was TextureBuilder. It was added as a project dependency for the BuildExampleGameAssets. This project dependency is required as the texture assets of the game can only be built once the texture building tool is built itself.

The time it took me to complete this assignment was 12 hours.