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

What this book covers

Chapter 1, C++ Concepts, covers the basics of C++ programming, which are essential to understand and code the chapters in this book.

Chapter 2, Mathematics and Graphics Concepts, In this chapter we cover the basic topics of maths such as vector calculations and knowledge on matrices. These are essential for graphics programming and basic physics programming. We then move on to the basics of graphics programming, starting with how a bunch of vertices is sent to the graphics pipeline and how they are converted into shapes and rendered on the screen.

Chapter 3, Setting Up Your Game, introduces the SFML framework, its uses, and its limitations. It also covers creating a Visual Studio project and adding SFML to it, creating a basic window with the basic framework of the game to initialize, update, render, and close it. We will also learn how to draw different shapes and learn how to add a textured sprite to the scene and add keyboard input.

Chapter 4, Creating Your Game, covers the creation of the character class and adding functionality to a character to make them move and jump. We will also create the enemy class to populate enemies for the game. We will add a rockets class so the player can spawn rockets when they fire. Finally, we will add collision detection to detect collisions between two sprites.

Chapter 5, Finalizing Your Game, covers finishing the game and adding some polishing touches by adding scoring, text, and audio. We'll also add some animation to the player character to make the game more lively.

Chapter 6, Getting Started with OpenGL, looks at what OpenGL is, its advantages, and its shortcomings. We'll integrate OpenGL into the Visual Studio project and use GLFW to create a window. We'll create a basic game loop and render our first 3D object using Vertex and fragment shaders.

Chapter 7, Building on the Game Objects, covers adding textures to an object. We'll include the Bullet Physics library in the project to add physics to the scene. We will see how to integrate physics with our 3D OpenGL rendered object. Finally, we will create a basic level to test out the physics.

Chapter 8, Enhancing Your Game with Collision, Loop, and Lighting, covers adding a game-over condition and finishing the game loop. We will add some finishing touches to the game by adding some basic 3D lighting and text to display the score and game-over condition.

Chapter 9, Getting Started with Vulkan, looks at the need for Vulkan and how it is different from OpenGL. We'll look at the advantages and disadvantages of Vulkan, integrate it into the Visual Studio project, and add GLFW to create a window for the project. We will create an app and a Vulkan instance, and add validation layers to check whether Vulkan is running as required. We'll also get physical device properties and create a logical device.

Chapter 10, Preparing the Clear Screen, covers the creation of a window surface to which we can render the scene. We also need to create a swap chain so that we can ping-pong between the front buffer and back buffer, and create image views and frame buffers to which the views are attached. We will create the draw command buffer to record and submit graphics commands and create a renderpass clear screen.

Chapter 11, Creating Object Resources, covers creating the resources required to draw the geometry. This includes adding a mesh class that has all the geometry information, including vertex and index data. We'll create object buffers to store the vertex, index, and uniform buffers. We'll also create DescriptorSetLayout and Descriptor Sets, and finally, we'll create shaders and convert them to SPIR-V binary format.

Chapter 12, Drawing Vulkan Objects, covers creating the graphics pipeline, in which we set the vertices and enable viewports, multisampling, and depth and stencil testing. We'll also create an object class, which will help create the object buffers, descriptor set, and graphics pipeline for the object. We will create a camera class to view the world through, and then finally render the object. At the end of the chapter, we will also see how to synchronize information being sent.