Purpose of the game is evading walls and scoring as much point as possible. This is the first 3D OpenGL game I have made. I implemented my own collision detection algorithm and 8xMSAA anti-aliasing. I also implemented object outlining using stencil buffers.
Source Code: GitHub
Demo: Google Drive



Some Technical Details
- This game was written in OpenGL/C++. Nsight Graphics was used as graphics debugging tool.
- Implemented Multisample Anti-Aliasing.
- Also implemented gray-scale post processing effects.
- The world consists of 5 “bounding box/room” in total. Every bounding box contains 3 lines of walls as it’s hinted with wall colors. The collision detection algorithm test the collision between plane-wall and plane-coin. And it’s tested only with objects that is in the same room with the plane to avoid unnecessary testing. Bounding boxes are destroyed if they go past behind the camera and new ones are created. That gives the immersion of that the game continues forever.
- Implemented object outlining using stencil buffers. Here is how it works.
- First enable stencil writing.
- Set stencil funtion to GL_ALWAYS so that the test always passes.
- Render the plane to stencil buffer. This fills stencil buffer with 1s wherever the object fragments are being rendered.
- Disable depth and stencil test.
- Scale up the plane by a small amount. This is done in vertex shader like this:
- gl_Position = projection * view * model * vec4(aPos + aNormal * 0.9, 1.0);
- Render the plane in any color you want but only if its fragments’ stencil values are not equal to
1
. Since orijinal plane is a little bit smaller than single colored version it won’t discard all the fragments of the single colored version. In the end single colored plane will look like real plane’s borders. - Lesson learned: When depth testing is disabled, order of draw calls matter. The last draw call will be rendered to the screen.
- Fixed many bugs during the development. Two of them was game breaking. FPS of the game dropped down to 15’s from 500’s because of the first bug. It turns out that I was recompling shaders at the beginning of each frame. I got stuttering issue because of the second bug. Reason for that one was loading one of the textures under some conditions during runtime rather than loading every texture at the beginning of the game. Nsight was incredibly helpful to identify the cause of these issues.
- I also used my own DrawDebugLines functions and ImGUI to debug several issues during the development.