PDA

View Full Version : Simple pbo usage question



newbiecow
12-19-2012, 01:15 PM
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,dat a,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!

aqnuep
12-19-2012, 01:45 PM
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 (http://www.opengl.org/registry/specs/AMD/pinned_memory.txt) 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.

newbiecow
12-21-2012, 06:59 AM
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 (http://www.opengl.org/registry/specs/AMD/pinned_memory.txt) 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.


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