Simple pbo usage question

Hi, Dear All!

I’ve now stuck on a point of dealing with pbo object.

I’ve written the following code,


GLubyte data[width*height];

glGenBuffers(1,&pixelPackBuffer);
glBindBuffer(GL_PIXEL_PACK_BUFFER,pixelPackBuffer);
glBufferData(GL_PIXEL_PACK_BUFFER,width*height,data,GL_STATIC_READ);
glReadPixels(0,0,width,height,GL_STENCIL_INDEX,GL_UNSIGNED_BYTE,BUFFER_OFFSET(0));

but when I insert a breakpoint to view the content of the array data, found nothing was read. Any idea?
Thanks in advance!

You passed ‘data’ to glBufferData, which means that the buffer is initialized with the stuff in ‘data’, not that ‘data’ is your buffer object. Your buffer object’s memory is in video memory, you have to read it with glGetBufferSubData or by reading the mapped pointer after a call to glMapBuffer[Range].

If you want your own allocated memory (in this case ‘data’) to be the backing store of the buffer itself then you have to take a look at the AMD_pinned_memory extension, as that would allow you to do so. But I suppose that’s not what you wanted to do here, just you misunderstood how buffer objects work.

[QUOTE=aqnuep;1246015]You passed ‘data’ to glBufferData, which means that the buffer is initialized with the stuff in ‘data’, not that ‘data’ is your buffer object. Your buffer object’s memory is in video memory, you have to read it with glGetBufferSubData or by reading the mapped pointer after a call to glMapBuffer[Range].

If you want your own allocated memory (in this case ‘data’) to be the backing store of the buffer itself then you have to take a look at the AMD_pinned_memory extension, as that would allow you to do so. But I suppose that’s not what you wanted to do here, just you misunderstood how buffer objects work.[/QUOTE]

Hi, Dear aqneup!

You solved my question. And you seem to be very familiar with AMD’s opengl extension. Are you an employee of AMD? Can you tell me where to get ati cards’ additional development kit or tools? I have searched the http://wwwd.amd.com but found no portal to such tools. Can you give me a linkage to that?

Best Regards,

newbiecow