• Advertisement
Sign in to follow this  

PBO to update a single texture

This topic is 2385 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

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....



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);
}

Share this post


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


{
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);
}

Share this post


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

  • Advertisement