something wrong with OpenGL interoperate

My kernel function needs to get the OpenGL buffer data to do something…
When I call the “cudaGLRegisterBufferObject”…
It shows “Cuda error in file ‘’ in line 383 : invalid resource handle.”
I have checked it for many times…
But…nothing happened… :no:

Does anyone know how to solve it…?

*************** My Program ********************

============= Host =================

//*** Create 2 OpenGL Buffer Object and ***//
GLuint *texname = NULL ;
texname = (GLuint )malloc(2sizeof(GLuint));
glBindTexture(GL_TEXTURE_2D, texname[0]);
glBindTexture(GL_TEXTURE_2D, texname[1]);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,

//*** call function from *.cu ***//
Test_cu_function (texname ) ;

//============ *.cu ==================

void Test_cu_function (GLuint *Tex )
CUDA_SAFE_CALL(cudaGLRegisterBufferObject(Tex [0])); //<—ERROR
CUDA_SAFE_CALL(cudaGLRegisterBufferObject(Tex [0]));

Hi, you are using the interoperability in a wrong way. The ‘postProcessGL’ example of the SDK explains how to use the interoperability with OpenGL

I have checked “postProcessGL” project and
tested my program for many times…
But the problem still existed…

My OpenGL Texture memory is 2D…
So…that’s because I can’t call the “cudaGLRegisterBufferObject” successfully?


cudaGLRegisterBufferObject needs a pixelBufferObject as a parameter, not a texture name.

You have to create a pixel buffer object and copy the image to it.

GLuint* bufferObject;

glGenBuffers(1, bufferObject);

glBindBuffer(GL_ARRAY_BUFFER, *bufferObject);