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 › render vertex array to offscreen using glgraphics
Page Index Toggle Pages: 1
render vertex array to offscreen using glgraphics (Read 1076 times)
render vertex array to offscreen using glgraphics
Sep 15th, 2009, 3:04pm
 
Hej,

I try to render a particle system with a vertex array offscreen. I use glgraphics:

Code:
off = new GLGraphicsOffScreen(this, 800, 600, true, 4); 



And then somewhere else in the code my particle renderer:

Code:

   PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
   GL gl = pgl.beginGL();
   gl.glEnable( GL.GL_BLEND );
   gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE);
   gl.glEnable(GL.GL_POINT_SMOOTH);
   gl.glPointSize(esize);

   gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
   gl.glVertexPointer(3, GL.GL_FLOAT, 0, posarray);
   gl.glEnableClientState(GL.GL_COLOR_ARRAY);
   gl.glColorPointer(3, GL.GL_FLOAT, 0, colarray);

   gl.glDrawArrays(GL.GL_POINTS, 0, pmax);
   gl.glDisable(GL.GL_BLEND);
   pgl.endGL();


I tried some ideas ... but I do not have enough insights to make this right.

I started to add "off.beginDraw();" and "off." before some lines but it would not work. Then I tried something like this, because I figured that GLGraphicsOffScreen could be a PGraphicsOpenGL:
Code:
    PGraphicsOpenGL pgl = (PGraphicsOpenGL) off; 



But that was not working either. It was just rendering to the screen directly.

Any ideas?

Thanks.
Re: render vertex array to offscreen using glgraphics
Reply #1 - Oct 8th, 2009, 3:10pm
 
mmm, GLGraphicsOffscreen is not designed to work with openGL calls. One option would be to create a GLModel object, put your particle system in it and then render the GLModel to the offscreen surface. Something like this:

glg1.beginDraw();
   cam.feed();
   cam.clear(0);    
   model.render();
   cam.done();  
 glg1.endDraw();  

The GLModel object is a recent addition to GLGraphics. In terms of performance, it is very fast because uses VBO's internally to store the vertices. The latest package includes some examples. I hope this answer is still useful.
Page Index Toggle Pages: 1