2

I have a texture, bound to GL_TEXTURE_EXTERNAL_OES target

    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

How can rebind it to GL_TEXTURE_2D target? GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); provides error

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Fr0stDev1
  • 143
  • 2
  • 15

1 Answers1

3

You can't. The texture target is a fundamental part of the texture object. If you have an external texture, you cannot treat it like a GL_TEXTURE_2D. At all.

This means if you want to bind it, you must bind it as a GL_TEXTURE_EXTERNAL_OES texture. If you want to use it in a sampler, that sampler must be of type samplerExternalOES rather than sampler2D (and your shader must enable the appropriate extension). And so forth.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • How can I use content of that texture? Maybe I can copy content to another texture, that is GL_TEXTURE2D? – Fr0stDev1 May 17 '16 at 09:38
  • So there is no any way to bind texture's content to 2D? Maybe I can copy it somehow? – Fr0stDev1 May 17 '16 at 11:50
  • @Fr0stDev1: "*How can I use content of that texture?*" Did you read anything after "You can't" in my post? Unless it's a use that specifically *needs* a 2D texture, then you can use an external texture just like any other texture target. It even has an associated sampler with accompanying texture accessing functions, so that you can read from it in the shader. Similarly, you can attach it to an FBO. It's still a texture; it's just not a texture of the target `GL_TEXTURE_2D`. The only difficulty is that your shader needs to be written specifically to read from one. – Nicol Bolas May 17 '16 at 14:21
  • @NicolBolas "Similarly, you can attach it to an FBO" are you sure? There are multiple QA saying you can't, because FBOs require a RGBA texture. I'd be curious to know if this is possible. Typically, the glTexImage2D() call fails if you pass `GL_TEXTURE_EXTERNAL_OES` as target. – natario Aug 19 '19 at 11:20
  • Just one of such answers here: https://community.khronos.org/t/how-to-buffer-frames-in-gpu-and-use-them-as-textures-in-the-future-render-processing/75152/5 – natario Aug 19 '19 at 11:24
  • Hey! I know this is an old post, but is it possible to render a `GL_TEXTURE_EXTERNAL_OES` to a `GL_TEXTURE_2D` using Skia, and then pass the `GL_TEXTURE_2D` through to multiple output `EGLSurface`s? See my question: https://stackoverflow.com/questions/77010619 – mrousavy Aug 30 '23 at 18:29