Rendering animations without background and saving snapshots

72 views
Skip to first unread message

Carson Farmer

unread,
Sep 3, 2012, 7:55:18 PM9/3/12
to pyprocess...@googlegroups.com
Hi list, this may actually be two separate problems, but hopefully someone can point me in the right direction? Firstly, when trying to save a snapshot (via save()) in my pyprocessing sketch, I keep getting the following error:
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    run()
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing/__init__.py", line 435, in run
    pyglet.app.run()
  File "/usr/lib/pymodules/python2.7/pyglet/app/__init__.py", line 264, in run
    EventLoop().run()
  File "/usr/lib/pymodules/python2.7/pyglet/app/xlib.py", line 82, in run
    window.dispatch_platform_event(e)
  File "/usr/lib/pymodules/python2.7/pyglet/window/xlib/__init__.py", line 1169, in dispatch_platform_event
    event_handler(e)
  File "/usr/lib/pymodules/python2.7/pyglet/window/xlib/__init__.py", line 1333, in _event_key
    self.dispatch_event('on_key_press', symbol, modifiers)
  File "/usr/lib/pymodules/python2.7/pyglet/window/__init__.py", line 1219, in dispatch_event
    EventDispatcher.dispatch_event(self, *args)
  File "/usr/lib/pymodules/python2.7/pyglet/event.py", line 340, in dispatch_event
    if handler(*args):
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing/__init__.py", line 139, in on_key_press
    callback.keyPressed()
  File "test.py", line 17, in keyPressed
    save('frame%s.png' % frame.count)
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing/pimage.py", line 741, in save
    get().save(filename)
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing/pimage.py", line 716, in get
    return PImage(pyglet.image.get_buffer_manager().get_color_buffer())
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing/pimage.py", line 55, in __init__
    self.loadPixels()
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing/pimage.py", line 61, in loadPixels
    self.buf = self.img.get_image_data().get_data('BGRA',-self.width*4)
  File "/usr/lib/pymodules/python2.7/pyglet/image/__init__.py", line 2046, in get_image_data
    glReadBuffer(self.gl_buffer)
  File "/usr/lib/pymodules/python2.7/pyglet/gl/lib.py", line 105, in errcheck
    raise GLException(msg)
pyglet.gl.lib.GLException: invalid operation

This error occurs when I use hint(FBO_FLIP_POLICY), a similar error occurs when I use hint(ACCUM_FLIP_POLICY) (though it crashes right away), and I don't seem to be able to get hint(SINGLE_FLIP_POLICY) to display anything, whereas hint(DOUBLE_FLIP_POLICY) works some of the time, but only if background() is used (i.e. not if I try to preserve traces, via fill(255, 255, 255, 20); rect(0, 0, width, height); for example). In reality, FBO_FLIP_POLICY is the only one that seems animate smoothly, and it allows me to use avoid using background(), but it craps out when trying to capture frames via save (i.e. produces above error)... In short, my questions are:
1) Why some flip policies require the background to be updated each time the scene is drawn
2) Why some flip policies have the above OpenGL exception
Any ideas on what I might do to fix/workaround these issues? Alternatively, does anyone have a better/preferred way of generating videos of pyprocessing animations?

I'm running on ubuntu 12.04 LTS 64bit, on a TOSHIBA laptop with an Intel Core i3-2367M processor @ 1.40GHz with Intel HD 3000 onboard graphics using Intel® Sandybridge Mobile driver.

Thanks for any pointers,

Carson

P.S. Here is a compact example that produces the above error on my system (based on one of the default examples):

from pyprocessing import *

hint(FBO_FLIP_POLICY)
size(100,100)

background(56, 90, 94)
smooth()
x = 0
strokeWeight(12)
for i in range(51,256,51):
  stroke(242, 204, 47, i)
  line(x, 20, x+20, 80)
  x += 20

def keyPressed():
    if key.char=="d":
        save('frame%s.png' % frame.count)

run()
Reply all
Reply to author
Forward
0 new messages