How to stop pyglet from clearing the screen ?

35 views
Skip to first unread message

mayasky

unread,
Nov 14, 2009, 4:29:09 PM11/14/09
to pyglet-users
I want to draw a scene and successively add lines to it. But pyglet
keeps updating and clearing everything :( , so all I get is blinks of
a single line...

from pyglet.gl import *

window=pyglet.window.Window()

def drawline():
...

@window.event
def on_draw():
drawline()

pyglet.app.run()

what should I do? thanks。

val

unread,
Nov 14, 2009, 8:28:47 PM11/14/09
to pyglet...@googlegroups.com
Hi

You can use a frame buffer (look for FBO in this mailing list and
you'll get some code).

Tristam MacDonald

unread,
Nov 14, 2009, 8:57:58 PM11/14/09
to pyglet...@googlegroups.com
On Sat, Nov 14, 2009 at 8:28 PM, val <val.b...@gmail.com> wrote:

You can use a frame buffer (look for FBO in this mailing list and
you'll get some code).

Or you can implement a replacement for pyglet.app.run(), which doesn't call window.clear() every frame.

--
Tristam MacDonald
http://swiftcoder.wordpress.com/

Richard Thomas

unread,
Nov 15, 2009, 1:03:58 AM11/15/09
to pyglet-users
Pyglet doesn't automatically clear the screen... If you don't call
window.clear or glClear it should work.

import pyglet
import random
window = pyglet.window.Window()
window.clear()
@window.event
def on_draw():
w, h = window.width, random.randrange(window.height)
pyglet.graphics.draw(2, pyglet.gl.GL_LINES,
('v2f', [0, h, w, h]),
('c4B', [255, 0, 0, 255] * 2))
pyglet.clock.schedule(lambda dt: None)
pyglet.app.run()

On Nov 15, 1:57 am, Tristam MacDonald <swiftco...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages