Write Up 03
Press Escape to quit the application.
Assignment03 was very challenging as here I was required to make a unique Graphics.cpp file.
In order to do this, I created a struct called View which receives platform specific data and implements platform specific functions from the old Graphics.d3d.cpp and Graphics.gl.cpp files in the following way:
It uses the InitializeViews() function, which has the implementation of the removed Graphics.d3d.cpp file on View.d3d.cpp. For OpenGL, the implementation is empty.
It implements a CleanUp() function to release the m_renderTargetView and m_depthStencilView pointers on Direct3D, the OpenGL implementation is empty.
It uses the ClearColor(float red, float green, float blue, float alpha) function which clears the screen with the color the user inputs in the Graphics.cpp file.
It uses the ViewSwapBuffers()function which swaps the buffers.
In summary, I created a platform independent interface View.h with platform specific implementations, View.d3d.cpp and View.gl.cpp.
The platform specific implementation files for the Effect struct as well as the Sprite struct use a new GetContext() function to get the immediate d3d context for Direct3D platforms. The OpenGL implementation has the same function but, in this case, is empty.
The following code shows the use of the platform independent interface View in the Graphics.cpp file to clear the back buffer color:
// Clear the frame
The following code shows code from Graphics.cpp which initializes a sprite:
sprite1.Initialize(0.5f, 0.5f, 0.5f, 0.5f);
The user has to specify four parameters which are as follows:
Parameter1: x coordinate of the center point of the sprite.
Parameter2: y coordinate of the center point of the sprite.
Parameter3: width of the sprite.
Parameter4: height of the sprite.
The following code shows code from Graphics.cpp which initializes an effect:
The user has to specify three parameters which are as follows:
Parameter1: name of the vertex shader file.
Parameter2: name of the fragment shader file.
Parameter3: render state of the effect.
I did the instructions specified in the optional challenge section and successfully made sprites comprised of only 4 vertices.
The time it took me to complete this assignment was 9 hours.