Course list http://www.c-jump.com/bcc/
Tutorials
people.freedesktop.org/~idr/OpenGL_tutorials
Intro to GLSL, Vertex Shader Inputs, Fragment shader, and Uniforms
by Ian Romanick, Intel (Highly recommended!)
opengl-tutorial.org
Tutorials for OpenGL 3.3 and later, ground-up approach
opengl.org/sdk/docs/tutorials/ClockworkCoders
Tutorial focusing on the OpenGL Shading Language
swiftless.com
Swiftless Tutorials By Donald Urquhart
Shaders -- Matrices -- Vertex Array Objects (VAOs) --Vertex Buffer Objects (VBOs)
user.xmission.com/~nate/tutors.html
Executable programs demonstrating concepts of 3D transformations, camera position, and light position.
Sample code and libraries
www.g-truc.net/project-0026.html
OpenGL Samples Pack
opengl.org
coding resources and libraries
Rendering: the entire process of drawing an image to the screen
Vertex: a single 3D point (x, y, z)
Face: Most often 3 vertices forming a triangle
Transformations: moving one or more vertices in 3D space
Translate: moving vertices along the x, y or z axis
Rotate: revolving vertices around the x, y or z axis
Scale: increasing/decreasing the distance of vertices from their center
Modeling Matrix: mathematical structure for holding transformations
View Matrix: another matrix for an observer's eye (or camera)
Projection matrix: matrix for getting 3D scene projected into a small one-unit cube
Rasterization: the final phase of rendering -- painting actual pixels on the screen
We have several 3D spaces to consider:
Local/Object - the coordinate system the mesh was modeled in
World - the coordinate system of the virtual environment
View/Camera - the coordinate system relative to the camera
Clip - windowing system
We use mathematics to transform vertices from one space to another
Open source Graphics Language
Cross-platform (MacOS, Windows, Linux using Mesa3D)
Was owned by an industry board (the ARB – Architecture Review Board) and now it is the Khronos group
Originally developed by Silicon Graphics, Inc. (SGI)
Read more on OpenGLBook.com
Not a programming language -- an Application Programming Interface (API)
Includes GLSL (GL Shading Language) – a C-like language for rendering on the GPU
OpenGL generally is not for GPGPU, General-purpose computing on graphics processing units, but some can be done Mesa ( www.mesa3d.org/ ) is an open-source software implementation of OpenGL
v 1.0-1.5...Fixed function pipeline, 1992 – 2003
v 2.0.......Programmable pipeline, 2004 – 2006
v 3.0-3.3...Programmable buffers (not backward compatible) 2008 – 2010
v 4.0-4.x...2010 - current
OpenGL is a state machine that uses a client/server model
Our C/C++ program is the client
The hardware (GPU driver) is the server
Client sends commands to the server
This is what GLEW ( glew.sourceforge.net/ ) does – asks the driver for pointers to all the gl functions
GL – The Graphics Library (opengl32.lib and DLL)
GLUT – OpenGL "Utility Toolkit" for system-independent windows, which also accepts user input (keyboard and mouse). We use FreeGLUT freeglut.sourceforge.net
GLEW ( glew.sourceforge.net/ ) The GL "Extension Wrangler" for determining which vendor extensions are available and loading them
GLM ( www.g-truc.net ) OpenGL Mathematics Library
Others are:
SDL ( www.libsdl.org )
GLX ( en.wikipedia.org/wiki/GLX ) X-Windows interface
WGL for Windows
Function names begin with gl or glut
Data types usually begin with GL:
GLboolean...1 bit GLsizei.....2 bits GLbyte......8 bits GLubyte.....8 bits unsigned GLchar......8 bits GLshort....16 bits GLushort...16 bits unsigned GLint......32 bits GLuint.....32 bits unsigned GLenum.....32 bits GLfloat....32 bits GLdouble...64 bits GLint64....64 bits
Constants start with GL_. e.g. GL_TRIANGLES
Because of Client/Server architecture, OpenGL can be hard to debug.
Note: invalid function calls are quietly disregarded
Best advice: apply small changes, compile and test often.
Use glGetError() to determine which error has occurred:
GL_NO_ERROR GL_INVALID_OPERATION // your command is ignored!! GL_INVALID_ENUM GL_INVALID_VALUE GL_OUT_OF_MEMORY
For example,
GLenum error_code = glGetError(); if ( error_code != GL_NO_ERROR ) { /*...*/ }
In OpenGL, we are always turning features on and off with glEnable() and glDisable()
By default, everything is disabled
For example:
glEnable( GL_DEPTH_TEST ); . . . glDisable( GL_DEPTH_TEST );
Note: you can always determine if something is on with
GLboolean glIsEnabled( GLenum );
All colors in OpenGL are comprised of three primary color components and alpha component:
Red, Green, Blue, and Alpha
Each component can be specified in two separate ranges
0 - 255 0.0f - 1.0f
For examples,
Red = { 255, 0, 0 } Green = { 0, 255, 0 } Blue = { 0, 0, 255 }
Meaning of alpha values in colors:
0.0 == 100% transparency
1.0 == 100% opacity
Red ( 1.0, 0.0, 0.0, 1.0 ) Blue ( 0.0, 0.0, 1.0, 1.0 ) Purple ( 1.0, 0.0, 1.0, 1.0 ) Yellow ( 1.0, 1.0, 0.0, 1.0 ) White ( 1.0, 1.0, 1.0, 1.0 ) Black ( 0.0, 0.0, 0.0, 1.0 ) Grey ( 0.5, 0.5, 0.5, 1.0 ) Brown ( 0.7, 0.5, 0.1, 1.0 )
Lighting is complex -- uses math to calculate light intensity
Based on approximations to real-world lighting
OpenGL supports the idea of:
Camera (View) – using a matrix
Light sources – using an array
Normals of a triangle
OpenGL Graphics Pipeline includes
Vertex Processing
Clipping/Assembly
Rasterization
Fragment Processing
Transform vertices using math
Calculate light for a vertex
Determine vertex color
PROGRAMMABLE: Vertex shaders can do all this
Assemble vertices into triangles
Clip triangles if they straddle viewport
Programmable with Geometry shaders
Scanline converting (visible surface determination), see Scanline rendering on wikipedia
Output is a set of uncolored fragments
Works on a fragment (pixel candidate)
Determins the color of each pixel, including
lighting,
materials, and
color information
Programmable with Fragment shaders