The idea of this projects is separating all platform-dependent codes to another interface. It handles the global data initialization and cleaning up. Before this assignment, I put some of that part into my geometry class. And the problem is that if I have multiple geometries, those static managers will be initialized and cleaned up twice. So, I create a namespace to handle those data.
Two distinct images: Two geometries with 6 triangles.
- Explain how you made Graphics.cpp platform-independent:
I used a map structure to store my geometry data and the linking effect. Also, I use a list to store all my effects so that I can initialize and clean them together once even multiple geometries are using the same effect.
In my graphic initialize function, I link my geometries and effects.
The new Interface my mine code is called DataHandler.
Those functions are initializing global data like cContext or some other things. Inside those functions, I used preprocessor to do platform dependent things. And I also put ClearColor and SwapBuffer here. For more details, you can see my code.
- Show us your code in the Graphics.cpp file that clears the back-buffer color
I set my back color in Initialize function by using my interface function call SetClearColor(float, float, float, float).
- Show a screenshot of your game with a clear color (i.e. background) other than black
The RGB value is (40,40,40, 255)
- Show code from your Graphics.cpp file that initializes an effect
The name of two types of shader are required. If the path is changed, the path is also requried
- Tell us how much memory a single effect takes up in both platforms (use sizeof() with a debugger rather than guessing). Is there any way to make it smaller?
The size is 72.
The size of mine effect is incredibly big. I store two strings for the name of two shaders. And I store two shader handles for two shaders and a render state. I did not want to load shader in constructor and make the constructor fail so I store shader name so that when I need to load them I can load them. And for those shader handles, I think once I initialize the shading data, I should not need them anymore. There are some ways to reduce the size of my effect, but the disadvantage of the way is that it may fail in constructor and assert in constructor.
- Show code from your Graphics.cpp file that initializes a 3D object
The vertex data, the length of vertex data array. The index data, the length of index data.
- Tell us how much memory a single object takes up in both platforms (use sizeof() with a debugger rather than guessing). Is there any way to make it smaller?
It was the same way like optimizing effect, but it will also need to take the risk of fail in constructor.