To use the Interoperation function we need to include the cl_gl.h
header file. This header contains declaration of the required function for interoperation.
Before discussing other implementation steps, we try to detect whether the current environment supports this interoperation. We use the OpenCL API clGetDeviceInfo(…)
for this purpose. The first call would get the total size needed to store the string (char*
) returned by the second call. This string is a list of all the device extensions that are supported by the current environment. We then try to find from this list, whether it has an item called cl_khr_gl_sharing
for Windows and Linux and cl_apple_gl_sharing
for Mac. Its presence would indicate the support of OpenCL-OpenGL interoperation, otherwise not.
Find the size of device info string in a variable sizeOfExtensionString
called which is of type size_t
as follows:
size_t sizeOfExtensionString; cl_int errorStatus...