Hi, we are incorporating our 3D surround view application into our system. However our system has to do other operations as well(CAN-related tasks). My colleague told me that the thread A, which displays screen, is too busy. And he suggested we should not run our 3D algorithm in thread A.
Our 3D algorithm costs 30ms for each frame, but the interval between operations for two frames is more 80ms in thread A.
He suggested I move rendered-related code to another thread B and keep draw function in thread A.
So I changed the code as following:
At init
Thread A calls the following function to create textures T and bind an image buffer to each of them.
glTexImage2D(TEXTURE, 0, GL_ALPHA, alpha_gd.cols, alpha_gd.rows, 0, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_gd.data);
Every frame
First thread B calls the following function to bind the new images to the textures T and do some operations to these textures to get result which we need.
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer);
Then thread A calls the following function to draw rendered result to the scrren.
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
The solution works. The interval between operations for two frames is about 40ms for each frame.
But after more than ten minutes, the screen seems corrupt which display random images.
My question is "Can I put opengl-es operations into two threads and how to do it?".
Best regards,
Mason Su