There are any way to get a auxiliary buffer video for blit?

2 views
Skip to first unread message

Hugo Ruscitti

unread,
Feb 11, 2008, 10:19:49 AM2/11/08
to pyglet...@googlegroups.com
Hi, i need to get a transition effect with 2 scenes in a
game with pyglet. Being a SDL/pygame programmer, i don't know
if my strategy is suitable in pyglet:

I think I need a copy reference to buffer video, blit every game
object in this buffer an later, when the user change to a new
scene, show a gradual transition between 2 buffers (one to
last scene, and other to new scene).

So, there are any variant to image blit method with a destination
image parameter?, some like:

buffer = create_auxiliary_buffer()
alternative_blit(game_object_image, buffer, x, y)

buffer.blit(0, 0)
window.flip()

Note that i can't blit directly with double buffer driven by
pyglet, like:

image.blit(x, y)
window.flip()

because i want to show a transition effect with 2 scenes, and
i not find other way -- maybe this is my real problem :|

Thanks.

--
Hugo Ruscitti
www.losersjuegos.com.ar

Austin Wood

unread,
Feb 11, 2008, 6:05:59 PM2/11/08
to pyglet...@googlegroups.com
On Feb 12, 2008 2:19 AM, Hugo Ruscitti <hugoru...@gmail.com> wrote:
>
> Hi, i need to get a transition effect with 2 scenes in a
> game with pyglet. Being a SDL/pygame programmer, i don't know
> if my strategy is suitable in pyglet:
>
> I think I need a copy reference to buffer video, blit every game
> object in this buffer an later, when the user change to a new
> scene, show a gradual transition between 2 buffers (one to
> last scene, and other to new scene).

You can do this using blending in OpenGL.

This basically covers what you want to do, but I think you'll need to
disable depth testing as you draw the second image.
http://jerome.jouvie.free.fr/OpenGl/Tutorials/Tutorial9.php#MixPicture

HTH

Simon Wittber

unread,
Feb 11, 2008, 9:06:04 PM2/11/08
to pyglet-users
On Feb 12, 12:19 am, "Hugo Ruscitti" <hugorusci...@gmail.com> wrote:
> Hi, i need to get a transition effect with 2 scenes in a
> game with pyglet. Being a SDL/pygame programmer, i don't know
> if my strategy is suitable in pyglet:
>
> I think I need a copy reference to buffer video, blit every game
> object in this buffer an later, when the user change to a new
> scene, show a gradual transition between 2 buffers (one to
> last scene, and other to new scene).
>

Have a look at the docs for glAccum and the OpenGL accumulation
buffer. It should solve your problem quite elegantly.

-Sw.

Hugo Ruscitti

unread,
Feb 12, 2008, 8:06:35 AM2/12/08
to pyglet...@googlegroups.com

Thanks, I get a example program that works fine to create a blend transition:

-- %< --
from pyglet import window
from pyglet.window import key
from pyglet.image import load
from pyglet.gl import *

window = window.Window(width=640, height=480)
window.set_location(200, 200)

a = load('a.png')
b = load('b.png')
i = 1.0

while not window.has_exit:
window.dispatch_events()

b.blit(0, 0)
glEnable(GL_BLEND)
glDisable(GL_DEPTH_TEST)

if i > 0:
i -= 0.01

glColor4f(1, 1, 1, i)

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
a.blit(0, 0)
glDisable(GL_BLEND)

window.flip()
-- %< --

But, I only can blend two images loaded from files. I can't draw any image
above ImageData instance.

I looking for something like:

>> player_imagedata.blit_in_a(background_or_buffer_imagedata, x, y)

in other words, blit in a auxiliary ImageData instance, not in a
backbuffer driven
by pyglet. It is possible?.

Thanks to all !.

--
Hugo Ruscitti
www.losersjuegos.com.ar

Reply all
Reply to author
Forward
0 new messages