Sign in to follow this  
MARS_999

PBO to update a single texture

Recommended Posts

MARS_999    1627
I am not sure if this is the correct way to update a PBO for streaming data to a texture, but when I update the texture nothing happens vs. is I use glTexSubImage2D I get results without the PBO....


[code]
void Setup(void)
{
glGenBuffers(1, &pbo);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER, vertRows * vertCols * sizeof(float), 0, GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}

void UpdateHeight(const std::vector<float>& h, GLintptr offset)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, offset, h.size() * sizeof(float), &h[0]);
glBindTexture(GL_TEXTURE_2D, heightmapTexID);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, vertCols, vertRows,
GL_LUMINANCE32F_ARB,
GL_FLOAT, GL::BUFFER_OFFSET(0));
/*float* ptr = (float*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
if(ptr)
{
memcpy(ptr, &h[0], sizeof(float) * h.size());
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB); // release the mapped buffer
}
*/
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
[/code]

Share this post


Link to post
Share on other sites
MARS_999    1627
Bah here is the correct code... The GL_LUMINANCE32F_ARB was it...

[code]
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, offset, h.size() * sizeof(float), &h[0]);
/*float* ptr = (float*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
if(ptr)
{
memcpy(ptr, &h[0], sizeof(float) * h.size());
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB); // release the mapped buffer
}
*/
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, heightmapTexID);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, vertCols, vertRows,
GL_LUMINANCE, GL_FLOAT, GL::BUFFER_OFFSET(0));
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
[/code]

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