Implementing the checkerboard scene
Task Introduction
The task set for this exercise was to implement two scenes, a checkerboard and a bouncing ball scene using the Game Programming framework provided in the lecture slides.
Purpose
The purpose of this post is to reflect on the debugging process that took place to fix the problems I was facing. After implementing the base game programming frame work from the lecture slides, I was able to then implement the checkerboard scene however, not every thing went smoothly.
Bug 1
As you can see from the screenshot below the checkerboard scene is not loading properly and only show the aqua background. This scene is meant to have 5 checkerboards, one in each corner and 1 in the middle. The top right is meant to be red, bottom right is green and bottom left is blue, the rest are meant to be white.
After hunting for the bug for about 30 minutes and double checking my code with the code in the lecture slides, I finally found a bug. Turns out I used the wrong trigonometric function for the world transformation matrix in renderer.cpp.
world.m[1][0] = cosf(angleInRadians) * (sizeY);
world.m[1][1] = sinf(angleInRadians) * (sizeY);
Instead it was meant to look like this:
world.m[1][0] = sinf(angleInRadians) * (sizeY);
world.m[1][1] = cosf(angleInRadians) * (sizeY);
After fixing this bug, I finally got a partial checkerboard being displayed in the scene.
Bug 2
Looking at the output after fixing bug 1 you can clearly see that it's still doesn't seem right, and you'd be correct. After spending more time trying to hunt down this issue I finally found it also in the renderer.cpp. After comparing the vertices that I had with the lecture slides, I once again realized that some of the values were wrong and should have been these instead:
After Fixing the second bug in this program I was able to get the checkerboard scene looking like this:
Now we are getting somewhere however, once again there is another bug! This time it's not displaying the checkerboards in the correct locations.
Bug 3 + 4
This was a relatively easy fix compared to the last two. Since I knew the checkerboard positions were out of place I knew where to look.
Green checkerboard position before:
Green checkerboard position after:
Blue checkerboard position before:
Blue checkerboard position after:
Wow it looks like the bugs has all been squashed and is displaying correctly, yay!
Final Adjustment
There is only a minor change left to do which is change the size of the window to better accommodate all the checkerboards.