call to OpenGL ES API with no current context (logged once per thread)
2015-04-01 16:29
127 查看
背景
cocos2dx Android 工程接入移动基地的短信扣费SDK;程序运行,扣费成功后 程序崩溃。
eclipse logcat 提示:
网上搜索到两个方法
第一个方法:.
在应用程序AndroidManifest.xml文件 添加android:hardwareAccelerated="true"开启硬件加速
我添加如下 ,最后一行<pre name="code" class="html"> <application android:label="@string/app_name" android:icon="@drawable/icon" android:name=".CmgameApplication" android:hardwareAccelerated="true">
程序运行后,付款后程序没有崩溃,可以流畅运行,但是在eclipse logcat下看到,付费时还是有提示
可见此方法并不能解决根本的问题。
第二个方法:
http://www.le4.cn/android/1632.html转载自此
这个问题是因为Android在启动cocos2d-x的Thread时,没有用context的主的Thread,而是使用的OpenGL的Thread,所以我们不能在主Thread去完成 本应该是在cocos2dx中OpenGL Thread中 完成的工作(即所调用的函数在Cocos2dx中做的工作), 必须使用OpenGL的Thread去完成︰
Java(Android)侧-Cocos2dxActivity.java
应该在Cocos2dxActivty的这个Activity用runOnGLThread去完成对应的工作
public static native void nativeCallback(String code, String params); //原本程序中调用的java函数 public static void runNativeCallback(final String code, final String params)//增加此函数,修改后在调用nativeCallback的地方调用runNativeCallback即可 { Cocos2dxGLSurfaceView.getInstance().queueEvent(new Runnable(){ @Override public void run() { nativeCallback(code, params);//在此调用原函数 } }); }
程序运行后完美解决问题。
相关文章推荐
- cocos2dx- call to OpenGL ES API with no current context(logged once per thread)
- call to OpenGL ES API with no current context (logged once per thread)可能会导致加载问题?
- cocos2dx- call to OpenGL ES API with no current context(logged once per thread)
- cocos2dx- call to OpenGL ES API with no current context(logged once per thread)
- OpenGL ES开发中遇到call to OpenGL ES API with no current context (logged once per thread) 问题原因
- Android: call to OpenGL ES API with no current context (logged once per thread)
- 【cocos2d-x 025】 call to OpenGL ES API with no current context (logged once per thread)
- call to OpenGL ES API with no current context (logged once per thread)
- call to OpenGL ES API with no current context (logged once per thread)
- call to OpenGL ES API with no current context (logged once per thread)
- cocos2dx- call to OpenGL ES API with no current context(logged once per thread)
- cocos2dx- call to OpenGL ES API with no current context(logged once per thread)
- 解决COCOS2D-X与JNI交互游戏出现崩溃的问题call to OpenGL ES API with no current context (logged once per thread)
- cocos2dx- call to OpenGL ES API with no current context(logged once per thread)
- JNI error:libEGL: call to OpenGL ES API with no current context (logged once per
- call to OpenGL ES API with no current context 和Fatal signal 11
- cocos2d-x在android上call to OpenGL ES API with no current context
- ANDROID “call to opengl es api with no current context”错误的解决
- ANDROID “call to opengl es api with no current context”错误的解决
- call to OpenGL ES API with no current context 和Fatal signal 11