简体   繁体   English

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

[英]call to OpenGL ES API with no current context (logged once per thread) - OpenGL ES

I really need someone help to understand the issue that I am facing. 我真的需要有人帮助来了解我所面临的问题。 I am trying to get the GPU information from the below lines: 我正在尝试从以下几行中获取GPU信息:

renderer = GLES20.glGetString(GLES20.GL_RENDERER); 渲染器= GLES20.glGetString(GLES20.GL_RENDERER);

vendor = GLES20.glGetString(GLES20.GL_VENDOR); 供应商= GLES20.glGetString(GLES20.GL_VENDOR);

version = GLES20.glGetString(GLES20.GL_VERSION); 版本= GLES20.glGetString(GLES20.GL_VERSION);

If I execute these lines from "OnCreate" method of an Activity I am receiving the error "E/libEGL(4380): call to OpenGL ES API with no current context (logged once per thread)" in the logcat and empty value is returned. 如果我从Activity的“ OnCreate”方法执行这些行,则会收到错误“ E / libEGL(4380):在logcat中调用没有当前上下文的OpenGL ES API(每个线程记录一次)”,并返回空值。

However If I execute these lines through button Click I am getting results. 但是,如果我通过单击“按钮”执行这些行,则会得到结果。

Can you someone help to me identify what mistake I am doing or is there any other thing I need to learn on this? 有人可以帮助我确定我在犯什么错误,或者我需要从中学到其他东西吗?

How do I get the result even If I execute from the onCreate Method? 即使从onCreate方法执行,如何获得结果?

The problem is exactly what the error message tells you: You're trying to make OpenGL calls ( glGetString ) without having a current OpenGL context. 问题正好是错误消息告诉您的内容:您正在尝试在没有当前OpenGL上下文的情况下进行OpenGL调用( glGetString )。 OpenGL calls require a current context in the thread you're making the calls from. OpenGL调用在您从中进行调用的线程中需要当前上下文。

The typical use of OpenGL includes using a GLSurfaceView , which takes care of creating a context, and making it current. OpenGL的典型用法包括使用GLSurfaceView ,它负责创建上下文并将其设置为当前上下文。 If you do need to make OpenGL calls from other places in the code, you need to take care of creating an OpenGL context yourself. 如果确实需要从代码中的其他位置进行OpenGL调用,则需要自己创建一个OpenGL上下文。 This is done using the EGL10 or EGL14 class. 这是使用EGL10EGL14类完成的。 You can find complete code in my answer here: GLES10.glGetIntegerv returns 0 in Lollipop only . 您可以在我的答案中找到完整的代码: GLES10.glGetIntegerv仅在Lollipop中返回0

Why it works from the button click handler is less clear. 从按钮单击处理程序来看它为什么起作用尚不清楚。 It seems like at least some versions of Android have a "stray" OpenGL context that happens to be current under certain circumstances. 似乎至少某些版本的Android具有“杂散” OpenGL上下文,在某些情况下碰巧是最新的。 I wouldn't count on that working consistently, though. 不过,我不会指望该技术能够始终如一地工作。 For example, as you can see in the question liked above, some people got burnt by relying on this when it stopped working on Lollipop. 例如,如您在上面喜欢的问题中看到的那样,当它停止在Lollipop上工作时,有人依靠它被烧死了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 调用没有当前上下文的OpenGL ES API(每个线程记录一次) - call to OpenGL ES API with no current context (logged once per thread) E / libEGL:调用OpenGL ES API,没有当前上下文(每个线程记录一次) - Android / SDL - E/libEGL: call to OpenGL ES API with no current context (logged once per thread) - Android/SDL Android 2.2 Webview导致OpenGL ES API没有当前上下文(每个线程记录一次) - Android 2.2 Webview causes OpenGL ES API with no current context (logged once per thread) ARToolkit-在没有当前上下文的情况下调用OpenGL ES API - ARToolkit - call to OpenGL ES API with no current context 在没有当前上下文的情况下调用OpenGL ES API - Call to OpenGL ES API with no current context 没有当前上下文的opengl es api - opengl es api with no current context 为什么我“在没有当前上下文的情况下调用OpenGL ES API”? - Why am I getting “call to OpenGL ES API with no current context”? 在Android中使用imageloader时“在没有当前上下文的情况下调用OpenGL ES API” - “call to OpenGL ES API with no current context” while using imageloader in android 错误/libEGL(206):在没有当前上下文的情况下调用 OpenGL ES API - ERROR/libEGL(206): call to OpenGL ES API with no current context 处理和“没有当前上下文的OpenGL ES API” - Processing and “OpenGL ES API with no current context”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM