Jump to content
  • Advertisement
Sign in to follow this  
ShmeeBegek

OpenGL Loading textures from buffers with padding

This topic is 5168 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 have been researching how to do this for a short while and I havn't come up with any amazing answers. I have a large buffer in memory and I wish to load just a small rectangle of that buffer into an OpenGL texture, so this is essentially a padded buffer. I would expect that there would be a function that could handle padding between rows, which is all that I need. But I havn't been able to find such a function, and the best answer that I have come up with is calling glTexSubImage2D once for each row which seems very crude. I've been looking into ways to memory-map the texture and simply copy the data in using memcpy, but I havn't had a huge amount of luck there either. Any suggestions? Thanks ~SPH

Share this post


Link to post
Share on other sites
Advertisement
You could just allocate a smaller temporary buffer,copy only the data you need there,and load it using glTexImage2D.I don't see any problem in that.

Share this post


Link to post
Share on other sites
You should be able to do that using GL_UNPACK_ROW_LENGTH, GL_UNPACK_SKIP_PIXELS, and GL_UNPACK_SKIP_ROWS. What do you mean by "padding between rows" ? Is your rectangle a continuous sub rectangle within a larger area, or is it "sliced up" ? Can you provide an example ? In both cases, you should be able to handle the situation by supplying appropriate settings to the GL_UNPACK* pixel store parameters.

Share this post


Link to post
Share on other sites

[SOURCE]
********
***####*
***####*
********
********
[/SOURCE]


There is a simple example of the concept described, the block that I want is highlighted with '#' characters. Here I would want OpenGL to skip 4 pixels after each row.

I'll look into those settings and post again, thanks, ~SPH

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!