/game-engine

C++ game engine development resources for educational purposes

Primary LanguageC

Game engines resources

C++ game engine development resources for educational purposes.

This repo is work in progress and is not even half finished, but you still can find some useful links and code examples here.

Creating a window

SDL is a cross-platform library for creating a window and handling window events (keyboard presses, mouse clicks, etc.).

OpenGL loading library called glad helps with OpenGL integration.

Alternative libraries:

Code examples:

  • Window.h - window is abstracted. Because of this abstraction we can implement window using any library and swap it for another later if needed.
  • SDLWindow.cpp - window implementation using SDL library.

Handling window events

To be able to handle user input: key presses, mouse movements and clicks, etc. you will need to handle window events.

Code examples:

  • Events - directory contains custom defined events. We define our custom events in order to not depend on any library, this way we could swap SDL for some other library relatively easily.
  • SDLWindow.cpp - HandleEvents() method transforms SDL events into our custom defined events.

User Interface

Any engine needs some kind of UI for development and debugging purposes.

Dear ImGui is one of the best libraries for creating UIs in C++.

Entity Component System

Entity Component System is a software architectural pattern for the representation of game world objects.

EnTT is one of the most popular ECS libraries in C++.

Resources:

Math calculations

Libraries:

glm math library for graphics software based on the OpenGL Shading Language (GLSL) specifications.

Tiles

For creating tiles, maps, etc.

Tools:

2D Physics

Libraries:

Resources:

Logging

It's important to have extensive logs in your application to understand what is happening and when.

spdlog is one of the libraries that can be used for logging.

Code examples:

  • Log.h - logger is abstracted so we can use any library we want.

Performance tips

Batch rendering

Rendering large amounts of objects can affect performance. Batch rendering is an optimization technique to make your game faster.

Resources:

Data locality

Data locality, or locality of reference, is the tendency of a processor to access the same set of memory locations repetitively over a short period of time.

We can utilize this knowledge together with optimizations like Data-oriented design to improve performance when processing large arrays of data.

Resources:

Profiling

TODO

Additional resources

Articles

Sprites

Resources:

Repositories

Tools

  • MagicaVoxel - GPU-based voxel art editor
  • GoNorth - a web application used for planning the story and world of RPGs or other open world games.

Videos