Hi,
does anybody know if it is possible to create a multisampled pBuffer? More specific: a multisample pBuffer with render-to-texture-rectangle active?
I tried it this way:
HDC hDC=wglGetCurrentDC();
HGLRC hglRC=wglGetCurrentContext();
GLenum target=GL_TEXTURE_RECTANGLE_NV;
if(hDC && hglRC)
{
glGenTextures(1,&m_index);// generate a texture-Object
glBindTexture(target, m_index);
// set the filtering
glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
int iAttributes[50];
unsigned int currentAttr=0;
for(unsigned int i=0; i<50; ++i)
iAttributes[i]=0;´
iAttributes[currentAttr++]=WGL_SUPPORT_OPENGL_ARB;
iAttributes[currentAttr++]=GL_TRUE;
iAttributes[currentAttr++]=WGL_DOUBLE_BUFFER_ARB;
iAttributes[currentAttr++]=GL_FALSE;
iAttributes[currentAttr++]=WGL_DRAW_TO_PBUFFER_ARB;
iAttributes[currentAttr++]=GL_TRUE;
iAttributes[currentAttr++]=WGL_ACCELERATION_ARB;
iAttributes[currentAttr++]=WGL_FULL_ACCELERATION_ARB;
iAttributes[currentAttr++]=WGL_RED_BITS_ARB;
iAttributes[currentAttr++]=8;
iAttributes[currentAttr++]=WGL_GREEN_BITS_ARB;
iAttributes[currentAttr++]=8;
iAttributes[currentAttr++]=WGL_BLUE_BITS_ARB;
iAttributes[currentAttr++]=8;
iAttributes[currentAttr++]=WGL_ALPHA_BITS_ARB;
iAttributes[currentAttr++]=8;
iAttributes[currentAttr++]=WGL_STENCIL_BITS_ARB;
iAttributes[currentAttr++]=8;
iAttributes[currentAttr++]=WGL_DEPTH_BITS_ARB;
iAttributes[currentAttr++]=24;
iAttributes[currentAttr++]=WGL_SAMPLE_BUFFERS_ARB;
iAttributes[currentAttr++]=GL_TRUE;
iAttributes[currentAttr++]=WGL_SAMPLES_ARB;
iAttributes[currentAttr++]=4;
iAttributes[currentAttr++]=WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV;
iAttributes[currentAttr++]=GL_TRUE;
float fAttributes[] = {0, 0};
// try to find a suitable Pixelformat
int status; // status variable
UINT numFormats; // saves the number of suitable formats
int pixelFormat; // saves the best fitting format
status = wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,
1, &pixelFormat, &numFormats);
if(status && numFormats)
{
int iPBufferAttr[20];
int iPBufferCurrentAttr=0;
for(unsigned int i=0; i<20; ++i)
iPBufferAttr[i]=0;
iPBufferAttr[iPBufferCurrentAttr++]=WGL_DEPTH_TEXTURE_FORMAT_NV;
iPBufferAttr[iPBufferCurrentAttr++]=WGL_TEXTURE_DEPTH_COMPONENT_NV;
iPBufferAttr[iPBufferCurrentAttr++]=WGL_TEXTURE_FORMAT_ARB;
iPBufferAttr[iPBufferCurrentAttr++]=WGL_TEXTURE_RGBA_ARB;
iPBufferAttr[iPBufferCurrentAttr++]=WGL_MIPMAP_TEXTURE_ARB;
iPBufferAttr[iPBufferCurrentAttr++]=0;
iPBufferAttr[iPBufferCurrentAttr++]=WGL_TEXTURE_TARGET_ARB;
iPBufferAttr[iPBufferCurrentAttr++]=WGL_TEXTURE_RECTANGLE_NV;
m_pBuffer=NULL;
m_pBufferDC=NULL;
m_pBufferRC=NULL;
// Create the pBuffer
m_pBuffer=wglCreatePbufferARB(hDC, pixelFormat, _width, _height,iPBufferAttr);
}
This only tells me, that there is no pixelformat available. However, if I use the exact same code without the multisampling lines, everything works fine.
So is it simply not possible to do antialiasing in a pBuffer or did I miss something important for it?
Case