Hi, I have setup a pbuffer with floating point values and want to bind it to a texture. First I render with a fragment shader into the pbuffer. The values read from it by glReadPixels are ok. Then (after disabling pbuffer) I bind the pbuffer as a texture, but values are always 0.0. If I do the same with fixed point pbuffer, everything works as expected (of course [0,1.0]). Here is some of the code (floating point):
//Attribs:
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_DRAW_TO_PBUFFER_ARB, GL_TRUE,
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV, GL_TRUE,
WGL_FLOAT_COMPONENTS_NV, GL_TRUE,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_FLOAT_ARB,
WGL_RED_BITS_ARB, 32,
WGL_GREEN_BITS_ARB, 32, WGL_BLUE_BITS_ARB, 32,
WGL_ALPHA_BITS_ARB, 8, WGL_DEPTH_BITS_ARB, 0,
WGL_DOUBLE_BUFFER_ARB, GL_FALSE,
0,0
WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_RECTANGLE_NV,
WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_FLOAT_RGBA_NV,
0, 0
internal_format = GL_FLOAT_RGBA32_NV;
target = GL_TEXTURE_RECTANGLE_NV;
glBindTexture(target, texId);
glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D( target, 0, internal_format, width, height, 0, GL_RGB, GL_FLOAT, 0 );
render into pbuffer:
printf("Render to pbuffer...
");
glBindTexture(GL_TEXTURE_2D, 0);
glDisable( GL_TEXTURE_2D );
pbuffer->enable();
setup_env();
glDrawBuffer( GL_FRONT );
glDisable( GL_TEXTURE_2D );
glClearColor( 1.0, 1.0, 1.0, 1.0 );
glClear( GL_COLOR_BUFFER_BIT );
glColor3f( 0.0, 1.0, 0.0 );
shader->install();
glUniform1fARB( shader->getUniformLocation( "s_div" ), float(i) );
glBegin( GL_QUADS );
{
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 0, 0 );
glVertex2f( 0, 0 );
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 1, 0 );
glVertex2f( 1, 0 );
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 1, 1 );
glVertex2f( 1, 1 );
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 0, 1 );
glVertex2f( 0, 1 );
}
glEnd();
shader->uninstall();
glFlush();
pbuffer->disable();
pbuffer->swap();
display pbuffer’s texture:
glClearColor( 1.0, 1.0, 1.0, 0.0 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
printf("Displaying pbuffer
");
glEnable( GL_TEXTURE_2D );
pbuffer->bind();
glEnable ( GL_TEXTURE_2D );
glColor3f( 1, 1, 1 );
glDisable( GL_DEPTH_TEST );
texture_shader->install();
glBegin( GL_QUADS );
{
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 0, 0 );
glVertex2f( 0, 0);
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 512.0, 0 );
glVertex2f( 1, 0 );
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 512.0, 512.0 );
glVertex2f( 1, 1 );
glMultiTexCoord2fARB ( GL_TEXTURE0_ARB, 0, 512.0 );
glVertex2f( 0, 1 );
}
glEnd();
texture_shader->uninstall();
glFlush();
thanks for advise