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.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Off-screen OpenGL rendering
Page Index Toggle Pages: 1
Off-screen OpenGL rendering (Read 3736 times)
Off-screen OpenGL rendering
Jul 4th, 2007, 9:25pm
 
Hi,

I want to maintain several contexts with different properties, in app using the OpenGL render.

Something similar to that example:
http://processing.org/learning/basics/creategraphics.html

I know this is not possible to use createGraphics() with OpenGL. I found out even before reading the documentation :-)
Error I got when compiling in Elcipse - "PGraphicsOpenGL can only be used as the main drawing surface"

In that thread v3ga seems to say that it's possible to do off-screen rendering in OpenGL, but no more than that -  http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1114400513;start=

I also read some stuff about offscreen rendering via pbuffers, but before going further in that scary direction I wanted to ask if anybody could direct me.

Thanks.
Re: Off-screen OpenGL rendering
Reply #1 - Jul 6th, 2007, 5:40pm
 
ok...so after some research and discussions with some really helpful people (such as v3ga) the possible solutions are:

-render to texture
-FBOs
-the Gestalt Lib.

also with straight Processing the following seems to be working:
 size(800, 600, OPENGL); // Opengl for the main context
 pg = createGraphics(400, 400, P3D); // P3D for the secondary context
Re: Off-screen OpenGL rendering
Reply #2 - Jul 11th, 2007, 5:34am
 
Hey...

I have been able to run most of those examples in Processing [under Eclipse] : http://pepijn.fab4.be/?page_id=34

But I can not make the Lesson36 to work. The 'spring' surface stays white/blank. No texture are created and mapped.

Could it be due to the use of FBO ?
Does OpenGL [jogl] part of processing includes FBOs ?
I'm not even sure that those question make sense ;-]
Re: Off-screen OpenGL rendering
Reply #3 - Jul 14th, 2007, 5:11am
 
ok... well I'm going to continue to speak to myself...;-)

I read this about PGraphicsOpenGL : "This code relies on PGraphics3D for all lighting and transformations. Meaning that translate(), rotate(), and any lighting will be done in PGraphics3D, ..."

http://dev.processing.org/reference/everything/javadoc/processing/opengl/PGraphicsOpenGL.html

Could it be why I'm having difficulty to make Lesson36 to work ? Does the fact that lighting is done in P3D 'reduce' the use of OpenGl direct call to ligthing commands ?
Re: Off-screen OpenGL rendering
Reply #4 - Jul 14th, 2007, 9:29pm
 
I think it all depends exactly how you're making your OpenGL calls.  If you're going through the Nehe lessons, you probably want to do everything through OpenGL, which means pretty much nothing through the PGraphicsOpenGL graphics calls other than maybe just getting the OpenGL context:

import processing.opengl.*;
import javax.media.opengl.*;
GL gl;
[in setup]:
gl = ((PGraphicsOpenGL) g).gl;

at which point all your OpenGL calls will be done as gl.something().

In Processing, all lighting and transformations are indeed carried out in software, so the OpenGL camera stuff is basically just set at a default and left there, and OpenGL lighting is not used at all (Processing manually moves the polygons into the correct locations and colors the vertices to do lighting, I think mainly to ensure consistency as much as possible between P3D and OpenGL and avoid dealing with graphics card quirks in lighting).  This very well may be a problem for what you're doing, it really depends exactly how you make all your calls - technically speaking, this type of stuff is unsupported, so there's no guarantee everything will interact nicely, though I know a lot of people have figured out how to use direct OpenGL calls effectively in Processing.  Processing's drawing tools are unlikely to help you at all when it comes to rendering to a texture, so if you're doing stuff like that, keep it pure OpenGL to the extent that is possible.

Maybe if the code is not too complex it would be worth posting it to see what's going on?
Re: Off-screen OpenGL rendering
Reply #5 - Jul 17th, 2007, 5:01am
 
Yes exactly. One of the reasons I’m doing this, is to have the OpenGL context created by Processing in order to still be able to use Processing advantages [and the libs available for Processing.] .

At this link you can find the source code and two screenshots. http://www.smallfly.com/temp/

The code corresponds to the Lessons36 [radial blur], but it has been trimmed down. There is no more code to create the “radial blur”, only the code for the spring shape and the light has remained. [no more render to texture or frame buffer object – only simple stuff ;-] But as you can see the color and lighting [set via gl.glMaterialfv] doesn’t get applied.

I have tried many different thing to make this work, but with no success.

Here I’m getting away of my initial task which is off screen rendering using FBOs, but now I’m curious to make that work too.
Re: Off-screen OpenGL rendering
Reply #6 - Jan 27th, 2010, 6:27pm
 
Re: Off-screen OpenGL rendering
Reply #7 - Jan 28th, 2010, 2:44am
 
make sure you copy Vitamin to your libraries folder and run the example.
http://www.pixelnerve.com/downloads/NeonEffect.zip


from:
http://processing.org/discourse/yabb2/num_1262637573.html#8
Page Index Toggle Pages: 1