Android GLSurfaceView glTexImage2D glDrawTexiOES
我正在尝试使用 GLSurfaceView 和 Native C 代码在 Android 上使用 OpenGL ES 渲染 640x480 RGB565 图像。
最初,我在使用 glTexImage2D 时遇到了 0x0501 错误,我可以通过更改图像尺寸来解决该错误。
但是现在,在“drawFrame”调用中,当我执行 glDrawTexiOES 重新渲染纹理时,我在日志中收到以下错误:
drawtex.c:89: DrawTexture: Notexturesenabled
我已经在执行 glEnable(GL_TEXTURE_2D) ,还有什么我应该做的吗?
是否有完整的示例显示 GLSurfaceView 和使用纹理的本机代码?
提前致谢!
I'm trying to render a 640x480 RGB565 image using OpenGL ES on Android using GLSurfaceView and Native C code.
Initially I had a 0x0501 error with glTexImage2D, which I was able to resolve by changing the image dimensions.
But now, in the "drawFrame" call, when I do glDrawTexiOES to resnder the texture, I'm getting the following error on the Logs:
drawtex.c:89: DrawTexture: No textures enabled
I'm already doing glEnable(GL_TEXTURE_2D), is there anything else I should do?
Is there a complete example showing GLSurfaceView with native code using textures?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也遇到了同样的问题,您可以像这样制作自定义渲染器:
或者(通过直接子类化 SurfaceView 来实现有点复杂)
I have had the same problem,you can either make a custom renderer like this:
or (a do it little bit complicated by subclassing SurfaceView directly)
是的,我做到了...
yes i did...
你是否先生成了纹理id并绑定了纹理?
glGenTexture()/glBindTexture()
Did you generate a texture id and bind a texture first?
glGenTexture()/glBindTexture()
以下将在 GL_TEXTURE0 上设置所有纹理并准备使用:
加载纹理时:
请参阅 这里了解如何填写TexImage2D参数。
不幸的是,我无法让 glDrawTex_OES 函数正常工作,但是如果将其渲染到四边形上,纹理确实可以工作:
The following will get the texture all set up and ready to use on GL_TEXTURE0:
When loading the texture:
see here for how to fill out the TexImage2D parameters.
I've unfortunately not been able to get the glDrawTex_OES functions to work properly, but the texture does work if you render it onto a quad: