Overview

Obstacle Dodger is a modern C++ game built from scratch using the OpenGL 3.3 Core Profile. This project serves as a comprehensive exploration of low-level graphics programming, audio management, and game loop architecture without relying on high-level commercial game engines like Unity or Unreal Engine.

"Building a game engine from scratch provides unparalleled insight into memory management, rendering pipelines, and the raw performance capabilities of C++."

Key Features

Modern Rendering

Utilizes OpenGL 3.3 Core Profile with custom vertex and fragment shaders for optimized rendering.

FreeType Text

Dynamic font rendering engine for UI elements, scoring, and the FPS counter.

OpenAL Audio

Integrated 3D spatial audio and sound effects using OpenAL Soft.

Input Handling

Seamless support for both Keyboard and Gamepad/Joystick inputs via GLFW.

Technical Implementation

The game architecture relies on GLFW for window creation and input handling, while GLAD loads the OpenGL function pointers. Math operations, including matrix transformations and vector calculations, are handled efficiently by GLM.

Shader Compilation

All rendering is executed through programmable shaders. Below is a simplified snippet of how the C++ engine loads and compiles the GLSL shaders dynamically at runtime:

unsigned int loadShader(GLenum type, const char* source) {
    unsigned int shader = glCreateShader(type);
    glShaderSource(shader, 1, &source, NULL);
    glCompileShader(shader);
    
    int success;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
    if (!success) {
        char infoLog[512];
        glGetShaderInfoLog(shader, 512, NULL, infoLog);
        std::cerr << "Shader Compilation Error:\n" << infoLog << std::endl;
    }
    return shader;
}

Installation & Usage

If you want to run the project locally or examine the source code, you will need a C++17 compatible compiler and CMake.

  • Ensure you have the required dependencies (GLFW, GLAD, GLM, FreeType, OpenAL) installed on your system.
  • Build the project using standard CMake commands: cmake . and make.
  • Run the executable generated in the build directory.