Book Image

Learn OpenGL

By : Frahaan Hussain
Book Image

Learn OpenGL

By: Frahaan Hussain

Overview of this book

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.
Table of Contents (13 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Adding a Camera class to the project


In the previous section, we learned how to add objects to our screen and how to apply texture, transformation and projection to the objects. As we progress ahead in the book, we will add various objects to our screen, but as we add more objects to it and if we wish to view those from different angles, we don't want to have specific code to be able to do that or to move freely around the objects. Therefore, in this chapter, we'll be looking at implementing a Camera class, which will help us to move around our world freely, using the keyboard, and view those objects from different angles. Implementing this class will help us to improvise a walking style of movement and take a look at the virtual world around the player with the help of the mouse. As we learned in the previous chapter, what we've got currently is the single cube we've created. As we are seeking to implement multiple objects in this chapter, we'll basically get rid of the vertices that describe...