C++ Game Development By Example
Learn to build games and graphics with SFML, OpenGL, and Vulkan using C++ programming
Siddharth Shekar
- 420 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
C++ Game Development By Example
Learn to build games and graphics with SFML, OpenGL, and Vulkan using C++ programming
Siddharth Shekar
About This Book
Explore modern game programming and rendering techniques to build games using C++ programming language and its popular libraries
Key Features
- Learn how you can build basic 2D and complex 3D games with C++
- Understand shadows, texturing, lighting, and rendering in 3D game development using OpenGL
- Uncover modern graphics programming techniques and GPU compute methods using the Vulkan API
Book Description
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.
What you will learn
- Understand shaders and how to write a basic vertex and fragment shader
- Build a Visual Studio project and add SFML to it
- Discover how to create sprite animations and a game character class
- Add sound effects and background music to your game
- Grasp how to integrate Vulkan into Visual Studio
- Create shaders and convert them to the SPIR-V binary format
Who this book is for
If you're a developer keen to learn game development with C++ or get up to date with game development, this book is for you. Some knowledge of C++ programming is assumed.
Frequently asked questions
Information
Section 1: Basic Concepts
C++ Concepts
- Program basics
- Variables
- Operators
- Statements
- Iteration
- Functions
- Arrays and pointers
- Struct and Enum
- Classes and inheritance
Program basics
#include <iostream> // Program prints out "Hello, World" to screen int main() { std::cout<< "Hello, World."<<std::endl; return 0; }
std::cout<< "Hello, World."<<std::endl;return 0;
- Open up Visual Studio and create a new project by going to File | New | Project.
- On the left-hand side, select Visual C++ and then Other. For the Project Type, select Empty Project. Give this project a Name. Visual Studio automatically names the first project MyFirstProject. You can name it whatever you like.
- Select the Location that you want the project to be saved in:
- Once the project is created, in Solution Explorer, right-click and select Add | New Item:
- Create a new .cpp file, called the Source file:
- Copy the code at the start of the section into the Source.cpp file.
- Now press the F5 key on the keyboard or press the Local Window Debugger button at the top of the window to run the application.
- A popup of the console should appear upon running the program. To make the console stay so that we can see what is happening, add the following highlighted lines to the code:
#include <iostream>
#include <conio.h>
// Program prints out "Hello, World" to screen int main() { std::cout << "Hello, World." << std::endl;
_getch();
return 0; }
- When you run the project again, you will see the following output:
Variables
Type variable;