I have an application in which I create a large offscreen framebuffer for rendering and then copy the result into the window displaybuffer using glBlitFramebufferEXT. This works well and lets me render the graphics at the required resolution even when the (preview) window is resized.
Multisampling is giving me trouble though.
If I select a x4 multisampling pixelformat (like 44) by SetPixelFormat and the create my context wglCreateContext, then it does not give an error. I just get a valid context and can render fine after setting glEnable(GL_MULTISAMPLE_ARB)… but it is not multisampled which glGetIntegerv(GL_SAMPLES,&numSamples) also tells me. It returns 0.
I then tried not rendering to my framebuffer (bound to the default fb=0) and dropping the blit. Now everything worked fine with antialiasing.
It makes me think that somehow I get a context with multisampling, but this is turned off when I use an incompatible framebuffer. The question is then why my framebuffer is not good. I only need color in it, not stencil or depth, so I only make a color texture and bind it. Is this not enough? What else should it contain…? or is my problem something else entirely?
//create frame buffer and make it current by binding
GLuint frameBufferID;
glGenFramebuffersEXT(1,&frameBufferID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferID);
//create texture for color
GLuint colorTextureID;
glGenTextures(1,&colorTextureID);
glBindTexture(GL_TEXTURE_2D,colorTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
//bind color texture
glBindTexture(GL_TEXTURE_2D,colorTextureID);//TODO: is this required?
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorTextureID, 0);
//bind this new framebuffer
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, frameBufferID);