call to OpenGL ES API with no current context (logged once per thread)
2017-02-12 15:53
821 查看
今天再做opengl es程序的时候,遇到了logcat打印的这句话,并且本应该显示的图形也没有显示。网上搜索一番后,发现了自己代码错误的地方。
由于OpenGL是基于状态的,所以会为每个线程准备私有线程数据
在使用GLSurfaceView的时候,Renderer里面都是在新线程里做的,目的是不耽误主线程办正事。
我原来的代码就错在,继承GLSurfaceView后,新建了一个全局变量(储存顶点数据),还建了一个内部类,这个内部类是继承Renderer的,所以,当我在GLSurfaceView构造函数中初始化全局变量后再调用下面的代码:
则renderer里面的代码则是在另一个线程里面运行的,在renderer里面就使用了没有初始化的顶点数据,所以不会显示任何图形。
由于OpenGL是基于状态的,所以会为每个线程准备私有线程数据
在使用GLSurfaceView的时候,Renderer里面都是在新线程里做的,目的是不耽误主线程办正事。
我原来的代码就错在,继承GLSurfaceView后,新建了一个全局变量(储存顶点数据),还建了一个内部类,这个内部类是继承Renderer的,所以,当我在GLSurfaceView构造函数中初始化全局变量后再调用下面的代码:
mRenderer=new SceneRenderer(); this.setRenderer(mRenderer); this.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
则renderer里面的代码则是在另一个线程里面运行的,在renderer里面就使用了没有初始化的顶点数据,所以不会显示任何图形。
相关文章推荐
- 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)
- 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) 问题原因
- 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)
- Android: 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)
- 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)
- cocos2dx- 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)
- JNI error:libEGL: call to OpenGL ES API with no current context (logged once per
- 关于LGame中的call to OpenGL ES API with no current context
- cocos2d-x在android上call to OpenGL ES API with no current context
- call to OpenGL ES API with no current context 和Fatal signal 11
- ANDROID “call to opengl es api with no current context”错误的解决
- 遇到ANDROID “call to opengl es api with no current context”错误