Built upon the understanding of last week, this week’s assignment require us to understand the graphics pipeline better and create a platform independent interface for mesh and effect. The requirement was instead of using platform specific graphics files, we have a create make a platform independent interfaces and use that for both OpenGL and Direct3D.
To clarify the graphics terms, mesh is the geometric data used in drawing and effect is the shading data over the geometric data. This means mesh defines the boundaries and effect defines the coloring over it. There is also an important difference between OpenGL and Direct3d on how they draw on screen. OpenGL takes the coordinate of vertices in counter-clock wise direction while Direct3D takes them in clockwise direction.
As the implementation of this assignment, I created a platform independent cMesh and cEffect class and both the Graphics.gl.cpp and Graphics.d3d.cpp call the same functions to initialize, draw, bind and clear the meshes and effect.
One major difference between Direct3d and OpenGL is the initialization of views. This step doesn’t happen in OpenGL but Direct3D initializes a view to render target on screen. It takes the screen’s resolution width and height to render the target. These views are initialized before the shading data (i.e. effect) and geometry data (i.e. meshes). One way I could think of to avoid this is we could initialize the views automatically when user initializes the effects for Direct3D. Preprocessor can be used in cEffect class to initialize views before the effects only for Direct3D.
Some screenshots from this assignment are below:
Playable Exe Download