Georgi B. Nikolov
Georgi B. Nikolov

Reputation: 998

Passing a GLTexture as an input to texImage2D in OpenGL ES 2.0

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 GLTextures 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 GLTextures. I want to be able to pack them onto a bigger GLTexture, share it everywhere and sample at different offsets for better performance.

Upvotes: 0

Views: 90

Answers (1)

solidpixel
solidpixel

Reputation: 12269

Is it possible to pass a GLTexture to a tex(Sub)Image2D call in OpenGL ES 2.0?

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.

Upvotes: 1

Related Questions