Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Interfacing OpenCL and OpenGL isn’t particularly difficult, but because there are so many data structures and functions involved, it can be hard to keep your code organized. The goal of this section is to present a method for structuring OpenGL-OpenCL code that can be used in different applications. This method will be used throughout this chapter and chapter 16.
To introduce the method, this section will present an application that draws three squares in a 3-D model. This is similar to the three_squares application from appendix B, but the Ch15/basic_interop code uses an OpenCL kernel to set the coordinates and colors of the vertices. This isn’t exciting as 3-D applications go, but once you see how the code works, you’ll be able to extend the method to support more interesting applications.