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.
IndexProcessing DevelopmentLibraries,  Tool Development › Defining a new renderer
Pages: 1 2 3 4
Defining a new renderer (Read 7027 times)
Defining a new renderer
Apr 5th, 2006, 8:35pm
 
I'm looking at writing a new renderer for processing, and it looks like all that needs to happen to get it to be used in a sketch is to do:
size(200,200,"my.library.class");
and it magicly works (assuming that my.library.class extends PGraphics/3/GL/whatever).

Is this likely to work concistently, or is it pure chance that it works for an external library?

I'm making tenetive steps towards writing a pure GL library for myself, to see what sorts of speeds I can get out of it. It's not likely to be a complete translation of the current PGraphicsGL though, since that looks way over my head.
Re: Defining a new renderer
Reply #1 - Apr 5th, 2006, 9:40pm
 
yup, that's the intent of how that is set up, and i'm committed to that api and having that continue to work.

my guess is that this will be a much better way to do a library with better access to the gl object, rather than trying to retrofit things on top of PGraphicsGL.

of course i'd rather have you help out with hacking PGraphicsGL, but we'll see how far you can get with your own lib. Wink
Re: Defining a new renderer
Reply #2 - Apr 5th, 2006, 11:50pm
 
The reason I want to start from scratch is that PGraphicsGL is fairly hefty, and relies on parts of PGraphics3, so it's really hard to work out how on earth everythign actually works.

I am probably going to start by gutting a copy of PGraphicsGL, and sticking what bits of GL I know into it, and see how far I get Smiley
Re: Defining a new renderer
Reply #3 - Apr 5th, 2006, 11:59pm
 
yep. well, with any luck, maybe we'll be able to replace PGraphicsGL with yours, once you can iron it all out. Smiley
Re: Defining a new renderer
Reply #4 - Apr 6th, 2006, 1:10am
 
Is there anything in the source tree that has a list of the minimum set of methods needed to do everything?
I know that above and beyond all the user-side calls, there's beginFrame and endFrame, is there anything else behind the scenes that needs to exist, that's done on a per-frame basis?

I'm going to leave all the requestDisplay/allocate stuff along from PgraphicsGL, just wondering what things are necessary, like is handle_lighting required, or just for convenience of splitting the code up to modular pieces?
Re: Defining a new renderer
Reply #5 - Apr 6th, 2006, 9:27am
 
Hi John

How far are you with your renderer actually I also started to work on a pure OPENGL Renderer so far I have cleared up the beginShape endShape stuff and all the matrix stuff.

To ben:

I am working with a svn version of Processing, and changed some fields of Pgraphics to protected this simplified the access on the color handling for examples. One other idea, in the moment PGraphics deals many implementations bezier, ellipsemode etc. and all other Renderers extend it, wouldn't it make sense to define a renderer class with the core drawing methods like beginShape endShape and to give PGraphics an instance of this renderer. Maybe this could simplify the graphics classes and the writing of new renderers.
Re: Defining a new renderer
Reply #6 - Apr 6th, 2006, 11:01am
 
So far all I've got is a whole bunch of ideas, and a passing knowledge of how the current PGraphicsGL works, and what it does natively, and what it forks off to PGraphics3. Not actually written anything other than a test to get pure GL lighting.

From my investigations, the lighting is almost entirely useable, it just needs the PG3 parts culling, and versions writing that do no matrix munging.

The vertex stuff is similar, except GL has a native QUAD mode so quads don't need to be triangulated, and again the matrix stuff needs to go bye-bye. Also the vertex colour stuff needs a tweak, to get ambient/specular/shininess working properly for GL, not having PG3 work out the vertex colour beforehand.

camera/frustrun/perspective/translate/rotate/scales et al need converting to gl equivalents, but I think there's a fairly simple mapping. (e.g. gluLookAt/glVertexf/glRotatef) for most.

All the texture stuff is probably fine, but maybe in the translation the image corruption stuff might get sorted.
Re: Defining a new renderer
Reply #7 - Apr 6th, 2006, 3:42pm
 
tex wrote on Apr 6th, 2006, 9:27am:
I am working with a svn version of Processing, and changed some fields of Pgraphics to protected this simplified the access on the color handling for examples. One other idea, in the moment PGraphics deals many implementations bezier, ellipsemode etc. and all other Renderers extend it, wouldn't it make sense to define a renderer class with the core drawing methods like beginShape endShape and to give PGraphics an instance of this renderer. Maybe this could simplify the graphics classes and the writing of new renderers.

you're misunderstanding how all these pieces interact, and the level of complexity involved in making things work. PGraphics is this base renderer class. it will eventually be cleaned up a bit so that it's not doing so much work, but will keep things like bezier curve evaluation which is used by most of the other renderers. PGraphics2 will later become P2D, and what is now PGraphics2 will become PGraphicsJava (or something like that) and be mostly deprecated (i think i'll remove the pixel stuff, since it's terrible, for instance).
Re: Defining a new renderer
Reply #8 - Apr 6th, 2006, 3:48pm
 
Quote:
So far all I've got is a whole bunch of ideas, and a passing knowledge of how the current PGraphicsGL works, and what it does natively, and what it forks off to PGraphics3. Not actually written anything other than a test to get pure GL lighting.

From my investigations, the lighting is almost entirely useable, it just needs the PG3 parts culling, and versions writing that do no matrix munging.

The vertex stuff is similar, except GL has a native QUAD mode so quads don't need to be triangulated, and again the matrix stuff needs to go bye-bye. Also the vertex colour stuff needs a tweak, to get ambient/specular/shininess working properly for GL, not having PG3 work out the vertex colour beforehand.

camera/frustrun/perspective/translate/rotate/scales et al need converting to gl equivalents, but I think there's a fairly simple mapping. (e.g. gluLookAt/glVertexf/glRotatef) for most.

All the texture stuff is probably fine, but maybe in the translation the image corruption stuff might get sorted.

generally it's easy to map the first 70 or 80%, but there's a nasty remaining bit that is quite a headache, which is why i'm not doing this by default in PGraphicsGL. obviously i'd much prefer that everything was native calls to GL, but to properly support 100% of the p5 api, it gets very messy. since you're not doing the base GL class for everyone, you have the luxury of leaving out some bits. Wink

for instance, beginShape() with with a fill() and QUADS maps to the GL call. but what happens when you want a stroke() in there as well? you have to make the set of calls twice. which isn't a big deal but starts getting pretty messy for the list of all the gl calls to support.

later, getting lighting to match between P3D and OPENGL is a considerable headache (i think there are notes about this in the javadocs).

as for the minimum set of methods, it's essentially the set of public methods in the PGraphics object. the PMethods.java file is and empty source file but contains my notes on what the api looked like, though i think it's now out of date (and soon to disappear from svn). look at PApplet for everything that gets a g.whatever() method added to the end (the auto-generated stuff). and if you have questions about whether one thing or another needs to be included, just ask.
Re: Defining a new renderer
Reply #9 - Apr 6th, 2006, 6:14pm
 
fry wrote on Apr 6th, 2006, 3:48pm:
since you're not doing the base GL class for everyone, you have the luxury of leaving out some bits. Wink


That's pretty much why I started saying I was making a new one, rather than upgrading PGraphicsGL Smiley

For what it's worth, I've got the lighting code all GL-ified, but possibly not complete, I just removed the PG3 dependencies from it all, and it seems to work.

Did find one bug in PGraphicsGL doing it though (and yes, you were right, it was a hack in glLightDirection, it needs to be 0 not 1)

Re: Defining a new renderer
Reply #10 - Apr 7th, 2006, 10:34am
 
I solved the stroke fill issuse using display lists, but of course there remain problems like the drawing of transparent shapes, so I don't see a pure OPENGL renderer as a replacement for PGraphicsGL.

According PGraphics, I really spent some time watching the different Renderers and I know that this is very complex. But I thought the seperation of the pure rendering process and the setting of modes, calculating of colors could give more possibilities in extending things. So for example one could extend PGraphics with methods to directly draw shapes using vectors, without effecting the other renderers. So far you would have to build a wrapper that gets a PGraphics instance, wraps all its methods and adds vector support, thats what I actually did for my vector lib. Of course this all does more affect the advanced use of processing core in an ide. That was just a thought, but it would definetly make sense to make more fields of PGraphics protected so that you can access them in classes that extend PGraphics.

According to this where do you see possibilities to extend processing? I would really like to join the workshop in Barcelona and take sometime to think about further developments before.

Re: Defining a new renderer
Reply #11 - Apr 7th, 2006, 1:46pm
 
right, this is more of how PGraphics will evolve, if you've looked at the source more recently, a lot more of the methods are being opened up.

generally, the idea is for the PGraphics object to handle the basics, i may even just make it an abstract class so that it's clearer what methods must be overridden for another renderer. so things like the color calculations would still be in PGraphics so that subclasses need not deal with them (i.e. look at how the calcColor stuff works in PGraphicsGL).

the class structure will look something like this:
Code:

PGraphics2 (P2D) -> PGraphicsPDF, PGraphicsSVG
PGraphics <
PGraphics3 (P3D) -> PGraphicsGL


as for extending processing, maybe we should start a separate topic on that. i think everyone's wish list would be different, but i'm sure we could all ramble for a while about things that we'd like to see.
Re: Defining a new renderer
Reply #12 - Apr 7th, 2006, 3:34pm
 
Quick update, I've now for real go lighting sorted.. previously my version got confused if you had both directional and spotlights in a scene together.

Also, because I've managed to remove the processing matrix fiddling, GLSL shaders can be used and will give the epxected results.. and these work in applets if your video card supports them.

So that means it's possible to have per-pixel lighting. And possibly shadowing, but that'll require a fair chunk of work I think. Anyway, here's some eye-candy:

http://www.hardcorepawn.com/NewGL/
Re: Defining a new renderer
Reply #13 - Apr 7th, 2006, 3:48pm
 
Hey JohnG,

Thanks very much for all the work you're inverting in creating this new GL renderer.  You seem to really be advancing in the quest.

Nice example! nice lightning!

There's a little problem when I run it though.  It's the same problem I had with the old way I did OpenGL applets.

When I refresh the page with the OpenGL applet or click the back button, after having ran it for a while, my Firefox crashes.

If you want more details I can send you by email the hs_err_pidxxxxx.log file that the jvm generates.

I was hoping that the new jogl version and joglAppletLauncher would fix it, but it doesn't look like it.  This is what made me remove all the GL applets I had in my Caligraft site.

Anyway thanks a lot for this contribution!
Re: Defining a new renderer
Reply #14 - Apr 7th, 2006, 4:19pm
 
I think it's a firefox issue rather than a Java one. I had that problem with the original non-sun-endorsed JOGLAppletLauncher, but not with the current one, hoewver I've moved to firefox 1.5 since then.

What version of firefox are you using?
Pages: 1 2 3 4