EAE6320_Assignment2_WriteUp
A downloadable game for Windows
Details of Assignment:
- This Assignment was basically refactoring all 2D/3D objects and Shaders related code such that the code becomes platform independent and so that it remains the same for all platforms
- The Second part of the assignment was to add additional objects/Shapes/Triangle to create a Square and Analyze GPU performance on it
Running Part of Assignment:
- The Screen shot attached below this shows the rectangle part for all the configurations
- The first thing I did was to research the code so that I know which functions would be needed to refactor the code
- After knowing the part of code that needs refactoring and deciding the number of functions needed, I separated it with some platform dependent code and used #if directives to sperate the code
- Then I add the vertices for 2 triangles and changed the values where needed to create square
- Afterwards, I realized that the platform dependent code can be easily merged because the variable was static and can be used in file itself as change in static variables is reflected at every place
- So Finally my binding function and drawing function looks like this:
Fig 1. Image of game running in all configuration
How I Reach At This Point:
- The first thing I did was to research the code so that I know which functions would be needed to refactor the code
- After knowing the part of code that needs refactoring and deciding the number of functions needed, I separated it with some platform dependent code and used #if directives to sperate the code
- Then I add the vertices for 2 triangles and changed the values where needed to create square
- Afterwards, I realized that the platform dependent code can be easily merged because the variable was static and can be used in file itself as change in static variables is reflected at every place
- So Finally my binding function and drawing function looks like this:
// Bind the shading data
{
{
s_shaderEffects->BindShadingData();
}
// Render state
{
s_shaderEffects->BindRenderState();
}
}
// Draw the geometry
{
s_geometry3DObjects->Draw3DObject();
}
- Also, the image of my folder structure
Fig 2. Screenshot of my folder structure
GPU Analysis Direct 3D:
- For Analysis in Direct 3D, I used the Visual Studio’s Graphics Analyzer
- Analysis was done in 2 steps,
- The First one was rendering the screen before anything was drawn on the screen
- The Second was analyzing the draw function and the wireframe of the object drawn by the draw function showing how the object was actually created
Fig 3. Screenshot of Clear Render Target function called
Fig 4. Screenshot of wireframe view of object on Draw function in Direct 3D, see below how 7 different triangles are seen to create the object
GPU Analysis OpenGL:
- For open GL, I used program called RenderDocs which gives GPU analysis of application like visual studio graphics analyzer
- The Open GL analysis was done in 3 steps as it has different tabs for, wireframe and actual image:
- Render screen before anything was draw or on calling Clear Render Target function
- Second part was seeing how the object looks after the draw function
- Third part was seeing the wireframe of the object drawn
Fig 5. Screenshot of clear render target function (open GL Render Docs)
Fig 6 Screenshot of the actual object for OpenGL in Render Docs
Fig 7. Screenshot of Wireframe of the object drawn in OpenGL Render Docs, see how 7 different triangle creates the shape
Optional Challenge:
- The optional challenge was to create a house (which can be seen in the images above) using triangles
- For creating this house, I actually paper prototyped the house on in my book and then just added the vertices where it was needed
- Also, as Open GL and Direct 3D works in different types, I did a hack that was to actually change the index of the vertices array without changing the values (swapping the index of first and third vertex of triangles)
Fig 8. Image of my paper prototype
Fig 9. Screenshot of my running house
Difference:
- The code needed for Direct 3D is more than OpenGL, so, the entire code for Open GL can be written in Graphics.cpp and we need to add #if directives for some direct 3D
- There are 2 Extra pointers needed for Direct 3D which created difference adding 3 functions to Init, Run and Clean these pointers
- So I think to combine the files we write those function in .d3d file and just call #if directive to call the those extra functions
- Along with that there is one function that is different for both Direct 3D and Open GL which is to clear the target screen, which can be defined in different function with same name
It took me 9 Hours to finish this assignment
Install instructions
- Download the Zip File
- Extraxt the .zip to any folder you want
- Double click the .EXE
Leave a comment
Log in with itch.io to leave a comment.