I want to interop Opencl and Opengl and my device have cl_khr_gl_sharing extention but when I create context has error CL_OUT_OF_RESOURCES
cl_uint num_platforms;
err = clGetPlatformIDs(1, NULL, &num_platforms);
if(err < 0) {
perror("Couldn't find any platforms.");
exit(1);
}
platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id) * num_platforms);
err = clGetPlatformIDs(num_platforms, platforms, NULL);
if(err < 0) {
printf("clGetPlatformIDs %s",get_error_string(err));
system("pause");
//perror("Couldn't create a context");
//exit(1);
}else{
printf("Create Plateform Success
");
}
cl_uint num_devices;
err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 1, NULL, &num_devices);
if(err < 0) {
perror("Couldn't find any devices");
exit(1);
}
devices = (cl_device_id*)malloc(sizeof(cl_device_id) * num_devices);
err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU,num_devices, devices, NULL);
if(err < 0) {
printf("clGetDeviceIDs %s",get_error_string(err));
system("pause");
//perror("Couldn't create a context");
//exit(1);
}else{
printf("Create Device Success
");
}
cl_context_properties props[] =
{
CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties>(platforms[0]),
CL_GL_CONTEXT_KHR, reinterpret_cast<cl_context_properties>(wglGetCurrentContext() ),
CL_WGL_HDC_KHR, reinterpret_cast<cl_context_properties>( wglGetCurrentDC() ),
0
};
context = clCreateContext(props, 1, &devices[0], NULL, NULL, &err);
if(err < 0) {
printf("//// %s",get_error_string(err));
system("pause");
//perror("Couldn't create a context");
//exit(1);
}
And output is
Create Platform Success
Create Device Success
//// CL_OUT_OF_RESOURCES
But When I create context with
clCreateContext(NULL, 1, &devices[0], NULL, NULL, &err);
Context can create. Does anybody have any suggestions?
Thank
Wijuk