通过GlTexture作为OpenGL ES 2.0中的TexImage2D的输入
我正在尝试构建一个纹理打包器,其中多个(可能是 NPOT)纹理可以打包成一个兆 二次幂纹理可实现更好的性能和更好的最小/放大过滤。
是否可以将 GLTexture
传递给 OpenGL ES 2.0 中的 tex(Sub)Image2D
调用?查看 docs,我看到最后一个参数是 data
:
指定指向内存中图像数据的指针。
我的情况是,我有一个最小的 OpenGL ES 2.0 抽象,它允许我创建具有不同字体、大小、样式等的文本纹理。我无法访问 CPU 或任何画布上的像素内容 code> 代表它的元素,只是生成的 GLTexture
。
假设我可以创建包含文本(例如字幕、UI 元素等)的动态 GLTexture,但无法访问 CPU 上的图像数据,那么如何将纹理本身打包成更大的纹理? “巨型”纹理?
我知道我可以通过渲染我想要打包到代表巨型纹理的帧缓冲区中的四边形的较小纹理来实现,但这需要渲染到浮点纹理,并非所有硬件都支持。
我想到的另一件事是通过 readPixels 将纹理内容读入 CPU 内存,但这是同步的,对我来说听起来很糟糕……
TLDR:我有一堆较小的 GLTexture代码>s。我希望能够将它们打包到更大的 GLTexture 上,在任何地方共享它并以不同的偏移量采样以获得更好的性能。
I am trying to build a texture packer, where multiple (possibly NPOT) textures can be packed into one mega
Power-Of-Two Texture for better performance and better min / mag filtering.
Is it possible to pass a GLTexture
to a tex(Sub)Image2D
call in OpenGL ES 2.0? Looking at the docs, I see the last argument is data
:
Specifies a pointer to the image data in memory.
My case is that I have a minimal OpenGL ES 2.0 abstraction, which allows me to create text textures with different fonts, sizes, styles etc. I don't have access to the pixel contents on the CPU or any canvas
elements that represent it, just the generated GLTexture
.
Assuming I can create dynamic GLTexture
s containing text (think subtitles, UI elements, etc), but don't have access to the image data on the CPU, how can I pack the textures themselves into a bigger "mega" texture?
I know I can do it by rendering the smaller textures I want to pack to quads in a framebuffer representing the mega texture, but this will require rendering to floating point textures, which not all hardware supports.
Another thing that comes into mind is reading the texture contents into CPU memory via readPixels
, but that is synchronous and sounds nasty to me...
TLDR: I have a bunch of smaller GLTexture
s. I want to be able to pack them onto a bigger GLTexture
, share it everywhere and sample at different offsets for better performance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
否。
如果您不能在软件中执行此操作,另一个选择是将其作为呈现方式操作在GPU上进行。
No.
If you can't do it in software, the other option is to do it on the GPU as a render-to-texture operation.