Uh, again, I didn't mean actual pickling, just something HAND-MADE, that has the same end-point. And it doesn't sound tricky at all, really. What you'd be doing is saving the current state of the context (any enabled bits, any disabled bits, any loaded resources, etc), restoring them (if possible, if not, fail gracefully with a 'could not complete' message). Each game object needs to have its hand-made pickling routine. You create a sprite? You also add a pickle and unpickle method to it that saves what YOU want it to. By default, for example in a sprite, you'd be saving the image filename, and any attributes in the pickle method. In the unpickle method, it'd recreate a Sprite class with the same filename, then set the attributes.
If _anything_ can't be done, contradicts, isn't valid, it fails with a simple error. This isn't any different to python's pickling. It's up to you to use it properly, it isn't a fix-all solution. This was just an idea, but after seeing this response I'm thinking of actually writing it up just to prove that it's not that complex. On 19 July 2011 09:50, Jonathan Hartley <[email protected]> wrote: > > write a pyglet 'pickle' method, that > > actually saves the current window/context states AND... > > I am a bear of little brain, but this sounds very tricky and not at all > desirable. There is a massive amount of information implied here, and you > absolutely *don't* want to be restoring most of it when you restore the > (x,y) and other model state of a single game object. It implies that you'd > be restoring all the opengl state repeatedly, once for every game object you > load. What if the state saved with one object contradicted that stored with > another? What if you're restoring on a different machine, so the same state > information isn't valid? > > I may be wrong but I think these ideas of pickling Sprites are totally > swimming against the current. It is much easier and more useful to only > pickle simple value-type objects (e.g. integers and strings), and > re-construct any required Sprites by calling the Sprite constructor as usual > when you restart the application. > > -- > You received this message because you are subscribed to the Google Groups > "pyglet-users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/pyglet-users/-/mVkz7ifzGzkJ. > > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pyglet-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.
