This course uses JavaScript because web-based graphics is easier with it.
Although JavaScript is less efficient than C++, the serious graphics computing is done on the graphics card.
The OpenGL API for C++ is quite similar to JavaScript's. Instead of the JavaScript framework, you need a C++ toolkit to provide the the higher level functions that OpenGL chose not to provide. This includes creating windows. GLUT is one such toolkit. It is widely used but old. There are other newer ones.
Why is this course different?
Shader-based
Most computer graphics use OpenGL but still use fixed-function pipeline, don't require shaders, do not make use of the full capabilities of the graphics processing unit (GPU)
Web: With HTML5, WebGL runs in the latest browsers. Makes use
of local hardware, No system dependencies.
Long history of attempts at a good API described in text.
OpenGL, 1992:
platform-independent API that was
Easy to use
Close enough to the hardware to get excellent performance
Focus on rendering
Omitted windowing and input to avoid window system dependencies
OpenGL evolution
Originally controlled by an Architectural Review Board (ARB)
Members included SGI, Microsoft, Nvidia, HP, 3DLabs, IBM,…….
Now Kronos Group
Was relatively stable (through version 2.5)
Backward compatible
Evolution reflected new hardware capabilities
3D texture mapping and texture objects
Vertex and fragment programs
Allows platform specific features through extensions
Modern OpenGL
#. Performance is achieved by using GPU rather than CPU
#. Control GPU through programs called shaders
#. Application’s job is to send data to GPU
#. GPU does all rendering
Immediate Mode Graphics
Geometry specified by vertices
#. Locations in space (2 or 3 dimensional)
#. Points, lines, circles, polygons, curves, surfaces
Immediate mode
#. Each time a vertex is specified in application, its location is sent to the GPU
#. Old style uses glVertex
#. Creates bottleneck between CPU and GPU
#. Removed from OpenGL 3.1 and OpenGL ES 2.0
Retained Mode Graphics
Put all vertex attribute data in array
Send array to GPU to be rendered immediately
Almost OK but problem is we would have to send array over each time we need another render of it
Better to send array over and store on GPU for multiple renderings
OpenGL 3.1
Totally shader-based
No default shaders
Each application must provide both a vertex and a fragment shader
No immediate mode
Few state variables
Most 2.5 functions deprecated
Backward compatibility not required
Exists a compatibility extension
Other Versions
OpenGL ES
Embedded systems
Version 1.0 simplified OpenGL 2.1
Version 2.0 simplified OpenGL 3.1
Shader based
WebGL
Javascript implementation of ES 2.0
Supported on newer browsers
OpenGL 4.1, 4.2, …..
Add geometry, tessellation, compute shaders
Source of much of this material: slides accompanying the text.
Reading assignment: Angel, chapter 1.
Homework 1 is online; due next Thurs. xxxxxxxxxxxxxxxxxxxxxxxx