Introduction

Introduction

Getting started OpenGL Creating a window Hello Window Hello Triangle Shaders Textures Transformations Coordinate Systems Camera Review

OpenGL

OpenGL

Creating a window

Creating a window

Hello Window

Hello Window

Hello Triangle

Hello Triangle

Shaders

Shaders

Textures

Textures

Transformations

Transformations

Coordinate Systems

Coordinate Systems

Camera

Camera

Review

Review

Lighting Colors Basic Lighting Materials Lighting maps Light casters Multiple lights Review

Colors

Colors

Basic Lighting

Basic Lighting

Materials

Materials

Lighting maps

Lighting maps

Light casters

Light casters

Multiple lights

Multiple lights

Review

Review

Model Loading Assimp Mesh Model

Assimp

Assimp

Mesh

Mesh

Model

Model

Advanced OpenGL Depth testing Stencil testing Blending Face culling Framebuffers Cubemaps Advanced Data Advanced GLSL Geometry Shader Instancing Anti Aliasing

Depth testing

Depth testing

Stencil testing

Stencil testing

Blending

Blending

Face culling

Face culling

Framebuffers

Framebuffers

Cubemaps

Cubemaps

Advanced Data

Advanced Data

Advanced GLSL

Advanced GLSL

Geometry Shader

Geometry Shader

Instancing

Instancing

Anti Aliasing

Anti Aliasing

Advanced Lighting Advanced Lighting Gamma Correction Shadows Shadow Mapping Point Shadows Normal Mapping Parallax Mapping HDR Bloom Deferred Shading SSAO

Advanced Lighting

Advanced Lighting

Gamma Correction

Gamma Correction

Shadows Shadow Mapping Point Shadows

Shadow Mapping

Shadow Mapping

Point Shadows

Point Shadows

Normal Mapping

Normal Mapping

Parallax Mapping

Parallax Mapping

HDR

HDR

Bloom

Bloom

Deferred Shading

Deferred Shading

SSAO

SSAO

PBR Theory Lighting IBL Diffuse irradiance Specular IBL

Theory

Theory

Lighting

Lighting

IBL Diffuse irradiance Specular IBL

Diffuse irradiance

Diffuse irradiance

Specular IBL

Specular IBL

In Practice Debugging Text Rendering 2D Game Breakout Setting up Rendering Sprites Levels Collisions Ball Collision detection Collision resolution Particles Postprocessing Powerups Audio Render text Final thoughts

Debugging

Debugging

Text Rendering

Text Rendering

2D Game Breakout Setting up Rendering Sprites Levels Collisions Ball Collision detection Collision resolution Particles Postprocessing Powerups Audio Render text Final thoughts

Breakout

Breakout

Setting up

Setting up

Rendering Sprites

Rendering Sprites

Levels

Levels

Collisions Ball Collision detection Collision resolution

Ball

Ball

Collision detection

Collision detection

Collision resolution

Collision resolution

Particles

Particles

Postprocessing

Postprocessing

Powerups

Powerups

Audio

Audio

Render text

Render text

Final thoughts

Final thoughts

Guest Articles How to publish 2020 OIT Introduction Weighted Blended Skeletal Animation 2021 CSM Scene Scene Graph Frustum Culling Tessellation Height map Tessellation DSA 2022 Compute Shaders Introduction Phys. Based Bloom Area Lights

How to publish

How to publish

2020 OIT Introduction Weighted Blended Skeletal Animation

OIT Introduction Weighted Blended

Introduction

Introduction

Weighted Blended

Weighted Blended

Skeletal Animation

Skeletal Animation

2021 CSM Scene Scene Graph Frustum Culling Tessellation Height map Tessellation DSA

CSM

CSM

Scene Scene Graph Frustum Culling

Scene Graph

Scene Graph

Frustum Culling

Frustum Culling

Tessellation Height map Tessellation

Height map

Height map

Tessellation

Tessellation

DSA

DSA

2022 Compute Shaders Introduction Phys. Based Bloom Area Lights

Compute Shaders Introduction

Introduction

Introduction

Phys. Based Bloom

Phys. Based Bloom

Area Lights

Area Lights

Code repository

Code repository

Translations

Translations

Privacy

Privacy

About

About

Welcome to OpenGL

Welcome to the online book for learning OpenGL! Whether you are trying to learn OpenGL for academic purposes, to pursue a career or simply looking for a hobby, this book will teach you the basics, the intermediate, and all the advanced knowledge using modern (core-profile) OpenGL. The aim of LearnOpenGL is to show you all there is to modern OpenGL in an easy-to-understand fashion with clear examples, while also providing a useful reference for later studies.

So why read these chapters?

Throughout the internet there are thousands of documents, books, and resources on learning OpenGL, however, most of these resources are only focused on OpenGL's immediate mode (commonly referred to as the old OpenGL), are incomplete, lack proper documentation, or are not suited for your learning preferences. Therefore, my aim is to provide a platform that is both complete and easy to understand.

Image of smiling textured containers in OpenGL

If you enjoy reading content that provides step-by-step instructions, clear examples, and that won't throw you in the deep with millions of details, this book is probably for you. The chapters aim to be understandable for people without any graphics programming experience, but are still interesting to read for the more experienced users. We also discuss practical concepts that, with some added creativity, could turn your ideas into real 3D applications. If all of the previous sounds like someone that could be you, then by all means, please continue.

What will you learn?

The focus of these chapters are on Modern OpenGL. Learning (and using) modern OpenGL requires a strong knowledge of graphics programming and how OpenGL operates under the hood to really get the best of your experience. So we will start by discussing core graphics aspects, how OpenGL actually draws pixels to your screen, and how we can leverage that knowledge to create some funky looking effects.

On top of the core knowledge we will discuss many useful techniques that you can use for your applications, like: traversing a scene, create beautiful lighting, load custom-made objects from a modelling program, do cool post-processing techniques, and much more. We also feature a walkthrough series where we actually create a small game based on our obtained OpenGL knowledge, so you will really get a feel of what it's like to actually do graphics programming.

Where to start

Learn OpenGL is free, and will always be free, for anyone who wants to start with graphics programming. All content is available here at the menu to your left. Simply hit the Introduction button and you're ready to start your journey!

Learn OpenGL - print edition

Image of physical front cover

The content has been thoroughly revised, numerous times, over the course of 7 years to have finally been aggregated into a physical copy available for print. There's been a lot of work put into the physical copy, treating it as the first-class citizen it is. Both the book and website are equals, their content is the same.

As everything is freely available online, getting the physical copy supports me as an author; and let's not forget that certain charm of printed paper. The book is available for sale on Amazon US, Amazon UK, Barnes & Noble, and many other (online) retailers. Note that at some retailers the book is

ridiculously overpriced; make sure it matches roughly $60 US dollars, or wait a bit untill the prices balance themselves out.

Amazon US

Amazon UK

Barnes & Noble

Learn OpenGL - online print edition - Free PDF

Image of book in PDF format

I've revised the source files for the physical print edition and cleaned them up to be available for online reading as well, for those that prefer its content in a singular PDF format. Use this format if you'd like to read during travel, write notes, or print it out yourself. In similar style to the website, this version is, and will always be, freely available.

Note that, similar to the physical copy, links/urls are written out fully or as footnotes, videos show static images, and there's no function hover pop-ups; all to account for the content being mostly offline.

If you want to keep up to date on the site and book's progress and/or other LearnOpenGL news, please follow me on Twitter.

Twitter