- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
I'm following this example to create a project, which uses OpenCL and OpenGL.
https://software.intel.com/en-us/articles/sharing-surfaces-between-opencl-and-opengl-43-on-intel-processor-graphics-using-implicit
I had to change a few things, but clCreateFromGLTexture function returns CL_INVALID_CONTEXT.
Creating context:
//get the GL rendering context
HGLRC hGLRC = wglGetCurrentContext();
//get the device context
HDC hDC = wglGetCurrentDC();
cl_context_properties properties[] =
{
CL_GL_CONTEXT_KHR, (cl_context_properties)hGLRC,
CL_WGL_HDC_KHR, (cl_context_properties)hDC,
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[0],
0
};
//create an OCL context using the context properties
cl_context context = clCreateContext(properties, numDevices, &devices[0], NULL, NULL, &status);
checkStatus("clCreateContext", status); //here status is cl_success
//create a texture object and assign data to it
GLuint texture;
glGenTextures(1, &texture);
//bind the texture
glBindTexture(GL_TEXTURE_2D, texture);
//allocate storage for texture data
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 600, 600, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
//specify data
glTexSubImage2D(GL_TEXTURE_2D,
0, //mip map level, in this case we only have 1 level==0
0, 0, //subregion offset
300, 300, //width and height of subregion
GL_RGBA, GL_UNSIGNED_BYTE,
texture); //works! We specify initial data
size_t global_dim[2];
global_dim[0] = 300;
global_dim[1] = 300;
cl_mem sharedMemObject = clCreateFromGLTexture(context, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, texture, &status);
Can anybody help me with this?
I'm using Intel Atom E3845 with the latest driver.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Were you able to get any other OpenCL samples running on this system? https://software.intel.com/en-us/intel-opencl-support/code-samples
How about any OpenGL examples?
Just want to make sure your environment is fully set up as a first step. If those both work, will the original example code compile and run? If not, what did you need to change?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank You for the reply!
I've already solved the problem. I had to create the OpenGL Texture before the properties array, because wglGetCurrentContext() couldn't return it, since it was created later.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page