Appendix B. Real-time rendering with OpenGL
The names resemble each other, but OpenCL and OpenGL serve very different purposes. While OpenCL is used for general computation, OpenGL (Open Graphics Language) is concerned with rendering 3-D graphics. By rendering, I mean that OpenGL accepts a model composed of three-dimensional figures and produces a two-dimensional array of pixels that can be drawn in a window. This rendering executes in a loop, and if the properties of the figures change, the renderer will update the drawing. Figure B.1 provides an example of a static rendering.
All the pixels in this figure have colors, but it would be tedious to set each color separately. Instead, the application defines three-dimensional points, called vertices, and routines to be invoked during the rendering, called shaders. As the application runs, the shaders process the vertices and draw the pixels in the window.
Despite their different purposes, OpenGL applications operate similarly to OpenCL applications. As explained throughout this book, an OpenCL application consists of two parts: a host application and a kernel. The host application initializes input data, packages it, and sends it to a device. The kernel processes the data as it executes on the device.