Hi,
I’m trying to render to a texture while using multisampling, but looking in the documentation I can’t figure out how to do it, or even if it’s supposed to work.
My current code is like this, but it won’t make multisampling:
glGenRenderbuffersEXT(1, &depth_rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, nResX, nResY);
glGenTextures(1, &nDepthTextIdx);
glBindTexture(GL_TEXTURE_2D, nDepthTextIdx);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, nResX, nResY, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
// init texture
glGenFramebuffersEXT(1, &nFBOIdx);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, nFBOIdx);
glGenTextures(1, &nTextIdx);
glBindTexture(GL_TEXTURE_2D, nTextIdx);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, nResX, nResY, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glGenerateMipmapEXT(GL_TEXTURE_2D);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, nTextIdx, 0);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// renderscene
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindTexture(GL_TEXTURE_2D, nTextIdx);
// Use texture
I know there’s the extension ext_Framebuffer_multisample, but its only function is glRenderbufferStorageMultisampleEXT. So if I understand properly, using it would make my render buffer (depth buffer) multisampled but not the color buffer? That’s wouldn’t be so usefull since what I want to do is to be able to map my frame buffer (which would now be a texture) back onto a polygon. Is there any way to do it?