This assignment required us to do 2 main things. The first one was to compile the fragment and vertex shader files into a single platform independent file that is used by both Direct3D and OpenGL. The second was to use Lua data to generate a mesh that we use to display the square we had in the last assignment.
For the shader files I chose to name them fragment.shader and vertex.shader. Since these files are shader files it made most sense to me to have their type in the file extension. The filenames described the type of shader they were. I used preprocessor macros to define which code is run for which platform. this way we have only one common shader file for each platform.
My mesh file has expanded a lot from before. One of the first things I did was to correct a mistake I made last week about passing the size of the Vertex data in the draw call. Since I restructured the mesh file that was no longer needed,. Since out mesh file will eventually be generated by Maya I decided to stick with the default winding order that maya uses which is right handed. This winding order is the same as OpenGl but different from DirectX. Similarly I went with having the RGB color values as well the alpha value in my structure because I thought that since all four values are used to display something, this should be reflected in my Lua file.
All my Mesh files are named with the .mesh extension. Since they contain data that generates the mesh it seemed most obvious to me to call them by the .mesh extension.
This is how my Mesh structure ended up looking like :
#if defined( EAE6320_PLATFORM_D3D )
IDirect3DVertexDeclaration9* s_vertexDeclaration = NULL;
IDirect3DIndexBuffer9* s_indexBuffer = NULL;
IDirect3DVertexBuffer9* s_vertexBuffer = NULL;
#elif defined( EAE6320_PLATFORM_GL )
GLuint s_vertexArrayId = 0;
The lua file that generates the mesh should be highly HUMAN READABLE. This means that any programmer who is using the file should easily understand the format and data in the mesh file. This makes the file easy to understand and thus modify. In later assignments we are going to write a maya exporter for us that will generate this file for us this we do not have a lot of work to do in making these files in the future. But having a readable and understandable format means that anyone using it can tell what data is being used in which format.
This assignment had a lot of places where you could go wrong and it took a long time to complete. There were a few errors I overlooked that I had help from a couple of my classmates to resolve. Finally I managed to get it work, it took a while.
You can download the DirectX_64 build here
You can download the OpenGL_32 build here