AnsweredAssumed Answered

Call to OpenGL ES API with no current context

Question asked by Matthew Davis on May 6, 2016
Latest reply on Jun 5, 2016 by Matthew Davis

I'm trying to use a custom shader in the camera HAL to process images as they come off of the camera in libcamera2, but I'm running into a problem when I try to initialize the library.  When I call eglGetDisplay(), it returns successfully, but I see the following error in the log:


E/libEGL  (  154): call to OpenGL ES API with no current context (logged once per thread)


If I understand correctly, this happens when you try to make OpenGL calls without properly initializing the library or if you try to call OpenGL on a thread other than the one that opened the context.  In my case, all of the calls happen on one thread and the error happens on the first call.  Since this isn't application code (I'm in the Android framework itself), I'm wondering if there's something I need to do to properly access the GPU.


None of the OpenGL calls returns an error until I try to read the pixels back with glReadPixels like this:


glReadPixels(0,0, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, outRGB);


Then the library reports GL_INVALID_OPERATION.  I'm combing through the rest of the code to see if I did anything else wrong, but the context error in the logs makes me worry that the problem is related to threading / hardware access and not the GL code itself.  The OpenGL code works just fine when I run as a stand-alone process on my laptop.


Do I need to do something special to access OpenGL ES from within the Android framework?  I've seen other threads indicating that people have done it.