Chapter 15. Combining OpenCL and OpenGL

 

This chapter covers

  • The functions needed to configure OpenGL-OpenCL interoperability
  • A method for coding OpenGL-OpenCL applications
  • Rendering animated models with OpenGL and OpenCL

One of OpenCL’s greatest strengths is that it can accelerate applications based on OpenGL, the cross-platform API for 3-D rendering. The end goal of an OpenGL application is to compute two-dimensional arrays of numbers that correspond to pixel colors. These pixels must be computed quickly—on a high-resolution display, the application may need to compute hundreds of thousands of colors for each new frame.

Note

The content of this chapter assumes a basic familiarity with OpenGL 3.3 or above and shader development. Appendix B introduces both topics. In addition, the code in this chapter will only compile on systems that support OpenGL 3.3 or above.

Hardware-accelerated OpenGL applications rely partly on a CPU and partly on a GPU. For example, the CPU may set vertex colors and texture coordinates, and the GPU will process the CPU’s data to obtain pixel colors. In a physics application, the CPU may solve the kinematic equations needed to determine a projectile’s trajectory, and the GPU will transform the vertices needed to depict the object’s motion.

15.1. Sharing data between OpenGL and OpenCL

15.2. Obtaining information

15.3. Basic interoperability example

15.4. Interoperability and animation

15.5. Summary

sitemap