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

My Resume Learn more

Assignment 03

This assignment focused on making Graphics completely platform-independent and using Index Buffers to draw meshes. Try it out here!

Encapsulating Views

To make Graphics platform-independent, the first thing I did was look at all the differences between Graphics for Direct3D and OpenGL. From this, I noticed the core differences were initialization and cleanup of views, swapping back buffers, and clearing the back buffer. This lead me to create another class called View that would encapsulate all this platform-dependent functionality away from graphics. The one thing that surprised me with initialization and cleanup of views was that this was something that only Direct3D did.

Clearing the back buffer is now a single line call in Graphics where the caller simply passes the color they would like for it:

Encapsulating Effect Shaders

Effects now take in parameters to the path of the caller's desired vertex and fragment shaders.

Effects also use 40 bytes with Direct3D and 16 bytes with OpenGL. This difference can be associated with Direct3D target x64 and OpenGL target x86. I don't believe Effects can be made any smaller given the Handles and States it needs to store.

Index Buffers for Mesh Initialization

Meshes now are initialized with a Vertex and Index array following a right-hand winding order.

Meshes are 32 bytes with Direct3D and 20 bytes with OpenGL. This difference can be associated with Direct3D target x64 and OpenGL target x86. We could make the mesh smaller if we knew more information on how many vertexes we needed to draw statically.


Fully making Graphics platform-independent made it far easier to understand and work with. Now that responsibilities for Effects and Meshes have been passed to different class, changing desired behavior is simply passing in different parameters as opposed to restructuring code. Looking into the future, it appears all this work also made the task of threading Graphics more attainable.





No Comments Yet.

Leave a comment