당신은 FBO에 첫 번째 패스 렌더링, 기본 프레임 버퍼에 두 번째 패스를 렌더링 할 때 다음 결과 질감을 사용할 수 있습니다.
흐림하려는 이미지가 이름이 inputTexId
인 텍스쳐에있는 경우 다음은 코드의 모양을 요약 한 것입니다. C++ 또는 Java를 사용하는지 여부는 지정하지 않았습니다. 다음은 C++ 바인딩을 사용하지만 Java에서 매우 비슷하게 보입니다.
일단, 설치하는 동안, 당신은 FBO 및 제 렌더링 패스의 결과를 포함하는 데 사용되는 텍스처 생성 :
GLuint pass1TexId = 0;
glGenTextures(1, &pass1TexId);
glBindTexture(GL_TEXTURE_2D, pass1TexId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_2D, 0);
GLuint fboId = 0;
glGenFramebuffers(1, &fboId);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, pass1TexId, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
당신은 흐림 필터를 적용 할 때마다, 당신은 이것을 사용 FBO 입력으로 원래의 이미지와 최초의 렌더링 패스 렌더링 타겟과 같은 :
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glBindTexture(GL_TEXTURE_2D, inputTexId);
// Set up shaders and state for first blur pass, and render.
그런 다음 두 번째 패스를 들어, 기본 프레임 버퍼에 렌더링 및 입력으로 첫 번째 패스에 의해 생성 된 텍스처를 사용합니다 :
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, pass1TexId);
// Set up shaders and state for second blur pass, and render.