Book Image

C++ Game Development By Example

By : Siddharth Shekar
Book Image

C++ Game Development By Example

By: Siddharth Shekar

Overview of this book

Although numerous languages are currently being used to develop games, C++ remains the standard for fabricating expert libraries and tool chains for game development. This book introduces you to the world of game development with C++. C++ Game Development By Example starts by touching upon the basic concepts of math, programming, and computer graphics and creating a simple side-scrolling action 2D game. You'll build a solid foundation by studying basic game concepts such as creating game loops, rendering 2D game scenes using SFML, 2D sprite creation and animation, and collision detection. The book will help you advance to creating a 3D physics puzzle game using modern OpenGL and the Bullet physics engine. You'll understand the graphics pipeline, which entails creating 3D objects using vertex and index buffers and rendering them to the scene using vertex and fragment shaders. Finally, you'll create a basic project using the Vulkan library that'll help you get to grips with creating swap chains, image views, render passes, and frame buffers for building high-performance graphics in your games. By the end of this book, you’ll be ready with 3 compelling projects created with SFML, the Vulkan API, and OpenGL, and you'll be able take your game and graphics programming skills to the next level.
Table of Contents (18 chapters)
Free Chapter
1
Section 1: Basic Concepts
4
Section 2: SFML 2D Game Development
8
Section 3: Modern OpenGL 3D Game Development
12
Section 4: Rendering 3D Objects with Vulkan

To get the most out of this book

The book is designed to be read from the start, chapter by chapter. If you have prior knowledge of the contents of a chapter, then please feel free to skip ahead instead.

It is good to have some prior programming experience with C++, but if not, then there is a chapter on C++ programming, which covers the basics. No prior knowledge of graphics programming is assumed.

To run OpenGL and Vulkan projects, make sure your hardware supports the current version of the API. The book uses OpenGL 4.5 and Vulkan 1.1. Most GPU vendors support OpenGL and Vulkan, but for a full list of supported GPUs, please refer to the GPU manufacturer or to the wiki, at https://en.wikipedia.org/wiki/Vulkan_(API).

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/CPP-Game-Development-By-Example. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Here, the printing of Hello, World is tasked to the main function."

A block of code is set as follows:

#include <iostream>
// Program prints out "Hello, World" to screen
int main()
{
std::cout<< "Hello, World."<<std::endl;
return 0;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

int main() {
//init game objects
while (window.isOpen()) {
// Handle Keyboard events
// Update Game Objects in the scene
window.clear(sf::Color::Red);
// Render Game Objects
window.display();
}
return 0;
}

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "In Input and under Linker, type the following .lib files."

Warnings or important notes appear like this.
Tips and tricks appear like this.