opengl多線程繪制
實作效果:opengl開啟兩個線程,一個線程用于繪制,另一個線程用于加載紋理。
實作方法:opengl是單線程的,其他線程不能通路另外線程的紋理資源,但是,如果兩個線程共享上下文,就可以通路彼此的紋理資源。
繪制線程:建立兩個上下文
//隻有主要代碼
...
context = eglCreateContext(display, config, NULL, ctxAttribs);
context1 = eglCreateContext(display, config, context, ctxAttribs);
...
eglMakeCurrent(display, eglSurface, eglSurface, context);
加載紋理線程:綁定繪制線程中兩個上下文中的一個
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context1);