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.
解決済! 解決策の投稿を見る。
To answer my own question: yes, linking specifically against those libraries is the correct answer. I don't see anything else in the Android tree that uses EGL and links against those libraries by name, but simply linking to -lEGL and -lGLESv2 causes problems. Linking to the _VIVANTE versions compiles and runs as expected.
Hi Matthew,
There is no anything special to access OpenGL Es with android framework on nxp bsps. However which imx android release package you are using? Which soc type you are using? Can it reproduced in our imx reference board? Please provide a detail info.
It seems you don’t include gpu library and gpu egl config into your rootfs. Typically you should have it included by default if you are using an nxp android release.
regards
Looking elsewhere in the Android tree, I see libGLESv2_VIVANTE.so and libEGL_VIVANTE.so in the device/fsl-proprietary/gpu-viv/lib/egl subdirectory? Should I be explicitly linking against those libraries? Searching through every .mk file in the project, none of them seem to use that version of the library--all of them use the generic OpenGL libraries like I am.
To answer my own question: yes, linking specifically against those libraries is the correct answer. I don't see anything else in the Android tree that uses EGL and links against those libraries by name, but simply linking to -lEGL and -lGLESv2 causes problems. Linking to the _VIVANTE versions compiles and runs as expected.