School
2024
C++
OpenGL
Game Engine
About

Proces
For this project we had eight weeks to go through the proces of creating and rendering 2D shapes, 3D shapes, terrain with blended textures, 3D models, lighting, fog and create our own glsl shaders. After that we had the option to add something we wanted to create for ourselves. I decided to abstract out all the functionality and make this project reusable so I can use a lot of the codebase for my own game engine project (Nebulon).
Setup
The first step of this project is to setup the project and setup the Github repository. Because I already have experience with creating a game engine, I decided on using Premake to create the visual studio solution and link up the libraries to the visual studio projects.
Basics
After having set up the project, I went on creating the foundation of engine by creating and rendering out a simple window and displaying a 2D shape with a color. I then moved on to creating the structures needed to render 3D shapes, such as a vertex array, vertex buffer and an index buffer. With those constructs in place I was able to render 3D (hard coded) shapes.

Lighting
Next up is lighting. For this project we had to create a skybox with a sun and a directional light. Not having done this previously, I followed the videos of my teacher that explained the math behind all of it and showed me how to implement it. I now had a skybox with a sun!

Terrain
Next up was creating a terrain. Following along with my teacher, I generated the vertices and
normals for the terrain and I created the shader to render the textures (blended) based on
the
height of the vertices.
A funny bug I encountered was that my terrain would not render. This was because I
previously
used a
stack-allocated vertex array and just used the size of the array to tell OpenGL how many
vertices to
render. The problem was, for the terrain I used heap-allocated memory and therefore I
accedently
used the size of the pointer instead of the size of the array. After that silly mistake, my
terrain
rendered beautifully.

Fog
Next up I had to render fog. I would blend each object based on the distance from the camera and the top and bottom colour of the fog. This would give everything the illusion of fog.

Models
The last part to this project was to render 3D models. I did this by using a library called Assimp. My problem was that I could not get this library to work by using git submodules or statically link to it (as i did with all my other libraries), so I had to use Microsoft's vcpkg library in order to ship the nececarry dll files with the project when building it.

Result
In the end, I could render everything I needed and I abstracted everything out in order to make it reusable in the future (and to make it easier for myself while I worked on this project).
A lot of my knowledge about how to create game engine functionality in C++ using OpenGL comes from a
game engine developer named Yan Chernikov (The
Cherno). His expertiece and way of thinking has helped me a lot in understanding how
most of
the structures and systems work in a game engine and how to create those myself.
Because of the knowledge I gained from him, I had a very swift setup and I already knew how
to
create the basic structures needed in a game engine, such as the window, buffers, shaders
and
more.
Because of this,
I could focus on learning new things such as rendering terrain, fog and loading in 3D
models.
I had a lot of fun creating this project!