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 › two windows / this not about spanning
Page Index Toggle Pages: 1
two windows / this not about spanning (Read 2644 times)
two windows / this not about spanning
Jun 8th, 2007, 5:54pm
 
hi

i need to have two windows for two different opengl 3d scenes (i need 2 windows rather than spanning across two different monitor because each scene will have completely different perspective, objects, lighting etc.).

what is the best way to do this?

i found here:

http://dev.processing.org/reference/core/javadoc/processing/core/PApplet.html   (under "multiple displays)

that it says

"It's also not that tough to do by hand w/ some Java code."

ermm... how might i go about starting?

thanks!
Re: two windows / this not about spanning
Reply #1 - Jun 9th, 2007, 4:13am
 
the way i see it, is to create a window with the size of both screens. but i am no java pro.
Re: two windows / this not about spanning
Reply #2 - Jun 9th, 2007, 10:46am
 
You can actually still do what you want with one spanned display using gl.glViewport(startx,starty,width,height);
That sets all the drawing to just one area, so you can call that command for the left side, covering the whole screen, do all your drawing, then call it again with the position of the right screen, and do that one.

e.g. (assuming 2 1024*768 displays)

Code:
import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;

GL gl;
GLU glu;
PGraphicsOpenGL pgl;
void setup()
{
size(2048,768,OPENGL);
pgl=((PGraphicsOpenGL)g);
gl=pgl.gl;
glu=pgl.glu;
}

void draw()
{
background(0);
//required....
pgl.beginGL();
gl.glViewport(0,0,1024,768);
pgl.endGL();
perspective(PI/3.0,1024.0/768.0,0.001,10000);
camera(0,0,-300,0,0,0,0,-1,0);
//end of required.
noStroke();
sphere(50);

pgl.beginGL();
gl.glViewport(1024,0,1024,768);
pgl.endGL();
perspective(PI/3.0,1024.0/768.0,0.001,10000);
camera(0,0,-300,0,0,0,0,-1,0);
noStroke();
box(50);
}


Note some commands still affect everything e.g. background();
Re: two windows / this not about spanning
Reply #3 - Jun 9th, 2007, 12:53pm
 
that's perfect, thanks so much for the demo code!
i had no idea about 'viewports'... i need to get deeper into opengl but finding it a bit daunting. for others who feel the same way, after reading john's message above, i found this: http://today.java.net/pub/a/today/2003/09/11/jogl2d.html
which seems like a good way of easing in...
Re: two windows / this not about spanning
Reply #4 - Jun 10th, 2007, 2:27pm
 
also make sure you use:
Code:

pgl= (PGraphicsOpenGL) g;
gl = pgl.beginGL();

rather than setting the gl object once inside setup.. there are some instances where the gl object may change.
Re: two windows / this not about spanning
Reply #5 - Jun 11th, 2007, 8:16pm
 
ah yes, good to know, thank you.
Page Index Toggle Pages: 1