Shantanu Pandey
  • Projects
    • Hard Light Vector
    • Memory Manager
    • Samurai Crusader
    • Dyslexia VR
    • Geriatric Depression Suite
  • Prototypes
    • Game Mechanics
    • Diana's Inferno
    • MakeUp & BreakUp
    • 10Pest
    • Ninja Pinball
  • Blogs
    • Sic Parvis Magna
    • Game Engineering - Week 1
    • Game Engineering - Week 2
    • Game Engineering - Week 3
    • Game Engineering - Week 4
    • Game Engineering - Week 5
    • Game Engineering - Week 6
    • Game Engineering - Week 7
    • Game Engineering - Week 8
    • Game Engineering - Week 9
    • Engine Feature - Audio Subsystem
    • Final Project - GameEngineering III
    • AI Movement Algorithms
    • Pathfinding Algortihms
    • Decision Makiing
  • About

Week 3 - 06/09/2018

9/13/2018

0 Comments

 
After creating the platform independent interfaces for mesh and effect in last week’s assignment, this week required us to create a single platform independent Graphics interface. This meant instead of using separate graphics.d3d and graphics.gl for Direct3D and OpenGL respectively, we had to create a single graphics both configurations.
​
After analyzing the code, I found that how buffers were handled in OpenGL and Direct3D was quite different. Graphics rendering use the buffers to draw images on screen. A new image is drawn every frame and before drawing, the image from previous frame is cleared. These temporary images are stored in buffers. So to make the graphics platform independent, I created a Buffers class and used that to specify the platform dependent clearing, swapping and cleaning up of buffers code. Also, Direct3d had and additional step of using views for graphics rendering. This code of initializing this view is also done in Buffers class by me (I feel this might be confusing to initialize views using Buffers class, but to avoid creating another platform independent interface, I used the Buffers). The body of function for views is empty in case of OpenGL as it does not require the the views.
Picture
Game Screenshot - Dark blue is the clear buffer color and other two square are two separate meshes and effects.
Playable EXE Download

Since as a part of this assignment we had to use index buffer instead of vertex buffer, and the graphics has to be platform independent, winding order of indices was another important thing to keep in mind. I used OpenGL winding order as the default and updated winding order of the index buffer passed while initializing in Direct3D.
​
Below code is used by me to clear the back buffer: 
Picture
It takes 4 floats for the clear color value (RGB and alpha)
 
Initialization 
​
Effect
I used the below implementation to initialize the effects:
Picture
​It takes the path of vertex shader and fragment shader as the argument.
Mesh
I used the below implementation to initialize the geometric data:
Picture
It takes the number of triangles to draw (triangle count), number of vertices to draw those triangles (actual vertex input, 4 in our case as two vertices will be common for drawing 2 tringles), vertex coordinates (vertex data) and index buffer as input parameters.
 
Memory Usage
Effect
Picture
OpenGL - 16 bytes
Picture
Direct3D - 40 bytes
We can see that direct 3D has significantly higher memory size as compared to OpenGL. I believe this is because Direct3D uses 3 additional pointers as compared to OpenGL. Memory alignment may be another issue that is causing some memory wastage is Direct3D.

Meshes
Picture
OpenGL - 12 bytes
Picture
Direct3D - 24 bytes
The size difference is due to the three pointer we use in Direct 3D are of 8 byte each while the 3 used in OpenGL are 4 bytes each.
 
Here is a list of some interesting information I found out during this assignment:
  • For drawing two meshes with two different effects, the order should be draw, render, draw, render. Draw, draw and render, render doesn’t work. I found this when I was initially doing the second approach and only the last specified mesh and effect were getting drawn.
  • While using index arrays for rendering, along with the index buffer, it is important to bind the vertex buffer as well. I missed this step in OpenGL configuration and the code didn’t work.
  • As for the platform independent graphics, only one type of indices winding order can be used as the default. In the mesh initialization of Direct3D (I used OpenGL as default), index vertex was passed as an argument. There are two ways we can update this winding order; either by swapping the index values of the input parameter (changing input is considered a bad design practice!), or by creating a copy of the index buffer array and use that for binding. I used the second approach but it sacrifice some execution time of the program. 
0 Comments

    Author

    Write something about yourself. No need to be fancy, just an overview.

    Archives

    September 2018

    Categories

    All

    RSS Feed

FOR ANY FURTHER DETAILS


Telephone

801-859-1131

Email

Resume
File Size: 227 kb
File Type: pdf
Download File

Visit Hard Light Vector
[email protected]
Git Hub
  • Projects
    • Hard Light Vector
    • Memory Manager
    • Samurai Crusader
    • Dyslexia VR
    • Geriatric Depression Suite
  • Prototypes
    • Game Mechanics
    • Diana's Inferno
    • MakeUp & BreakUp
    • 10Pest
    • Ninja Pinball
  • Blogs
    • Sic Parvis Magna
    • Game Engineering - Week 1
    • Game Engineering - Week 2
    • Game Engineering - Week 3
    • Game Engineering - Week 4
    • Game Engineering - Week 5
    • Game Engineering - Week 6
    • Game Engineering - Week 7
    • Game Engineering - Week 8
    • Game Engineering - Week 9
    • Engine Feature - Audio Subsystem
    • Final Project - GameEngineering III
    • AI Movement Algorithms
    • Pathfinding Algortihms
    • Decision Makiing
  • About