I'm using Open GL ES 3.1 in my app and I'm facing a problem I haven't be able to fix so far.
When I try to create a 3D object, depending on where the constructor is called, either the object is correctly created (and can be displayed successfully) or the app crashes because shaders can't be created (call to glCreateShader()
returns 0). This lets me say my shader codes are correct.
When I try to get information about the error with glGetError()
, I receive GL_NO_ERROR
, even when the returned shader is 0!
I have also added setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS)
but it doesn't give me any clue.
I supposed the problem could be caused by concurrent access to the Open GL environment and I had my drawing and animating methods synchronized but it didn't help either.
According to this question Compile GLSL shader asynchronously or in a different thread on Android, I'm pretty sure the problem comes from the impossibility to use the main Open GL environment in a separate thread. But I can't be sure of that because the code given uses class I can't find in the Open GL ES 3.1 library (EGLContext2
, eglCreateContext
, eglCreatePbufferSurface
).
Does anyone know how I can access the Open GL ES environment from my second thread?