Sign in to follow this  
glJack

EXT_PIXEL_BUFFER_OBJECT tutorial

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
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
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[i]);
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
JavaCoolDude
Thanx! Your sample really helped me to understand how this ext gets useful.

[Edited by - glJack on July 4, 2005 7:41:14 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this