为什么我会“在没有当前上下文的情况下调用 OpenGL ES API"? [英] Why am I getting "call to OpenGL ES API with no current context"?

查看:73
本文介绍了为什么我会“在没有当前上下文的情况下调用 OpenGL ES API"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 openGL 和 android 开发的新手,所以如果我的问题很琐碎,请原谅我.

I am new to both openGL and android development so please forgive me if my question is very trivial.

我正在尝试构建一个简单的小应用程序,该应用程序在三个 EditText 中接受用户的输入,这些输入代表要在 GLSurfaceView 中显示的 RGB 颜色的每个分量的 0 - 100% 值.

I am trying to build a simple little app that takes input from the user in three EditTexts representing a 0 - 100% value for each component of a RGB color to be displayed in a GLSurfaceView.

问题是我需要它来使用 openGL ES 2.0 并且我需要使用统一值将数据传递到着色程序,以便一旦我开始工作,我就可以继续我真正想要完成的事情.

The catch is that I need this to use openGL ES 2.0 and I need to pass the data into the shading program using a uniform value so that once I get it working I can move on to what I am really trying to accomplish.

运行我编写的内容后,我可以让 GLSurfaceView 正确显示第一个纯色,但是每当我更改任何值并调用以重建着色程序中的统一插槽时,我都会在 LogCat 中收到此错误:

Upon running what I have written I can get the GLSurfaceView to correctly display the first solid color, but whenever I change any of the values and make calls to rebuild the uniform slot in the shading program I get this error in the LogCat:

ERROR/libEGL(14316):在没有当前上下文的情况下调用 OpenGL ES API(每个线程记录一次)

ERROR/libEGL(14316): call to OpenGL ES API with no current context (logged once per thread)

当然,GLSurfaceView 仍然是初始颜色.

and of course the GLSurfaceView remains the initial color.

我一直在寻找解决此问题的方法,并且尽我所知,在设置渲染器之前,我可能需要在某处设置 EGLContext.但是,我在 API 演示中没有看到任何关于此的信息,而且我在网上能找到的唯一信息是在 GLSurfaceView 甚至可用之前编写的.

I've been searching all over for a solution to this problem and as best I can tell I might need to be setting up an EGLContext somewhere before setting my renderer. However, I don't see anything in the API demos about this, and the only information I can find online was written before GLSurfaceView was even available.

我还需要设置 EGLContext 还是我错过了其他东西?

Do I need to set up an EGLContext still or have I missed something else?


可能有帮助的其他信息:

Additional info that may help:

- 使用 XML 文件来设置 UI(据我所知,在代码中这样做无济于事)

-used an XML file to set up the UI (and as far as I can tell doing it in code doesn't help)

- 当我尝试在单独的程序中从 SD 卡加载新纹理时遇到同样的问题.我可以让第一个纹理正常工作,但是当使用相同的方法加载第二个时,我得到相同的错误并且没有任何变化.

-having the same trouble when I try to load in a new texture from the sd card in a seperate program. I can get the first texture to work fine, but when using the same method to load the second I get the same error and nothing changes.

推荐答案

您不是从 OpenGL 线程调用它.如果另一个线程尝试使用 OpenGL 执行某些操作,请将其放入队列并在您的 OpenGL 线程中调用它.

You're not calling it from the OpenGL thread. If a different thread is trying to do something with OpenGL, queue that up and call it during your OpenGL thread instead.

这篇关于为什么我会“在没有当前上下文的情况下调用 OpenGL ES API"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆