EGL错误:“纹理资源为NULL,未指定级别”

问题描述 投票:0回答:1

我收到EGL错误:EGL错误:type = 0x824c,severity = 0x9146,message =“纹理资源为NULL,未指定级别”

在下面的前3行代码中为texId1执行glTextSubImage时会出现此错误。 texId2没有错误。想知道是否有其他人对这个错误可能是什么有任何想法?

在debugMessagecallback中可以看到此错误,并且关联的glGetError()是GL_INVALID_OPERATION。

   //render loop
   glBindTexture(GL_TEXTURE_2D, (GLuint)texId1);
   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, g_textureWidth,    g_textureHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixelsdata1);

   glBindTexture(GL_TEXTURE_2D, 0); //unbind tex


   glBindTexture(GL_TEXTURE_2D, (GLuint)texId2);
   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, g_textureWidth,      g_textureHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixelsdata2);

   glBindTexture(GL_TEXTURE_2D, 0); //unbind tex

android opengl-es egl qualcomm
1个回答
0
投票

好的,这是发生了什么,因此选择这个作为这篇文章的自我答案。我创建纹理的统一代码,我也尝试将其默认为白色。我这样做是通过分配m_tex = Texture2D.whiteTexture来实现的。意图是做一些像m_tex.whiteTexture;这是不允许的,所以最终我去了:-)

在引擎盖下看起来Unity正在使用我在意外重建的Texture2D.whiteTexture上的glTexStorage2D()调用,使其不可变。事实上,我必须调整原始tex的大小,这对我来说很明显,我得到了一个新的纹理而不是颜色变化,但是我专注于解释我的本机代码中的gl调用和错误代码。评论这些whiteTexture并调整大小后不再出现gl错误:

m_tex = new Texture2D(1920, 1080, TextureFormat.RGBA32, false);
m_tex.filterMode = FilterMode.Bilinear;

//m_tex = Texture2D.whiteTexture;
//m_tex.Resize(1920, 1080);
m_tex.Apply();

还有一个注意事项我继续使用glTexSubImage2D调用,其中pixeldata与上面的原始帖子中的同一个调用中传递。我不使用glTexImage。我猜Unity在所有纹理创建上使用ARB_texture_storage extension,从而使这些纹理不可变。这是扩展中的注释:

When using this extension, it is no longer possible to supply texture
data using TexImage*. Instead, data can be uploaded using TexSubImage*,
or produced by other means (such as render-to-texture, mipmap generation,
or rendering to a sibling EGLImage).

谢谢你@ Rabbid76和@solidpixel。我相信所有评论都会对其他人有用。干杯:-)

© www.soinside.com 2019 - 2024. All rights reserved.