0% found this document useful (0 votes)
25 views

OpenGL Programming - Wikibooks, Open Books For An Open World

This document introduces OpenGL programming and provides tutorials on modern OpenGL techniques. It covers topics like basic 3D rendering, lighting, texturing, scientific visualization graphs, and more advanced techniques. The document is intended as an open source reference for learning OpenGL and encouraging contributions from the community.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

OpenGL Programming - Wikibooks, Open Books For An Open World

This document introduces OpenGL programming and provides tutorials on modern OpenGL techniques. It covers topics like basic 3D rendering, lighting, texturing, scientific visualization graphs, and more advanced techniques. The document is intended as an open source reference for learning OpenGL and encouraging contributions from the community.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

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!
Contents
Introduction
Setting Up OpenGL
Modern OpenGL
The basics arc
The lighting arc
The scientific arc
Selected topics
The post-processing arc
Mini-portal
Glescraft
Using the accumulation buffer
Cutting-edge OpenGL
Code quality
Appendices
Legacy OpenGL 1.x
Starting Tutorial
Basics
Intermediate
Advanced
Appendices
External links
Wikibooks
Ports
Freely-licensed documentation and samples
Non-freely-licensed documentation
Websites
Further reading

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 01:
Tutorial 02: adding more
newcomer's
01 02 robustness to our code,
introduction, first dive
transparency
into shaders

Tutorial 03: passing


Tutorial 04:
information to shaders:
03 04 transformation matrices:
attributes, varying and
positioning and rotating
uniforms

Tutorial 05: adding the Tutorial 06: textures:


05 3rd dimension: a cube, 06 displaying a wooden
plus a camera cube

Navigation: navigate in
OBJ format: loading
3D space and
07 Suzanne the monkey 08
manipulate objects in our
from Blender
model viewer

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.

Diffuse Reflection: about


Specular Highlights:
per-vertex diffuse lighting
01 02 about per-vertex
and multiple light sources
lighting
of different kinds

03 Two-Sided Surfaces (about 04 Smooth Specular


two-sided per-vertex Highlights (about per-
lighting) pixel lighting)
Multiple Lights (about
Two-Sided Smooth
for-loops for handling
05 Surfaces (about two-sided 06
multiple light
per-pixel lighting)
sources)
This series of tutorials is a C++ port of the GLSL wikibook Basic Texturing tutorials.

Textured Spheres: Lighting Textured Surfaces:


01 about texturing a 02 about textures for diffuse
sphere lighting

Transparent Textures: about


Glossy Textures:
using alpha textures for
03 about gloss 04
discarding fragments, alpha
mapping
testing, and blending

Layers of Textures:
05 about
multitexturing

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

Lighting of Bumpy Projection of Bumpy


01 Surfaces: about 02 Surfaces: about parallax
normal mapping mapping

Cookies: about Light Attenuation: about


projective texture texture mapping for light
03 04
mapping for shaping attenuation and lookup
light tables in general

Projectors: about
projective texture
05
mapping for
projectors
There are more tutorials to port at the GLSL wikibook!

The scientific arc

Graph 01: plotting a simple


Graph 02: plotting a
function, using vertex
01 02 graph from data in a
buffer objects and point
texture
sprites

Graph 04: plotting a


Graph 03: plotting borders
03 04 three-dimensional
and axes, clipping
graph

Graph 05: plotting a


05 surface with hidden line
removal

And more to come.

Selected topics

Bounding box: draw a


Virtual Trackball:
cube around your object
01 intuitive object rotation 02
for editing or debugging
with the mouse
purposes

Video Capture: capture


2D-on-3D: hardware-
your animation using
03 accelerated 2D 04
apitrace (C++) or
programming
JavaScript (WebGL)

Tea time: generating


Stencil buffer: masking
05 an HD teapot from 06
and combining
Bézier surfaces
Quadrics: creating
Basic text: rendering text
07 simple shapes with a 08
using the FreeType library
bit of maths

Optimized text Object selection:


rendering: using a unprojecting coordinates
09 10
texture atlas and object identification
containing all glyphs using the stencil buffer

Particle systems:
Anti-Aliasing:
11 12 differents kinds of particle
smoothing lines
systems

The post-processing arc

Concepts: how to perform full-


???: next
screen post-processing, first
01 02 effect to be
example with a simple animated
decided!
wave

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

Mini-Portal Smooth:
Mini-Portal: a first
smooth transition,
01 working see-through 02
understanding the
portal
camera
Mini-Portal Recursive:
recursive portals - Mini-Portal Optimization:
03 04
display portals within optimization with scissors
portals

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

Glescraft 2: removing
Glescraft 1: basic voxel
01 02 unnecessary voxel
rendering
faces

Glescraft 3: texturing,
Glescraft 4: first person
03 lighting, fog, 04
camera controls
transparency

Glescraft 5: drawing Glescraft 6: adding and


05 06
only what is on screen removing voxels

Glescraft 7: using
07
geometry shaders

Using the accumulation buffer

Tutorial 01: Tutorial 02: full-screen


01 02
motion blur supersampling anti-aliasing
Tutorial 03: Tutorial 04: order-independent
03 04
depth of field transparency

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.

Tutorial 01: modify and Tutorial 02: dynamic


01 create vertices on the fly 02 mesh quality with
with geometry shaders tesselation

and lots of other features.

Code quality

Debugging: tips to Performance: measuring


01 help debug your 02 and improving your
OpenGL code application performance.

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 (https://gitlab.com/wikibooks-opengl/modern-tutorials)

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
2. Setting Up OpenGL In The Programming Environment
3. Drawing Primitives
1. Immediate Mode
2. Display Lists
3. Vertex Arrays
4. Basic Transformations
1. Translation
2. Rotation
3. Scaling
4. Custom Transformations

Basics
1. Structure of a Typical OpenGL Application
2. Drawing Rectangles
3. Drawing Lines and Points
4. Drawing Simple 2D Shapes
5. OpenGL Naming Conventions
6. Using Color
7. Viewing Transformations
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

External links

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 (https://gitlab.com/wikibooks-opengl/modern-tutorials/tree/master) contains the


main SDL2 version, but also GLUT and WebGL ports
port to Lightweight Java Game Library (LWJGL) (https://github.com/alihelmy/lwjglTutorial) (blog (http://on
ehandstand.blogspot.com/search/label/OpenGL%20Wikibook%20LWJGL%20Port))
not really a port, but commented, progressive version of the tutorials code as the author follows them (htt
p://littlefootlandmines.blogspot.com/search/label/opengl%20tutorials)

Freely-licensed documentation and samples


OpenGL ES 2.0 Reference Pages (https://www.khronos.org/registry/OpenGL-Refpages/es2.0/): official
reference man pages, SGI Free Software B License
Learning Modern 3D Graphics Programming (https://paroj.github.io/gltut/): another modern OpenGL
tutorial, requiring v3.3 or later, MIT license (source repository (https://bitbucket.org/alfonse/gltut/src))
Learn OpenGL ES (http://www.learnopengles.com/): 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 (https://github.com/lear
nopengles/Learn-OpenGLES-Tutorials) − Apache License 2)
OpenGL Samples Pack (http://www.g-truc.net/project-0026.html#menu): written in C++ based on the
"core profile" specifications, aimed at easing upgrades to new OpenGL versions and features, MIT
license (source repository (http://ogl-samples.git.sourceforge.net/git/gitweb.cgi?p=ogl-samples/ogl-sampl
es;a=tree))
Introduction and examples for OpenGL 3.3 (http://www.mechcore.net/wiki/index.php?title=OpenGL_Exa
mples)Template:Fix/category: GFDL license
A modern OpenGL FAQ (https://www.khronos.org/opengl/wiki/FAQ): GFDL license
OpenGLContext Python Tutorials (http://pyopengl.sourceforge.net/context/tutorials/index.html): basic
tutorials using PyOpenGL (BSD-style licenses (http://bazaar.launchpad.net/~mcfletch/openglcontext/trun
k/view/head:/license.txt))
Paul's projects (http://www.paulsprojects.net/tutorials/tutorials.html): OpenGL 1.x, two tutorials on shadow
mapping and bump mapping, with code under the MIT license
WebGL:
Gregg Tavares’ WebGL articles (http://greggman.github.io/webgl-fundamentals/webgl/lessons/webgl-f
undamentals.html): detailed 2D and 3D basics with emphasing on matrix operations; lots of diagrams
and interactive animations (source code (https://github.com/greggman/webgl-fundamentals) − MIT
license)
WebGL at Mozilla Developer Network (https://developer.mozilla.org/en-US/docs/Web/WebGL):
WebGL overview, including embedding videos; CC BY-SA for articles, MIT and public domain for
source code
three.js (http://threejs.org/): collection of demos using the three.js WebGL framework; source code (ht
tps://github.com/mrdoob/three.js/tree/master/examples) is MIT but models/data may be non-free

Non-freely-licensed documentation
NeHe's OpenGL tutorial (http://nehe.gamedev.net/lesson.asp?index=01): OpenGL 1.x
Collection of OpenGL fundamentals tutorials using C++ and Windows API (http://www.falloutsoftware.co
m/): OpenGL 1.x
ZeusCMD OpenGL Tutorials (http://www.zeuscmd.com/): OpenGL 1.x
OpenGL Programming Examples (https://tutorialsplay.com/opengl/): OpenGL 1.x,

Websites
OpenGL Lighting Model Tutorial with Examples (http://www.falloutsoftware.com/tutorials/gl/gl8.htm)
Official OpenGL Website (http://opengl.org/)
Mesa, an open-sourced 3D graphics library almost identical to OpenGL (http://mesa3d.org/)

Further reading
OpenGL Architecture Review Board, et al: OpenGL Programming Guide: The Official Guide to Learning
OpenGL, Version 2, Fifth Edition, Addison-Wesley, ISBN 0-321-33573-2
OpenGL Architecture Review Board, et al: OpenGL Reference Manual: The Official Reference Document
to OpenGL, Version 1.4, Addison-Wesley, ISBN 0-321-17383-X
Wright, Richard S. Jr and Lipchak, Benjamin: OpenGL SuperBible, Third Edition, Sams Publishing, ISBN
0-672-32601-9
< OpenGL Programming
- Comment on this page
- Recent stats (http://stats.grok.se/en.b/
latest90/OpenGL_Programming)

Browse & download complete code (https://gitlab.com/wikibooks-opengl/modern-tutorials)

Retrieved from "https://en.wikibooks.org/w/index.php?title=OpenGL_Programming&oldid=4214162"

This page was last edited on 30 November 2022, at 07:32.

Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you
agree to the Terms of Use and Privacy Policy.

You might also like