Can I maintain a reference to the GL10 safely?
In my android application I get a reference to the GL10 object in the methods: onSurfaceCreated, onSurfaceChanged, and onDrawFrame. Is it safe t开发者_如何转开发o hold onto that reference?
Don't store a reference from your GL10
pointer.
It's only valid for the three overrided methods, onSurfaceChanged()
, onSurfaceCreated()
and onDrawFrame()
. OpenGL ES uses state change and therefore is the OpenGL ES context only valid inside these methods.
It may look safe, mainly because onDrawFrame()
will be iterated over and over by the GL thread, which will make your OpenGL ES context "activated" during these calls.
精彩评论