   glReadPixels and GL_PIXEL_PACK_BUFFER_ARB
  Hi,I am trying to find a way to access pixel data from a frame buffer object in the video card memory faster. Here is what i am doing :I create a hidden window. I initialize OpenGL on it. I create the frame buffer object this way :void initpbuffer( void ){char *ext = (char*)glGetString( GL_EXTENSIONS );text = (unsigned char *) malloc ( 256*256 * 3);if( strstr( ext, "EXT_framebuffer_object" ) == NULL ){MessageBox(NULL,"EXT_framebuffer_object extension was not found","ERROR",MB_OK|MB_ICONEXCLAMATION);exit(-1);}else{glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)wglGetProcAddress("glBindFramebufferEXT");glBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");glBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT");glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)wglGetProcAddress("glFramebufferTexture2DEXT");glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)wglGetProcAddress("glCheckFramebufferStatusEXT");if( !glBindFramebufferEXT || !glGenFramebuffersEXT || !glFramebufferTexture2DEXT || !glFramebufferTexture2DEXT ){MessageBox(NULL,"One or more EXT_framebuffer_object functions were not found","ERROR",MB_OK|MB_ICONEXCLAMATION);exit(-1);}}   glGenFramebuffersEXT(1, &fb;   glGenTextures(1, &tex;    // texture   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);   glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex);   glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE,NULL);   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,    GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, tex, 0);glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, fb);glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, 256*256*3, NULL, GL_DYNAMIC_COPY);   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);}I draw and this is how I get the data :glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,fb); glReadPixels(0,0,256,256,GL_RGB,GL_UNSIGNED_BYTE,text);glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);However, the data that I get back is black and white, not what I need. If I comment this line glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,fb);  it looks fine, but I need the speed, so I need to speed up glReadPixels.Without GL_PIXEL_PACK_BUFFER, it takes me about 2 ms for glReadPixels to execture, with it, it is 0.02, but it is not what I want.Am I doing something wrong, is there a bug in my code ? Are there other alternatives ?If this can not be fixed, then what is a better way to use glReadPixels faster as I need the speed. Thanks.   
  Your lucky if you didn't lock up your system.I strongly suggest you read how this feature works by visiting the spechttp://www.opengl.org/registryThere is an example code in there.Notice that this fires up the DMA transfer.Then you do some other stuff for some CPU cycles, then you pick up the pixels.This allows better parallelism between CPU and GPU and that's how you get a speed up.In your case, it won't help at all plus your code is wrong.Asynchronous glReadPixels:   const int imagewidth = 640;   const int imageheight = 480;   const int imageSize = imagewidth*imageheight*4;   glGenBuffers(2, imageBuffers);   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[0]);   glBufferData(GL_PIXEL_PACK_BUFFER_ARB, imageSize / 2, NULL, GL_STREAM_READ);   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[1]);   glBufferData(GL_PIXEL_PACK_BUFFER_ARB, imageSize / 2, NULL, GL_STREAM_READ);   // Render to framebuffer   glDrawBuffer(GL_BACK);   renderScene();   // Bind two different buffer objects and start the glReadPixels   // asynchronously. Each call will return directly after   // starting the DMA transfer.   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[0]);   glReadPixels(0, 0, imagewidth, imageheight/2, GL_BGRA, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[1]);   glReadPixels(0, imageheight/2, imagewidth, imageheight/2, GL_BGRA, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));   // Process partial images.  Mapping the buffer waits for   // outstanding DMA transfers into the buffer to finish.   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[0]);   pboMemory1 = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB,   GL_READ_ONLY);   processImage(pboMemory1);   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[1]);   pboMemory2 = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB,   GL_READ_ONLY);   processImage(pboMemory2);   // Unmap the image buffers   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[0]);   glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);   glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, imageBuffers[1]);   glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);