简体   繁体   English

如何阻止应用内结算客户端丢失EGL上下文?

[英]How to stop In-App Billing client from losing EGL Context?

I have an Android project with two activities. 我有一个包含两个活动的Android项目。 One is my main activity, using a GLSurfaceView that gets updated from native code. 我的主要活动之一是使用从本地代码更新的GLSurfaceView The other is a PurchaseActivity that opens up Google's In-App Billing client to make purchases. 另一个是PurchaseActivity ,可以打开Goog​​le的应用内结算客户进行购买。 Making purchases works fine. 进行购买可以正常工作。

The problem I'm running into is that after the PurchaseActivity finishes, whether it completes successfully, errs, or is cancelled, and it switches back to the main activity, the EGL context disappears and I receive: 我遇到的问题是, PurchaseActivity完成之后,无论它成功完成,错误还是被取消,并且切换回主活动,EGL上下文消失,我收到:

call to OpenGL ES API with no current context (logged once per thread) 在没有当前上下文的情况下调用OpenGL ES API(每个线程记录一次)

After that the onSurfaceCreated() and onSurfaceChanged() methods are retriggered. 之后,将onSurfaceCreated()触发onSurfaceCreated()onSurfaceChanged()方法。

I found this question similar but mine is already running in a separate activity and if I remove the finish() call, it just remains stuck in the PurchaseActivity . 我发现这个问题类似,但是我的问题已经在单独的活动中运行,如果我删除了finish()调用,它只会停留在PurchaseActivity

Do I really need to reload the textures after making an in-app billing call? 拨打应用内结算电话后,我真的需要重新加载纹理吗? It seems this shouldn't be necessary at this point since the app is not being suspended. 由于该应用尚未暂停,因此目前似乎没有必要。

My renderer code is pretty basic but for whatever reason, after the billing client window closes, it triggers a new surface and blows up my native code: 我的渲染器代码很基本,但是由于任何原因,在关闭计费客户端窗口之后,它会触发一个新界面并炸毁我的本机代码:

public class GameRenderer implements GLSurfaceView.Renderer
{   
    public void onSurfaceCreated(GL10 gl, EGLConfig config)
    { }

    public void onSurfaceChanged(GL10 gl, int width, int height)
    {
        BaseLib.setScreenSize(width, height);
        BaseLib.init();
    }

    public void onDrawFrame(GL10 gl)
    {
        BaseLib.render();
    }
}

Have you seen this thread? 你看过这个话题吗?

Prevent onPause from trashing OpenGL Context 防止onPause破坏OpenGL上下文

I would guess you get an onPause when you switch activities, which tells the GLSurfaceView to release resources. 我猜您在切换活动时会收到onPause,这告诉GLSurfaceView释放资源。

On API 11+ there is a command setPreserveEGLContextOnPause , but not sure if that's a solution for you if you want to target lower API levels than that. 在API 11+上,有一个命令setPreserveEGLContextOnPause ,但是如果您希望将API级别设置为更低的级别,则不确定这是否是您的解决方案。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM