Learn OpenGL
Beginner's guide to 3D rendering and game development with OpenGL and C++
Frahaan Hussain
- 208 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Learn OpenGL
Beginner's guide to 3D rendering and game development with OpenGL and C++
Frahaan Hussain
About This Book
A step-by-step instructional guide to understanding the fundamentals of game development with OpenGL. Right from the setup to the important features, we'll get a better understanding of games and the engines behind them.
Key Features
- Learn the basics of drawing along with fundamentals of shading to create amazing objects.
- Get in-depth knowledge of lighting and materials to make realistic objects.
- Understand the fundamentals of model loading and cube mapping.
Book Description
Learn OpenGL is your one-stop reference guide to get started with OpenGL and C++ for game development. From setting up the development environment to getting started with basics of drawing and shaders, along with concepts such as lighting, model loading, and cube mapping, this book will get you up to speed with the fundamentals.
You begin by setting up your development environment to use OpenGL on Windows and macOS. With GLFW and GLEW set up using absolute and relative linking done, you are ready to setup SDL and SFML for both the operating systems.
Now that your development environment is set up, you'll learn to draw using simple shaders as well as make the shader more adaptable and reusable. Then we move on to more advanced topics like texturing your objects with images and transforming your objects using translate, rotate and scale.
With these concepts covered, we'll move on to topics like lighting to enable you to incorporate amazing dynamic lights in your game world.
By the end of the book, you'll learn about model loading, right from setting up ASSIMP to learning about the model class and loading a model in your game environment. We will conclude by understanding cube mapping to bring advance worlds to your game.
What you will learn
- Set up GLFW and GLEW on Windows and macOS with absolute, relative Linking
- Set up SDL and SFML on your system using absolute and relative Linking
- Draw using the simple shaders
- Create a camera and learn to populate your game world with objects
- Learn about color and lighting concepts to create an amazing game world
- Understand model loading and cube mapping to advance your game
Who this book is for
This book is targeted towards anyone and everyone who is interested in creating games, learning how game engines work and most importantly for anyone who is interested in learning OpenGL. The ideal reader for this book would be anyone with a passion for learning game development or looking out for an OpenGL reference guide. The skills that you'll learn in this book will be applicable to all your game development needs. You'll require a strong foundation in C++ to understand and apply the concepts of this book.
Frequently asked questions
Information
Setting Up OpenGL
- Downloading the essential libraries
- Setting up a project on different platforms to use the libraries
- Creating an OpenGL rendering window using the libraries
Setting up OpenGL using GLFW and GLEW on Windows
Downloading the essential libraries
- First of all, we will need Visual Studio. You might have already installed it. If you did, it's fantastic. If not, go to https://visualstudio.microsoft.com/, go to Downloads, and then click to download the Visual Studio Community 2017 version. Then, follow the instructions and install Visual Studio onto your system. Once you've got that installed, you just want to make sure it's set up for the C++ environment.
- Next, we will download the OpenGL Extension Wrangler library. Visit http://glew.sourceforge.net/, and then click on the Binaries option to download the 32-bit or 64-bit version files, as per your system requirements:
- Once you have done that, we will move on to downloading OpenGL framework library files. Go to http://www.glfw.org/ and click on the Download menu. We will want to download the precompiled binaries for Windows. As seen in the following screenshot, select and click to download either the 32-bit or 64-bit version as per your system requirements:
Linking GLFW and GLEW libraries with absolute linking
- Open Visual Studio, and then click on Create new Project...:
- Then, go to Visual C++ | Windows Desktop | Windows Console Application and name your project GLFWOpenGL, as seen in the following screenshot, and then click OK:
https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation
- Now, right-click on the project in the Solution Explorer window. Go to Add | New Item, and you will get an Add New Item window. Select C++ File, as this will be our main file, and let's name it main.cpp and then click on the Add button.
- Next, right-click on the project in the Solution Explorer window. Click on Properties.
- A Property Pages window will pop up; click on C/C++ | General and then go to Additional Include Directories. Click on the dropdown, then click on <Edit>, and you will get a pop up window as follows:
- As highlighted in the preceding screenshot, click on the new button and then c...