I try it in this way: ( Here the most important code)

Code for the texture
Code :
...
glGenTextures(1, &textur);	
glBindTexture(GL_TEXTURE_2D, textur);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );	
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, BMP.bmWidth,  BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);

Code to get the context (Windows)
Code :
cl_context_properties props[] = { CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),  CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(), CL_CONTEXT_PLATFORM, (cl_context_properties) selectedPlatformID, 0};
 
cl_context  context = clCreateContext(properties,1, &selectedDeviceID, NULL, NULL, &err);


Code to get the texture object from OpenGL to OpenCL
Code :
imageOutObject = createFromGLTexture2D(context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D,0,textur);


Code in the main loop
Code :
 
size_t localWorkSize[2] = { 8, 8 };		
unsigned int workGroupSize = 64;		
 
size_t globalWorkSize[2] =  {width, height};
 
clSetKernelArg( kernel, 0, sizeof( imageOutObject ), &imageOutObject );
 
clEnqueueAcquireGLObjects(commands,1,&imageOutObject,0,NULL,NULL);
 
clEnqueueNDRangeKernel(commands, kernel, 2, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL);
 
clEnqueueReleaseGLObjects(commands,1,&imageOutObject,0,NULL,NULL);
clFinish(commands);
 
 
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();					
glBindTexture(GL_TEXTURE_2D, textur);
 
glBegin(GL_QUADS);
 
     glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
     glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
     glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
     glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
glEnd();
 
glFinish();
SwapBuffers(hDC);

The kernel
Code :
__kernel void kernel1(write_only image2d_t output)       
   {                                                                                                   
       int2 coordi = (int2)( get_global_id(0), get_global_i(1) );                                          
       float4 color;                                                                                   
       color = (float4)(1.0,0.0,0.0,1.0);    //set new color
       write_imagef( output,coordi , color );                                            
   }


I use a picture with many different colors for the texture and it is shown on the screen.
But changing the color with the kernel does not happen.

I get error code -5 at
clEnqueueAcquireGLObjects
and
clEnqueueReleaseGLObjects

But this error is not defined!!!!
No error shown here:
http://www.khronos.org/registry/cl/sdk/ ... jects.html

http://www.khronos.org/registry/cl/sdk/ ... jects.html

matches with my error code -5

No matter what I write in the kernel, nothing happens to the texture.


(Sorry for not perfect english)

What is wrong in my program?