[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [PyGame + PyOpenGL] Setting Target Surface



On 4/6/06, Sami Hangaslammi <sami.hangaslammi@xxxxxxxxx> wrote:
> On 4/6/06, Mike Wyatt <mwyatt@xxxxxxxxx> wrote:
> > onto the back buffer, then flipping the final image to the screen. This
> > will be used for fade in/out transitions between game screens.
>
> You can't directly render to other pygame Surfaces. I _think_ the way
> you are supposed to do this sort of thing is to render to the back
> buffer and then read the pixel data with glReadPixels after which you
> can transform it into a texture and render it in a quad.
>
FYI, glReadPixels tends to be very slow (fastest is memory around on
the video card, second is moving memory around system memory, slowest
is moving memory to and from system memory and the card)

so if the scenes you are building to be transitioned are dynamic,
changing every frame, then you would be much better off keeping the
renders on the card, by pulling the rendered scenes into a texture
with glCopyTexImage2D, rather than using a pygame surface as an
intermediate layer. (with a pygame surface, you'd need to stuff it's
data in a texture before rendering anyways, so you save 2 steps in
that case)

check this tutorial for a blur effect done with render to texture
(done in c++, but the gl calls should be easy to follow)
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=36