Quantcast
Channel: Intel® Software - OpenCL*
Viewing all articles
Browse latest Browse all 1182

Problem with OpenCL and OpenGL Interoperability

$
0
0

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-openc...

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.

Thread Topic: 

Help Me

Viewing all articles
Browse latest Browse all 1182

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>