2012-07-30 2 views

답변

16

예, 맞습니다.

먼저 당신은 하나 개의 스레드에서의 컨텍스트를 만들어야합니다

EGLint contextAttrs[] = 
    { 
     EGL_CONTEXT_CLIENT_VERSION, 2, 
     EGL_NONE 
    }; 

    if (m_Context == 0) 
    { 
     LOG_ERROR("m_Context wasn't initialized for some reason"); 
    } 

    // create a shared context for this thread 
    m_LocalThreadContext = eglCreateContext(m_Display, m_Config, m_Context, contextAttrs); 

당신은 당연히해야 할 것이다 :

EGLint contextAttrs[] = { 
    EGL_CONTEXT_CLIENT_VERSION, 2, 
    EGL_NONE 
}; 

LOG_INFO("creating context"); 
if (!(m_Context = eglCreateContext(m_Display, m_Config, 0, contextAttrs))) 
{ 
    LOG_ERROR("eglCreateContext() returned error %d", eglGetError()); 
    return false; 
} 

그런 다음 다른 스레드에서이 같은 공유 컨텍스트를 만들 GLES로하고 싶은 업데이트를 동기화하는 뮤텍스/세마포어. 예를 들어 당신은 그럼 당신은 스레드

+0

안녕 중 하나에서 등 텍스처, 부하 쉐이더를 만들 수 있습니다

if (!eglMakeCurrent(m_Display, m_Surface, m_Surface, m_Context)) { LOG_ERROR("eglMakeCurrent() returned error %d", eglGetError()); } 

를 호출 할 수 있습니다 다른 스레드 전에 스레드 내에서

eglMakeCurrent(m_Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 

을 할 필요가, I 2 개의 OpenGL 스레드 동기화가 발생했습니다. makeCurrent 외에도 다른 사람이 처리해야하는 것은 무엇입니까? 이 부분을 소개하는 기사가 있습니까? – dragonfly

+0

전체 샘플을 보려면이 소스 코드를 살펴보십시오. https://github.com/klhurley/EffectsManager/blob/master/src/Android/Renderer.cpp –

관련 문제