나는 즉석에서 밉맵을 생성 주위에 내 머리를 포장하고,이 코드로이 비트를 읽고 있어요 : http://www.g-truc.net/post-0256.htmlOpenGL을 glGeneratemipmap 및 프레임 버퍼
//Create the mipmapped texture
glGenTextures(1, &ColorbufferName);
glBindTexture(ColorbufferName);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_UNSIGNED_BYTE, NULL);
glGenerateMipmap(GL_TEXTURE_2D); // /!\ Allocate the mipmaps /!\
...
//Create the framebuffer object and attach the mipmapped texture
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColorbufferName, 0);
...
//Commands to actually draw something
render();
...
//Generate the mipmaps of ColorbufferName
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, ColorbufferName);
glGenerateMipmap(GL_TEXTURE_2D);
내 질문 :
에glGenerateMipmap
요구를하지 왜
- 텍스쳐에 렌더링 할 때 두 번 호출 할 수 있습니까?
- 모든 프레임처럼 이것을 호출해야합니까?
내가 예를 들어이 같은 OpenGL을로로드 한 후 내가 한 번만 호출 할 필요 확산 2D 텍스처 가져 오는 경우 :
GLCALL(glGenTextures(1, &mTexture));
GLCALL(glBindTexture(GL_TEXTURE_2D, mTexture));
GLint format = (colorFormat == ColorFormat::COLOR_FORMAT_RGB ? GL_RGB : colorFormat == ColorFormat::COLOR_FORMAT_RGBA ? GL_RGBA : GL_RED);
GLCALL(glTexImage2D(GL_TEXTURE_2D, 0, format, textureWidth, textureHeight, 0, format, GL_UNSIGNED_BYTE, &textureData[0]));
GLCALL(glGenerateMipmap(GL_TEXTURE_2D));
GLCALL(glBindTexture(GL_TEXTURE_2D, 0));
을 나는 텍스처는 모든 프레임을 다시 그려되어 있기 때문에 의심을하고 밉맵 생성은 그 과정에서 내용을 사용하지만 이것에 대한 확인을 원합니다.
3 - 또한 내 FBuffer로 렌더링 한 다음 즉시 glBlitFramebuffer
을 기본 FBO로 바인딩하면 바인드해야합니까? glGenerateMipmap
이렇게하면 되나요?
GLCALL(glBindTexture(GL_TEXTURE_2D, mGBufferTextures[GBuffer::GBUFFER_TEXTURE_DIFFUSE]));
GLCALL(glGenerateMipmap(GL_TEXTURE_2D));
GLCALL(glReadBuffer(GL_COLOR_ATTACHMENT0 + GBuffer::GBUFFER_TEXTURE_DIFFUSE));
GLCALL(glBlitFramebuffer(0, 0, mWindowWidth, mWindowHeight, 0, 0, mWindowWidth, mWindowHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR));