clCreateContextFromType引发异常

时间:2018-12-03 22:41:19

标签: c++ opengl interop opencl

我正在使用C ++。我正在使用OpenCL 1.2,Visual Studio 13.0(Windows 7)。我正在通过《 OpenCL编程指南》这本书学习OpenCL。我在以下代码中尝试互操作OpenCl / OpenGL.n:

cl_platform_id firstPlatformId;
errNum = clGetPlatformIDs(1, &firstPlatformId, &numPlatforms);
cl_context_properties contextProperties[] =
{
    CL_CONTEXT_PLATFORM,
    (cl_context_properties)firstPlatformId,
    CL_GL_CONTEXT_KHR,
    (cl_context_properties)wglGetCurrentContext(),
    CL_WGL_HDC_KHR,
    (cl_context_properties)wglGetCurrentDC(),
    0
};

cl_uint uiDevCount;
cl_device_id* cdDevices;
// Get the number of GPU devices available to the platform
errNum = clGetDeviceIDs(firstPlatformId, CL_DEVICE_TYPE_GPU, 0, NULL, &uiDevCount);

// Create the device list
cdDevices = new cl_device_id[uiDevCount];
errNum = clGetDeviceIDs(firstPlatformId, CL_DEVICE_TYPE_GPU, uiDevCount, cdDevices, NULL);

auto clDev = &cdDevices[0];
context = clCreateContext(contextProperties, 1, clDev, NULL, NULL, &errNum);
//// alternate:
/*context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU,
    NULL, NULL, &errNum);*/

当我到达clCreateContext或clCreateContextFromType时,它将引发未处理的异常。有什么想法吗?

0 个答案:

没有答案