Ok here is my little sample. Hopefully the Pbuffer things are self explaining.
this is the shader code:
void main(void){
gl_FragColor = vec4( 10.0, 10.0, 10.0, 1.0 );
}
this code writes the values (simple fragment shader):
void main(void){
gl_FragColor = vec4( 10.0, 10.0, 10.0, 1.0 );
}
void drawTest()
{
pBuffer[0]->useAsBuffer( WGL_BACK_LEFT_ARB );
glClearColor( 0.5, 0.5, 0.5, 0.0 );
glClear( GL_COLOR_BUFFER_BIT );
Shader *funcC = new Shader("func_lc");
funcC->install();
// draw things
glColor3f( 1.0, 0, 0 );
glBegin( GL_TRIANGLES );
{
glTexCoord2i( 0, 0 );
glVertex2f( -1.0f, -1.0f );
glTexCoord2i (1 , 0 );
glVertex2f( 1.0f, -1.0f );
glTexCoord2i ( 1, 1 );
glVertex2f( 1.0f, 1.0f );
}
glEnd();
funcC->uninstall();
pBuffer[0]->useAsTexture( WGL_BACK_LEFT_ARB );
renderSingleTexture();
pBuffer[0]->unbind( WGL_BACK_LEFT_ARB );
}
and this code reads the values back from the pbuffer (mbuffer is floating point array):
pBuffer[0]->useAsBuffer( WGL_BACK_LEFT_ARB );
glReadBuffer( GL_BACK );
glReadPixels( 0, 0, 512, 512, GL_LUMINANCE, GL_FLOAT, mbuffer );
pBuffer[0]->disable();
is this okay, or is it impossible to get the float values back that way? Its not that important to get the float values back, but I need to be sure, that the values stored in the pbuffer are unclamped floats.