Hi Im using 9800GT on windows platform, using Visual studios for coding. Im trying to use OpenGL to increase my display rate but there has been a problem on the pixel buffer. Following is my code.
void createVBO(GLuint* pixel_buffer, struct cudaGraphicsResource **cuda_pixel_resource){
if(pixel_buffer){ // create buffer object
glGenBuffers(1, pixel_buffer);
glBindBuffer(GL_ARRAY_BUFFER, *pixel_buffer); //register buffer on cuda
unsigned int size = XDIM * YDIM * 4 * sizeof(float);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CUT_CHECK_ERROR(cudaGraphicsGLRegisterBuffer(cuda_pixel_resource, *pixel_buffer, cudaGraphicsMapFlagsWriteDiscard)); }
else{ cutilSafeCall( cudaMalloc( (void **)&d_vbo_buffer, XDIM*YDIM*4*sizeof(float) ) ); }}
int main(int argc, char *argv[]) {
// Pre-Calculation
readData();
convertor(); //convert values into single float
calc_resample_coefficients();
// Explicitly set device
glutInit(&argc, argv);
glewInit();
int device;
cudaGLGetDevice(&device)
cudaGLSetGLDevice(device);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
glutInitWindowSize(window_width, window_height);
glutCreateWindow("Cuda GL Interop (VBO)");
glutDisplayFunc(display); // Create buffer object and register it with CUDA
createVBO(&pbo, &cuda_pbo_resource); // Loop
glutMainLoop();
deleteVBO();
cudaThreadExit();}
Im having a error saying at CUT_CHECK_ERROR(cudaGraphicsGLRegisterBuffer(cuda_pixel_resource, *pixel_buffer, cudaGraphicsMapFlagsWriteDiscard)); of the following code.
I tryed to google whats going on but I wasnt able to find that matches to my error. Can somebody help me? Thank you