Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

PBO to update a single texture

This topic is 2650 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!