sghr / iGeo

iGeo: Computational Design and 3D Modeling Library for Processing
http://igeo.jp
GNU Lesser General Public License v3.0
146 stars 34 forks source link

save/saveFrame with update method #29

Open Renroujos opened 3 years ago

Renroujos commented 3 years ago

I am fairly new to both Processing and iGeo and for the life of me I cannot figured out how to take a simple screenshot of the canvas properly.

Take for instance the code below: I am creating a bunch of random points one by one on XY plane. At each update iteration/duration I want to capture a screenshot to make a gif file afterward. When I run the code, I will either get the "com.jogamp.opengl.GLException: GL-Error 0x502" or the generated screenshots will be all black with no objects in it.

I can, as a last resort, create a keyPressed function with the save/saveFrame method inside to capture screenshot on key press and that works, but it seems extremely counter intuitive. What am I doing wrong? What is the proper method to capture screenshot sequentially with iGeo? I am using iGeo 0.9.4.1 and Processing 3.5.4 on Python mode.

the code:

add_library('igeo')

def setup():

size(480,360,IG.GL)
IG.bg(1)
IG.persTarget()
IG.duration(20)    
rPoint = RandPoint(0,200)

class RandPoint(IAgent):

points = []
frame = 0

def __init__(self, mm, mx):

    self.min = mm
    self.max = mx

def update(self):

    min = self.min
    max = self.max
    self.points.append(IPoint(IRand.get(min, max), IRand.get(min, max),0).clr(IRand.clr()))
    self.frame += 1
    print('add point number {}'.format(self.frame)) 
    save('ss'+str(self.frame)+'.jpg')