• Advertisement
Sign in to follow this  

question about pbuffer

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i want to use 2 pbuffers in my program.but i didn't sucess. step as follow: 1. initial 2 pbuffers; 2. make the buffer[1]'s context current; 3. render to pbuffer[1]; 4. make the buffer[2]'s context current; 5. bind buffer[1] to texture[1]; 6. render to pbuffer[2]; 7. make framebuffer's context current,bind buffer[2] to texture[2],then render to screen(display the texture[2]); but nothing on the screen ,like black texture.what's wrong? i'm not sure the steps are all right or if there is something wrong in details. i use "wglmakecurrent" to change the context,is there some other things i have to do? thx!

Share this post


Link to post
Share on other sites
Advertisement
did you use wglShareLists() to share the resources between the main and the two pbuffer contexts?

This is something which trips a fair few people up (even myself once) as the pbuffers are totally new contexts and by default dont share any of the characteristics of your main buffer, thus when you create them you should bind them current and perform you standard OpenGL setup on them (projection matrix, clear colors etc) and then call the wglShareLists() function to share any textures, VBOs, display lists etc between them and the main context.

Share this post


Link to post
Share on other sites
Thanks a lot!
I didn't use wglShareList(),because it works well if there is only 1 pbuffer(render-to-pbuffer-to-screen).I'll try to use wglShareList().
my display card is ATI R9550.there is render code as followe:

void render( void )
{

int flag = 0;
wglQueryPbufferARB( pbuffer[0].hPBuffer, WGL_PBUFFER_LOST_ARB, &flag );

if( flag != 0 )
{
MessageBox(NULL,"The p-buffer was lost!",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
exit(-1);
}

// Render to pbuffer[0]
wglMakeCurrent( pbuffer[0].hDC, pbuffer[0].hRC );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -5.0f );
glBindTexture( GL_TEXTURE_2D, TextureID );
Draw()

// Bind pbuffer[0] to texture and render to pbuffer[1]
wglMakeCurrent( pbuffer[1].hDC, pbuffer[1].hRC );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -5.0f );
glBindTexture( GL_TEXTURE_2D, dynamicTextureID[0] );
wglBindTexImageARB( pbuffer[0].hPBuffer, WGL_FRONT_LEFT_ARB );
Draw();
wglReleaseTexImageARB( pbuffer[0].hPBuffer, WGL_FRONT_LEFT_ARB );
// Bind pbuffer[1] to texture and render to screen
wglMakeCurrent(hDC, hRC);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -5.0f );
glBindTexture( GL_TEXTURE_2D, dynamicTextureID[1] );
wglBindTexImageARB( pbuffer[1].hPBuffer, WGL_FRONT_LEFT_ARB );
Draw()
wglReleaseTexImageARB( pbuffer[1].hPBuffer, WGL_FRONT_LEFT_ARB );

SwapBuffers(hDC);
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement