0%

Book Description

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.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Learn OpenGL
  3. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Disclaimer 
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    5. Get in touch
      1. Reviews
  6. Setting Up OpenGL
    1. Setting up OpenGL using GLFW and GLEW on Windows
      1. Downloading the essential libraries
      2. Linking GLFW and GLEW libraries with absolute linking
      3. Linking GLFW and GLEW libraries with relative linking
      4. Adding a dynamic link library to the project
    2. Setting up OpenGL using GLFW on a Mac
      1. Downloading the GLFW and GLEW libraries for a Mac
      2. Setting up Xcode for OpenGL
    3. Creating the OpenGL rendering window using GLFW
    4. Setting up OpenGL using SDL on Windows
      1. Downloading the SDL library
      2. Setting up OpenGL using SDL and GLEW with absolute linking
      3. Setting up OpenGL using SDL and GLEW with relative linking
      4. Adding a DLL file to the project
    5. Setting up OpenGL using SDL on a Mac
      1. Downloading the SDL and GLEW libraries
      2. Setting up Xcode for OpenGL using SDL
    6. Creating the OpenGL rendering window using SDL
    7. Setting up OpenGL using SFML on Windows
      1. Downloading the SFML library
      2. Linking the SFML and GLEW libraries to the project
      3. Adding a DLL file to the project
    8. Setting up OpenGL using SFML on a Mac
    9. Creating the OpenGL rendering window using SFML
    10. Summary
  7. Drawing Shapes and Applying Textures
    1. Drawing a triangle
      1. Adding code to draw the shape
    2. Abstracting the shaders
      1. Creating the shader files
      2. Creating the Shader.h header file
      3. Making changes to the draw triangle code
    3. Loading and applying textures to the shape
      1. Setting up a project to use SOIL on Windows
      2. Setting up a project to use SOIL on Mac
      3. Applying texture to our shape
        1. Modifying the while loop
      4. Updating the shader files to integrate texture coordinates
    4. Summary
  8. Transformations, Projections, and Camera
    1. Transformations using GLM
      1. Setting up a project to use GLM on Windows / Mac
      2. Updating shader files
      3. Applying transformations to the objects
    2. Projections and coordinate systems
      1. Modifications to the code
        1. Making modifications to the shader files
        2. Modifications to the main code
          1. View Frustum
          2. Modifications to while loop 
          3. Orthgraphic projection
    3. Adding a Camera class to the project
      1. Creating a Camera.h header file
      2.   Making modifications to main.cpp
    4. Summary
  9. Effects of lighting , Materials and Lightmaps
    1. Adding an object and a light source
      1. Creating  lighting and lamp shader files
        1. Creating shader files for the lamp
      2. Modifying the main code to implement a cube and a light source 
        1. Modifications to the while loop
    2. Lighting up objects 
      1. Updating the shaders
        1. What are normals ?
        2. Updating the lighting.frag shader
          1.  Ambient lighting
          2. Diffuse lighting
          3. Specular lighting
      2. Minor change in Camera.h 
      3. Making changes to the main code
    3. Materials
      1. Updating shader files for Materials
      2. Making changes to the main code to add materials to our object
    4. Lightmaps
      1. Making modifications to shader files
      2. Changes to the main code to implement lightmaps
        1. Modifying while loop
    5. Summary
  10. Types of light sources and combining of lights
    1. Directional light
      1. Directional lights
      2. Making changes to main code to integrate directional light in our world
    2. Point lights
      1. The point light concept
      2. The diffuse section
      3. The specular section
      4. The attenuation section
      5. Time for changes in main.cpp
    3. Spotlight 
      1. Making changes to shader files
      2. Minor modification to Camera.h
      3. Making changes to the main code
    4. Combining light
      1. Getting the shader files ready 
      2. Making modifications void main of lighting.frag 
      3. Changes to the main code
    5. Summary 
  11. Implementing a Skybox Using a Cubemap
    1. Creating shaders for the skybox
    2. Modifications to the main.cpp file
      1. Creating the Texture.h file
      2. Adding cube mapping code to Texture.h
      3. Drawing the skybox
    3. Summary
  12. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think