• Advertisement
Sign in to follow this  

EXT_PIXEL_BUFFER_OBJECT tutorial

This topic is 4675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Where I can find a tutorial explaining how to use this extenstion. I googled many times, but everything I find is this ext' spec. thanx

Share this post


Link to post
Share on other sites
Advertisement
You shouldn't really expect to get much out of tutorials for this extension. It's a rather advanced feature, enabling things like particle physics on the GPU, but what you actually use it for will vary widely. The spec should be all you need; if you read the spec and find yourself scratching your head and having no idea why you'd want this stuff, you probably don't need it.

Share this post


Link to post
Share on other sites
it cant.
the pixel buffer object extension is for async upload/download of texture data to the gfx card/driver.

The framebuffer object extension is the one required for performing render to texture operations.

Share this post


Link to post
Share on other sites
Yeah, don't confuse PBO with pbuffer or FBO. It doesn't have very much at all to do with the sort of render-to-texture one uses for normal render-to-texture tasks.

Share this post


Link to post
Share on other sites
thanx for help. Now I see, why I couldn't find demos demonstrating render-to-texture using PBO :)

But when this extension can be useful? What for it has been made?

Share this post


Link to post
Share on other sites
as I said before...

Quote:
Original post by _the_phantom_
the pixel buffer object extension is for async upload/download of texture data to the gfx card/driver.


Share this post


Link to post
Share on other sites
Optimally we create two PBO client-to-server streamers per texture object:


if(GLEE_EXT_pixel_buffer_object)
{
glGenBuffers(2, pixelStreamers);
for(int i = 0; i < 2; i++)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, pixelStreamers);
glBufferData(GL_PIXEL_UNPACK_BUFFER_EXT, textureWidth*textureHeight*colorChannelsCount*sizeOfASingleChannelInBytes, NULL, GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
}
}





In the following code, the tickTock variable is of type bool, we use it to alternate the PBO streamers per-frame again for optimal performance.


void* pboMemory = NULL;
tickTock = !tickTock;

glBindTexture(yourTextureType, yourTextureID);

if(pixelStreamers[tickTock])
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, pixelStreamers[tickTock]);
pboMemory = glMapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY);
memcpy(pboMemory, videoData, textureWidth*textureHeight*colorChannelsCount*sizeOfASingleChannelInBytes);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT);

//Notify texture object of the new update
glTexSubImage2D(getTarget(), 0, 0, 0, textureWidth, textureHeight, yourTextureFormat, yourTextureDataType, NULL);
//Shut the streamer off
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
}



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement