Jump to content
  • Advertisement
Sign in to follow this  
gualaopo

Help: PBO + pbuffer problem

This topic is 4677 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 do some image process with GPU. I use the PBO(pixel_buffer_object) to get the input stream image date from the video_capture device. It's done. Then I need to do some ping-pong operation in pbuffer,but it doesn't work. I see I can only render the PBO to a single pbuffer,and then render the pbuffer to sceern.If I use the pbuffer's two surface(GL_BACK and GL_FRONT) to do ping-pong,it seemed that the texture data in PBO skip the pbuffer,and render to screen directly. I think the pbuffer configuration is right because the static texture instead of PBO works well. can anybody help me ,thx!!!!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by phantom
code?

btw, unless you have a very good reason, favour using the framebuffer object extension over the pbuffer one, its 'better' in most cases




//the PBO has been initialed before
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
img = getNextImage();

//upload texture to GPU with PBO
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, texBuffer);
>sizeX*img->sizeY*3, NULL, GL_STREAM_DRAW_ARB);
void *pboMemory = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, GL_READ_WRITE);
memcpy(pboMemory, img->data,img->sizeX*img->sizeY*3);
glBindTexture(GL_TEXTURE_RECTANGLE_NV,tex);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, img->sizeX, img->sizeY, GL_RGB, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);

//render to pbuffer
rt->BeginCapture ();
glDrawBuffer(GL_FRONT);
glBindTexture(GL_TEXTURE_RECTANGLE_NV,tex);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1, -1);
glTexCoord2f(0, 0); glVertex2f( 1, -1);
glTexCoord2f(0, 0); glVertex2f( 1, 1);
glTexCoord2f(0, 0); glVertex2f(-1, 1);
glEnd();
glDrawBuffer(GL_BACK);
rt->BindBuffer(WGL_FRONT_LEFT_ARB);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1, -1);
glTexCoord2f(1, 0); glVertex2f( 1, -1);
glTexCoord2f(1, 1); glVertex2f( 1, 1);
glTexCoord2f(0, 1); glVertex2f(-1, 1);
glEnd();
rt->EndCapture();
rt->BindBuffer(WGL_BACK_LEFT_ARB);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(-1, -1);
glTexCoord2f(1, 0); glVertex2f( 1, -1);
glTexCoord2f(1, 1); glVertex2f( 1, 1);
glTexCoord2f(0, 1); glVertex2f(-1, 1);
glEnd();
}


I used to do this with FPO,but get the same rusult!

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!