A downloadable game for Windows

This assignment was an interesting exercise in encapsulating platform-specific code into a platform-independent interface.

We were to create an abstract representation of "Geometry" (vertex data) and the "Effect" that would bind to it (the shaders) and have a common interface for both of these for Direct3D and OpenGL.

To do that, I needed to hunt down all the common functions for creating a geometry and binding shading data to render it (the geometry) and separate them into a platform-independent interface. Obviously, the implementations for OpenGL and D3D were different, so we had to put them into separate CPP files.

One fun (and I use "fun" both literally and sarcastically)  thing we had to do was to account for the "winding direction" (is that the technical term for this?) for OpenGL and Direct3D. Which just so happen to be the opposite of each other.

For my code, I chose to set a right-hand-rule winding motion to be the default, that my Geometry representation expects. It switches to the left-hand-rule notation for Direct3D underneath for Direct3D platforms.

Requirements for the assignment:

  • GPU capture screenshots galore!
  • Code screenshots to show the platform-independent interface. I took these from the OpenGL version but, as is apparent, there's no mention of OpenGL-specific data anywhere in the interface.
  • Remaining differences between OpenGL and Direct3D:
    • If I wanted to make the Graphics interface (which calls the interface I wrote in this assignment)  platform-independent, I think we'd need to wrap all the stuff about "programIDs" (in OpenGL) and "Views" (in D3D) into a similar platform-independent interface. 
    • There was also a lot of device-level management stuff (like swapping buffers, which both of these frameworks did; just differently) that also would need to be abstracted out.
    • Luckily, in this case, both platforms seem to follow the same underlying concepts; they just use different terminology to implement them. So that makes it pretty simple to abstract out the surrounding concepts into something like a "OpenGL Graphics System" and a "D3D Graphics System" and then have an common interface that the engine's Graphics System can use.


Overall, I was amazed at how simple this assignment turned out to be (honestly, I thought it'd get super overwhelming, wading through code someone else wrote on platforms you know nothing about.) It was really just a matter of systematically moving the individual pieces of code around and a lot of Ctrl+K -> Ctrl+C.

Download

Download
MyGame_x64_Direct3D.zip 166 kB
Download
MyGame_x86_OpenGL.zip 161 kB

Leave a comment

Log in with itch.io to leave a comment.