PDA

View Full Version : Texture failed to bind after glBindBufferARB()



georgeou
12-16-2009, 07:34 AM
I am using to PBO to accelerate the loading webcam image in openGL,however,after I have call the glBindBufferARB(),I failed to bind other texture to my mesh.No matter what I tried,it is always binding the webcam image.
Here is my codes,can anyone give me some ideas?

cutilSafeCall(cudaGLMapBufferObject((void**)&dd_re sult, pbo2));
gaussianFilterRGBA(dd_image, dd_result, dd_temp, width1, height1, sigma1,order, nthreads);
cutilSafeCall(cudaGLUnmapBufferObject(pbo2));
//Second Gaussian
cutilSafeCall(cudaGLMapBufferObject((void**)&dd_re sult1, pbo));
gaussianFilterRGBA(dd_image, dd_result1, dd_temp1, width1, height1, sigma2,order, nthreads);
cutilSafeCall(cudaGLUnmapBufferObject(pbo));


glEnable(GL_TEXTURE_2D);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo2);
glActiveTextureARB( GL_TEXTURE0_ARB );
glBindTexture(GL_TEXTURE_2D, texid2);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width1, height1, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

glEnable(GL_TEXTURE_2D);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
glActiveTextureARB( GL_TEXTURE1_ARB );
glBindTexture(GL_TEXTURE_2D, texid);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width1, height1,GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);


glLoadIdentity();
camera1->ResizeWindow();

glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);

glBegin(GL_QUADS);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f,1.0f );
glVertex3f(-camera1->aspect, -1,-2);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 1.0f );
glVertex3f(camera1->aspect, -1,-2);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 0.0f );
glVertex3f(camera1->aspect, 1,-2);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 0.0f );
glVertex3f(-camera1->aspect, 1,-2);
glEnd();

glActiveTextureARB( GL_TEXTURE2_ARB );
glBindTexture( GL_TEXTURE_2D, texCol0);//Failed to bind //textures now

drawFish();

Brolingstanz
12-16-2009, 10:04 AM
Don't you need to pack the buffer at some point before processing ? You might check the CUDA SDK postProcessGL demo for a complete example.