简体   繁体   中英

OpenGL ES API error (no context)

I am getting this error:

ERROR libEGL call to OpenGL ES API with no current context

My class extends GLSurfaceView. I have a method Init() that is called (from the main Activity) to initialize some things. This method is always called after OnSurfaceCreated(). This method calls a native library function that, in turn, calls some opengl functions.

I have changed things so that now i initializes things in the method onDraw() and it works. So, can opengl functions (from java or native code) be called only from java methods that have a GL10 parameter?

I am confused but multithreaded programming, since i come from plain single thread development. When it is safe (the context is available) to call opengles functions from native code? Only from OnDraW(), onSurfaceCreated(), onSurfaceChanged() ?

Why when, from the activity method, i call the Init() method of my gl class and the context is not available?

Are you using queuevent(runnable)? By the sound of it you're calling native functions from the ui thread. By using queuevent you insure that these are run in the glthread and subsequently use the correct context. check this out: http://developer.android.com/reference/android/opengl/GLSurfaceView.html#queueEvent(java.lang.Runnable )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM