首页 > 代码库 > OpenGL,Android注意事项初始化顺序 NullPointer
OpenGL,Android注意事项初始化顺序 NullPointer
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 beforesetRenderer(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))
setEGLConfigChooser(boolean)
setEGLConfigChooser(EGLConfigChooser)
setEGLConfigChooser(int, int, int, int, int, int)
The following GLSurfaceView methods can only be called after setRenderer is called:
(setRender后调用)
getRenderMode()
onPause()
onResume()
queueEvent(Runnable)
requestRender()
setRenderMode(int)
OpenGL,Android注意事项初始化顺序 NullPointer
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。