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 › multiscreening (4 screens) on one machine...
Page Index Toggle Pages: 1
multiscreening (4 screens) on one machine... (Read 1058 times)
multiscreening (4 screens) on one machine...
Jan 15th, 2008, 11:15am
 
Hi there.

I'm running an application simulating gravitational body-movement on one Quad-Core machine and I want to use a Quad-Head-Card to display the output on 4 beamers... Each display shall have a size of 1024x768 arranged like this:
_ _
|_|_|
|_|_|

giving a total screen-size of 2048x1536 with an overlapping area between each of the screens.

My problem now is to manage the overlapping.

I've tried using PGraphics

pg1  = createGraphics(full_width, full_height, P3D);
pg2  = createGraphics(half_width, half_height, P3D);

to grab the respective areas from the simulation (pg1), applying an alpha-mask and then combining the final output by putting these 4 images together.

pg2.copy(pg1, 0, 0, half_width, half_height, 0, 0, half_width, half_height);
pg2.mask(alphaImg);
image(pg2, 0, 0);

The problems there were - this is way to slow and somehow seems to eat up my memory - giving me the OutOfMemory-Exception after a few frames.

Another idea is to double-draw the images spanning two or more screens an try to mask them accordingly... This might work for the objects themselves, but I want/have to draw a trailing line to better see the way the object flew...

These trails are, what would make this idea extremely problematic. The images can be masked so that they don't reach into the neighbor-image - but the lines? I guess I would have to render these into a PGraphics, mask them and then render them into the screen... But that would probably give me the same or similar problems I had with the first idea...

Then I saw the MPE-Project, but even the simple example-project given on the MPE-Site seems to lag at this size... Am I doing something wrong here?

Does anybody have another idea how I could accomplish what I'm trying to do?

Any help is appreciated...

Sven
Re: multiscreening (4 screens) on one machine...
Reply #1 - Jan 15th, 2008, 4:16pm
 
hi Sven,

the overlapping with projections is called "soft edging". There is software/hardware especially for this purpose, but when i researched about this last time, all of them were quite costly.
I've made some atempts with real time softedging too, but had the same issues of speed. MPE was not out back then, so i have not tried it.

Here's the source of my basic soft-edging test:
http://www.extrapixel.ch/processing/softedging/softedging1.pde

maybe it runs well enough on your machine, but on my macbook pro i can't get a serious framerate using real projector resolutions. The copy() and image() operations are just too slow on large images i guess...
Re: multiscreening (4 screens) on one machine...
Reply #2 - Jan 15th, 2008, 7:59pm
 
Hi there...

Thanks a lot for your reply...

Well, in the end my problem is not the "soft edging" itself, for the projectors that schall be used are capable to create the neccessary fading-effects themselves - all I have to do is creating the appropriate overlapping graphics... But as I said - that sounds easier in this case then it really is...

I will have a look at your test tomorrow, but if you use copy and image too I guess it will come to the same slow result that I got until now...

Perheps I will try rendering on a OpenGL-Offscreen somehow (as my collegue suggested) but for now I don't really see how this might help...

Perhaps I can figure out some way to clip the trails effectively without reverting from splines to lines... if this would work, maybe I'll be allright...

But still - any other ideas or hints are welcome for sure...

Sven
Re: multiscreening (4 screens) on one machine...
Reply #3 - Jan 24th, 2008, 8:17am
 
Ok, after trying around a bit I found a way to do this really fast and smooth...

I'm using the PGraphicsOffscreenGL-approach I found somewhere on this site and adjusted the render-method to create 4 quads filling the screen and mapping the content to those quads so that the overlapping fits my needs. After some testing I even got the alpha-masking to work.

It works just fine and runs at >60fps...

I guess this thread can be closed now...


-------------------------------------------
void render(PGraphicsOffscreenGL pg)
 {
   start();
   
   gl.glUniform2fARB(offsetTex, 1.0 / pg.width, 1.0 / pg.height);
   gl.glUniform2fARB(destRes, width, height);  
 
   int w_h = off_screen_width/2;
   int h_h = off_screen_height/2;

   pgl.beginGL();
   gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);    

   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glPushMatrix();        
   gl.glLoadIdentity();
   gl.glOrtho(0.0, width, 0.0, height, -100.0, +100.0);
   gl.glMatrixMode(GL.GL_MODELVIEW);
   gl.glPushMatrix();        
   gl.glLoadIdentity();        
   gl.glViewport(0, 0, width, height);

   gl.glEnable(GL.GL_TEXTURE_2D);
   gl.glBindTexture(GL.GL_TEXTURE_2D, pg.getDrawTex());

   gl.glColor4f(1.0, 1.0, 1.0, 1.0);        
   
   gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(0.0, 0.0);
     gl.glVertex2f(0.0, 0.0);
     gl.glTexCoord2f(0.5, 0.0);
     gl.glVertex2f(w_h, 0.0);
     gl.glTexCoord2f(0.5, 0.5);
     gl.glVertex2f(w_h, h_h);
     gl.glTexCoord2f(0.0, 0.5);
     gl.glVertex2f(0.0, h_h);
   gl.glEnd();

   gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(ol_x_h, 0.0);
     gl.glVertex2f(w_h, 0.0);
     gl.glTexCoord2f(ol_x_f, 0.0);      
     gl.glVertex2f(off_screen_width, 0.0);
     gl.glTexCoord2f(ol_x_f, 0.5);
     gl.glVertex2f(off_screen_width, h_h);
     gl.glTexCoord2f(ol_x_h, 0.5);
     gl.glVertex2f(w_h, h_h);
   gl.glEnd();

   gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(0.0, ol_y_h);
     gl.glVertex2f(0.0, h_h);
     gl.glTexCoord2f(0.5, ol_y_h);
     gl.glVertex2f(w_h, h_h);
     gl.glTexCoord2f(0.5, ol_y_f);
     gl.glVertex2f(w_h, off_screen_height);
     gl.glTexCoord2f(0.0, ol_y_f);
     gl.glVertex2f(0.0, off_screen_height);
   gl.glEnd();

   gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(ol_x_h, ol_y_h);
     gl.glVertex2f(w_h, h_h);
     gl.glTexCoord2f(ol_x_f, ol_y_h);
     gl.glVertex2f(off_screen_width, h_h);
     gl.glTexCoord2f(ol_x_f, ol_y_f);
     gl.glVertex2f(off_screen_width, off_screen_height);
     gl.glTexCoord2f(ol_x_h, ol_y_f);
     gl.glVertex2f(w_h, off_screen_height);
   gl.glEnd();    

   gl.glEnable(GL.GL_BLEND);
   gl.glBlendFunc(GL.GL_ZERO, GL.GL_SRC_ALPHA);

   gl.glBindTexture(GL.GL_TEXTURE_2D, alphaTex[0]);
 
  gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(0.0, 0.0);
     gl.glVertex2f(0.0, 0.0);
     gl.glTexCoord2f(0.5, 0.0);
     gl.glVertex2f(w_h, 0.0);
     gl.glTexCoord2f(0.5, 0.5);
     gl.glVertex2f(w_h, h_h);
     gl.glTexCoord2f(0.0, 0.5);
     gl.glVertex2f(0.0, h_h);
   gl.glEnd();

   gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(0.5, 0.0);
     gl.glVertex2f(w_h, 0.0);
     gl.glTexCoord2f(1.0, 0.0);
     gl.glVertex2f(width, 0.0);
     gl.glTexCoord2f(1.0, 0.5);
     gl.glVertex2f(width, h_h);
     gl.glTexCoord2f(0.5, 0.5);
     gl.glVertex2f(w_h, h_h);
   gl.glEnd();

   gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(0.0, 0.5);
     gl.glVertex2f(0.0, h_h);
     gl.glTexCoord2f(0.5, 0.5);
     gl.glVertex2f(w_h, h_h);
     gl.glTexCoord2f(0.5, 1.0);
     gl.glVertex2f(w_h, height);
     gl.glTexCoord2f(0.0, 1.0);
     gl.glVertex2f(0.0, height);
   gl.glEnd();

   gl.glBegin(GL.GL_QUADS);
     gl.glTexCoord2f(0.5, 0.5);
     gl.glVertex2f(w_h, h_h);
     gl.glTexCoord2f(1.0, 0.5);
     gl.glVertex2f(width, h_h);
     gl.glTexCoord2f(1.0, 1.0);
     gl.glVertex2f(width, height);
     gl.glTexCoord2f(0.5, 1.0);
     gl.glVertex2f(w_h, height);
   gl.glEnd();

   gl.glDisable(GL.GL_BLEND);          
   gl.glActiveTexture(GL.GL_TEXTURE0);
   gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
   
   stop();    

   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glPopMatrix();
   gl.glMatrixMode(GL.GL_MODELVIEW);
   gl.glPopMatrix();  

   pgl.endGL();
 }
---------------------------------------------
Page Index Toggle Pages: 1