Possible to glTexImage2d an NPOT image onto a Pow-2 texture without extra allocation?

好久不见. 提交于 2019-12-01 13:55:21

Use glTexImage2D with empty data to initialize the texture and glTexSubImage2D to fill a portion of it with data. Technically OpenGL allows the data parameter given to glTexImage{1,2,3}D to be a null pointer, indicating that the texture object is just to be initializd. It depends on the language binding, if that feature remains supported in the target language – just test what happens if you pass a null pointer.

datenwolf is right on how to initialize the texture with just a partial image, but there are 2 issues with this you need to be aware of:

  • you need to remap the texture coordinates of your mesh, as the [0-1] texture range of the full texture now also contains uninitialized data, as opposed to your full texture. The useful range is now [0-orig_width/padded_width]
  • wrapping of your texture will only wrap the whole texture, not your sub-part.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!