PDA

View Full Version : PBUFFER!!!



I_dont_know
02-23-2004, 10:04 AM
How to flush my pbuffer to the main window (not to the texture - it is too slow)?

Thanks.

hortitude
02-23-2004, 12:45 PM
I have yet to find any good way. The best I've managed is to use the pbuffer as a render-to-texture.

When I set up my context instead as the normal frame buffer I get about the same results for frame time as when I use the pbuffer and then display it as a texture.

Alternatively you could call ReadPixels and then display it in some other manner in your window -- but I don't think you'll find that any faster

I_dont_know
02-24-2004, 09:38 AM
Originally posted by hortitude:
I have yet to find any good way. The best I've managed is to use the pbuffer as a render-to-texture.

When I set up my context instead as the normal frame buffer I get about the same results for frame time as when I use the pbuffer and then display it as a texture.

Alternatively you could call ReadPixels and then display it in some other manner in your window -- but I don't think you'll find that any faster

I need to render into the pbuffer (1600 by 1200 pixels) and flush this static image to the main window of my program (like in DirectDraw, where you can create several drawing planes) and then draw the dynamics. Texture reading and binding take a lot of time. I think there should be a way to flush pbuffer's contents to the window like we do it with ordinal frame buffer, because they use the same video memory.

Maybe I should change some attributes. When rendering to texture I use these parameters:

int pb_attr[] =
{WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB, // Our p-buffer will have a texture format of RGBA
WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB, // Of texture target will be GL_TEXTURE_2D
0 // Zero terminates the list
};

but there are many other attributes (which can tell to OpenGL to create an analog of frame buffer for the main window)?

Thanks.

NitroGL
02-24-2004, 10:11 AM
Originally posted by I_dont_know:
How to flush my pbuffer to the main window (not to the texture - it is too slow)?

Thanks.

glCopyPixels and WGL_ARB_make_current_read? Though that won't work on nVidia based cards.

[This message has been edited by NitroGL (edited 02-24-2004).]

roffe
02-25-2004, 04:38 PM
Does your pbuffer and window have the same pixelformat and similiar size?

If so, skip the pbuffer, render to backbuffer and use CopyPixels. Don't forget to change Draw/ReadBuffer though.


[This message has been edited by roffe (edited 02-25-2004).]

I_dont_know
02-26-2004, 11:06 AM
Can you write a code structure of your advice (C or Pascal), roffe?

roffe
02-26-2004, 04:25 PM
Originally posted by I_dont_know:
Can you write a code structure of your advice (C or Pascal), roffe?

I'll try. Take it for what it is. I've never tried using glCopyPixels between back and front myself, but I've heard it should work just fine.

// assuming active window ctx with dbl buffering

glDrawBuffer(GL_BACK);
//render something to main wnd
renderSomething();

//swap/copy data into front buffer
SwapBuffers(win.hdc);

// render what you needed to render into the pbuffer
glClear(...);
setupSpecialViewport();
setupSpecialProjection_Viewing();
specialRender();

// selectively copy from back to front
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_BACK);

// specify rectangle and raster position for "special" render
setup_waitfor_RasterPos();
glCopyPixels(...);

//restore states/other