Game Engineering – II |Assignment – 2

The focus of this assignment was to create an interface for the Mesh (geometry data) and the Effect(shader data) that was bring used by both the Direct3D and OpenGL graphics classes.

Here is the executable MyGame_

Looking at the Graphics.cpp files told me a lot about how the graphics pipeline actually works. All of it is a series of inputs and outputs i.e. each part of the pipeline takes in some data, does something with it and gives it off to the next part of the pipeline (I gleamed this from Varun with whom I had a discussion about the assignment) and as such, gets promptly destroyed when no longer needed (which in this case is done inside the CleanUp function).

Another thing I found out (Or well, remember now because I knew this before) is that there are two copies of the data (mesh and effect) present at any time. One copy being populated from the data being submitted by the application thread while the other copy is fully rendered but not displayed as it currently sits on the back buffer, which is ready to be swapped with the front buffer and displayed.

cEffect
The cEffect interface

As for the interface itself the Effects interface had some code which was platform independent. More specifically, it was the code which was loading and releasing shaders (which tells me both OpenGL and Direct3D handle this part in a similar manner, also evident from the common shader variables used by both). As such I moved it inside private functions which were then used internally by the interface.

The Mesh interface however, did not. That is not to say there wasn’t any commonalities between OpenGL and Direct3D, just that they weren’t significant enough to warrant their own separate functions.

cMesh
The cMesh interface

While going through both Graphics.3d3.cpp and Graphics.gl.cpp  I saw quite a bit of code that was common to both files. An example would be the events handling the receiving of data and submitting to the new frame, quite a bit of cleanup code (besides the bit that I already hid behind an interface as assignment requirement) and even some frame initialization stuff. However, actually combining both these files and ultimately hiding them behind a single Graphics.cpp interface would be difficult if not outright impossible just because of the difference in how OpenGL and Direct3D work under the hood (at least what I gleamed from just looking at these files)

The following are the screenshots from the graphics debugger built in to Visual Studio.

d3d_clear
Render Target cleared
d3d_wireframe
Square rendered in the Draw call along with the wire-frame view

And also the screenshots from renderDoc for OpenGL.

gl_clear
glClearColor
gl_draw_texView
glDrawArray
gl_draw_mesh
glDrawArray with wireframe

And finally, a screenshot from the executable itself.

gamescreen.png

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s