We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Layering Demos
Page Index Toggle Pages: 1
Layering Demos (Read 1577 times)
Layering Demos
Dec 9th, 2009, 8:12pm
 
I built a library for Processing that allows the developer to write sketches with multiple layers that are drawn independently of one another.  All the info about the library is here: http://nootropicdesign.com/processing-layers/

Some demos that show the capability:
Paintball: http://nootropicdesign.com/processing-layers/Paintball/applet/index.html

LaserBurn: http://nootropicdesign.com/processing-layers/LaserBurn/applet/index.html

Re: Layering Demos
Reply #1 - Dec 10th, 2009, 6:19pm
 
Very Interesting...  Smiley
Re: Layering Demos
Reply #2 - Dec 11th, 2009, 4:37am
 
Michael,

I've made a program very similar to yours that you may be curious to see the source code of, to give you ideas: http://www.onar3d.com/mother/

It is like yours, but OpenGL only, and has been in development in quite a while now, so it's feature set is pretty stable.

Knowing how OpenGL works, I believe you will find it is very difficult to get your idea working with sketches that run different renderers, ie layering three sketches, where one runs P2D, the other P3D and a third running in OPENGL. At least to get it running efficiently.

Because it will necessarily involve copying screen-sized images back and forth between the graphics cards memory and the computers memory once for each sketch, per frame, making for a great deal of unnecessary overhead.

Anyway, cool to see more people interested in the idea!
Re: Layering Demos
Reply #3 - Dec 11th, 2009, 5:12am
 
Totally awesome stuff.

I will apply this to a tennis game I wanted to do.
Re: Layering Demos
Reply #4 - Dec 11th, 2009, 5:15am
 
I like the idea; but I'd be happy enough with something that allowed me to switch the ordering of layers on-the-fly without necessarily treating each individual layer as a separate sketch - though I do see the benefit of not having to re-calculate an unchanged 'layer' each frame.

I've got into the habit of using registerDraw on classes and it would be handy to be able to change the rendering order as and when required.  Apparently Processing stores registered classes in an array...  No idea if this is exposed or what would happen if you changed the order whilst the sketch is running... Alternatively I guess you could unregister and re-register in the required order, but again no idea what effect this might have...
Re: Layering Demos
Reply #5 - Dec 11th, 2009, 7:07am
 
Are the layers some kind of ArrayList with PGraphics?
Re: Layering Demos
Reply #6 - Dec 11th, 2009, 1:47pm
 
bredend:
yes, each layer has its own PGraphics object, and the PAppletLayers object manages an ArrayList of PLayer objects.

Take a look at the source code here:
http://layers.svn.sourceforge.net/viewvc/layers/trunk/src/com/nootropic/processi...


This library only has two classes.  It's a shockingly small amount of code needed to accomplish layering. (not that it wasn't challenging...)

Page Index Toggle Pages: 1