Creating context using multiple devices from openGL context

What I want to do is

Render a Image using openGL

process the image using several CL devices.

However I run into problems when trying to create context that contains several devices when i create the context from OpenGL.

My code look like this:

cl_int err;


	cl_platform_id platforms[10];

	cl_uint nrPlatforms;

	err = clGetPlatformIDs(10, platforms,&nrPlatforms );


	cl_uint maxDevices = 100;

	cl_device_id* devices = new cl_device_id[maxDevices];

	cl_uint nrDevices;

	err = clGetDeviceIDs(platforms[0], deviceType, maxDevices, devices, &nrDevices);



	cl_context_properties props[] = 


		CL_GL_CONTEXT_KHR, gcAdapter->getCL_GL_CONTEXT_KHR(), // The gl context handel

		CL_WGL_HDC_KHR,  gcAdapter->getCL_WGL_HDC_KHR(), // 



	cl_context gl_to_cl_context;

	gl_to_cl_context = clCreateContext(props, nrDevices, 

		devices, NULL, NULL, &err);



	// Set the context

	_context = gl_to_cl_context;

if i replace

gl_to_cl_context = clCreateContext(props, nrDevices, 

	devices, NULL, NULL, &err);


gl_to_cl_context = clCreateContext(props, 1, 

	devices[0], NULL, NULL, &err);


gl_to_cl_context = clCreateContext(props, 1,

	devices[1], NULL, NULL, &err);

No error is reported and everything is working.

But I whant to use several devices :sweat: or:

Is it even possible to use several devices operating on gl Recourses?

OS: is XP

cards: 2x NVIDIA GTX 480

cl driver: 197.41

cl develop: cuda 3.0

Im using osg to handle openGL calls

I have exactly the same problem now that I got my 2 cards to work. My confusion begins right here:

In my case this also works and the ouput of an OpenCL program that shares buffers with OpenGL produces the correct results in each case. However, only device[0] is actually hooked up to the monitor!! It seems to me that even if you create a context with only one of the devices, both cards are picking up all of the OpenCL commands. Actually both cards are also picking up the wgl and gl calls. i.e. a call to wglCreateContext creates a context on both cards. That is the only way how I can explain that my monitor shows me the same reuslts regadless of which device I am using. So, basically both cards work in unicense.

That now leaves me with the question of how to use the two cards for different purposes. I,e. one for OpenGL and maybe some OpenCL kernels that require interoperability, and another card for some visualizaiton unrelated OpenCL computation ?