OpenGL Programming

Welcome to the OpenGL Programming book. OpenGL is an API used for drawing 3D graphics. OpenGL is not a programming language; an OpenGL application is typically written in C or C++. What OpenGL does allow you to do is draw attractive, realistic 3D graphics with minimal effort. The API is typically used to interact with a GPU, to achieve hardware-accelerated rendering.

You are free, and encouraged, to share and contribute to this wikibook: it is written in the spirit of free documentation, that belongs to humanity. Feel free to make copies, teach it in school or professional classes, improve the text, write comments or even new sections.

We're looking for contributors. If you know about OpenGL, feel free to leave comments, expand TODO sections and write new ones!

Introduction

 * 1) About this book
 * 2) History and Evolution of OpenGL

Setting Up OpenGL

 * Installation on GNU/Linux
 * Installation on Macintosh
 * Installation on Windows with Code::Blocks
 * Installation for Android NDK development
 * with a GLUT-like wrapper to follow the exercises
 * Installation for iPhone development
 * Installing GLUT

Modern OpenGL
"Modern" OpenGL is about OpenGL 2.1+, OpenGL ES 2.0+ and WebGL, with a programmable pipeline and shaders.

The basics arc
Tutorial_drafts: ideas and notes for upcoming tutorials

The lighting arc
This series of tutorials is a C++ port of the GLSL wikibook Basic Lighting tutorials.

This series of tutorials is a C++ port of the GLSL wikibook Basic Texturing tutorials.

This series of tutorials is a C++ port of the GLSL wikibook tutorials about Textures in 3D.

There are more tutorials to port at the GLSL wikibook!

The scientific arc
And more to come.

Mini-portal
This series shows how to implement a teleportation system similar to Valve's Portal, step-by-step, using OpenGL.

Glescraft
This series shows how to render a voxel based world, similar to Minecraft.

Using the accumulation buffer
Note: not all videocards support accumulation buffer

Cutting-edge OpenGL
If you do not target old mobile devices or the web, you can upgrade to OpenGL (ES) 3.x / 4.x. It notably introduces new kinds of shaders: Geometry, Tessellation Control and Tessellation Evaluation, and Compute.

and lots of other features.

Appendices

 * OpenGL ES 2.0 Overview: OpenGL ES 2.0 (OpenGL for Embedded Systems 2.0) concepts and its differences to normal OpenGL
 * Migrating from 1.x to 2.x: how to upgrade your code to use modern OpenGL
 * Glossary: what do all those new weird words mean?
 * APIs, Libraries and acronyms: how all acronyms relate to each others
 * OpenGL Shading Language: elements of GLSL programming
 * Shaders reference: input and output variables list
 * Team: contributors to this wikibook
 * Download code: wikibooks-opengl code repository

Legacy OpenGL 1.x
"Legacy" OpenGL is about OpenGL 1.x and OpenGL ES 1.x, with a fixed pipeline and no shaders.

Starting Tutorial

 * 1) Setting Up A Programming Environment On Windows[[File:75%.svg]]
 * 2) Setting Up OpenGL In The Programming Environment[[File:75%.svg]]
 * 3) Drawing Primitives[[File:75%.svg]]
 * 4) Immediate Mode
 * 5) Display Lists
 * 6) Vertex Arrays
 * 7) Basic Transformations[[File:75%.svg]]
 * 8) Translation
 * 9) Rotation
 * 10) Scaling
 * 11) Custom Transformations

Basics

 * 1) Structure of a Typical OpenGL Application [[File:100%.svg]]
 * 2) Drawing Rectangles [[File:75%.svg]]
 * 3) Drawing Lines and Points
 * 4) Drawing Simple 2D Shapes [[File:100%.svg]]
 * 5) OpenGL Naming Conventions [[File:75%.svg]]
 * 6) Using Color [[File:75%.svg]]
 * 7) Viewing Transformations [[File:25%.svg]]
 * 8) Drawing Simple 3D Objects
 * 9) Perspective versus Orthographic Projections

Intermediate

 * 1) Smoothing Polygons with Normals
 * 2) Adding Lights
 * 3) Using Materials
 * 4) Using Textures
 * 5) Using Mipmaps
 * 6) Drawing Complex Polygons Using Tessellation

Advanced

 * 1) Optimizing OpenGL Code
 * 2) Drawing Shadows
 * 3) Drawing Using Quadrics
 * 4) Drawing Using NURBS and Curves
 * 5) Ambient Occlusion

Appendices

 * 1) Coordinate Transformations
 * 2) Understanding Transformation Matrices
 * 3) OpenGL Library Reference. functions and type reference for gl.h glu.h and glut.h
 * 4) Why OpenGL Exists and What It's Good For
 * 5) Migrating from 1.x to 2.x: how to upgrade your code to use modern OpenGL

Wikibooks
Related WikiBooks:
 * GLSL Programming : wikibook on the use of the OpenGL Shading Language (GLSL) in Unity 3 and Blender 2.5, with much information on lighting and texturing
 * Blender 3D: Noob to Pro: comprehensive book on using the Blender 3D modeling environment
 * an open source, cross-platform IDE's for exploring pixel based graphics on the GPU using GLSL :
 * Fragmentarium
 * Shadertoy

Ports
The following websites provide conversion of the tutorials to other programming languages or platforms:
 * Official code repository contains the main SDL2 version, but also GLUT and WebGL ports
 * port to Lightweight Java Game Library (LWJGL) (blog)
 * not really a port, but commented, progressive version of the tutorials code as the author follows them

Freely-licensed documentation and samples

 * OpenGL ES 2.0 Reference Pages: official reference man pages, SGI Free Software B License
 * Learning Modern 3D Graphics Programming: another modern OpenGL tutorial, requiring v3.3 or later, MIT license (source repository)
 * Learn OpenGL ES: Detailed, step-by-step OpenGL ES tutorials in Java for Android, and a bit of WebGL as well, CC BY-SA 3.0 license (source repository − Apache License 2)
 * OpenGL Samples Pack: written in C++ based on the "core profile" specifications, aimed at easing upgrades to new OpenGL versions and features, MIT license (http://ogl-samples.git.sourceforge.net/git/gitweb.cgi?p=ogl-samples/ogl-samples;a=tree)
 * http://www.mechcore.net/wiki/index.php?title=OpenGL_Examples: GFDL license
 * https://www.khronos.org/opengl/wiki/FAQ: GFDL license
 * OpenGLContext Python Tutorials: basic tutorials using PyOpenGL (BSD-style licenses)
 * Paul's projects: OpenGL 1.x, two tutorials on shadow mapping and bump mapping, with code under the MIT license
 * WebGL:
 * Gregg Tavares’ WebGL articles: detailed 2D and 3D basics with emphasing on matrix operations; lots of diagrams and interactive animations (source code − MIT license)
 * WebGL at Mozilla Developer Network: WebGL overview, including embedding videos; CC BY-SA for articles, MIT and public domain for source code
 * three.js: collection of demos using the three.js WebGL framework; source code is MIT but models/data may be non-free

Non-freely-licensed documentation

 * http://nehe.gamedev.net/lesson.asp?index=01: OpenGL 1.x
 * Collection of OpenGL fundamentals tutorials using C++ and Windows API: OpenGL 1.x
 * ZeusCMD OpenGL Tutorials: OpenGL 1.x
 * OpenGL Programming Examples: OpenGL 1.x,

Websites

 * OpenGL Lighting Model Tutorial with Examples
 * Official OpenGL Website
 * Mesa, an open-sourced 3D graphics library almost identical to OpenGL