码迷,mamicode.com
首页 > 移动开发 > 详细

OpenGL,Android注意事项初始化顺序 NullPointer

时间:2014-12-11 01:38:50      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:opengl   android   

BUG:

Caused by: java.lang.IllegalStateException: setRenderer has already been called for this instance.

或者NullPointer错误


解决方法:

把setEGLContextClientVersion(2);挪到setRenderer()前面。方法的注释上写到“If this method is called, it must be called before setRenderer(Renderer) is called. 
”。


拓展:

并且setRender()之后之前的方法调用顺序,也是固定。详情可以看代码注释,如下:

This method should be called once and only once in the life-cycle of a GLSurfaceView.

(这些方法只能在CLSurfaceView中有且只能调用一次)

The following GLSurfaceView methods can only be called before setRenderer is called:

(setRender前调用,当然也包括setEGLContextClientVersion(2))

The following GLSurfaceView methods can only be called after setRenderer is called:

(setRender后调用)


OpenGL,Android注意事项初始化顺序 NullPointer

标签:opengl   android   

原文地址:http://blog.csdn.net/zhjali123/article/details/41856181

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!