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 › the best way to add a 2D text interface over GL
Pages: 1 2 
the best way to add a 2D text interface over GL? (Read 6191 times)
Re: the best way to add a 2D text interface over G
Reply #15 - May 14th, 2005, 6:39pm
 
fry wrote on May 14th, 2005, 4:51pm:
whups, sorry.. not thinking. you're right, you shouldn't call camera() more than once per frame. it's too messy to support that, so we're not.


Oh.. Well I seem to be getting away with calling it twice quite well so far...
Re: the best way to add a 2D text interface over G
Reply #16 - May 14th, 2005, 7:48pm
 
So, after a lot of sweat I figured out that there are different behaviors for P3D and OpenGL. I have versions using the OCD library, and just using processing, the the multiple calls of camera or perspective or won't work or will be inconsistent when using openGL.

To this point, no 2D interface overlay for me...  Sad
Re: the best way to add a 2D text interface over G
Reply #17 - May 15th, 2005, 12:09am
 
That's a shame that you can't find a consistent way of doing it for your sketch.

I'm probably lucky that I foudn a way that works, and I only intend to have it working with P3D, in a specific situation.
Re: the best way to add a 2D text interface over G
Reply #18 - May 15th, 2005, 2:28am
 
sure it was not intended to be used like this, but it works (only P3D, OPENGL is too sensible):

Code:

float fov;
float cameraZ;

void setup()
{
size(200, 200, P3D);
noFill();
fov = PI/3.0;
cameraZ = (height/2.0) / tan(PI * fov / 360.0);
}

PGraphics3 pg;

void draw()
{
pg = new PGraphics3( width, height, null );
pg.defaults();

pg.background(255);
pg.perspective( fov*rot, float(width)/float(height), cameraZ/10.0, cameraZ*10.0);
pg.translate(width/2, height/2, -300);
pg.rotateX(-PI*0.18*rot);
pg.rotateY(PI*0.333*rot);
pg.fill(122);
pg.box(100);

rot += 0.02;
rot %= TWO_PI;

pg.translate( 100,100,-100 );
pg.rotateZ( PI * 0.2 );
pg.rotateX( PI * 0.2 );
pg.fill( 255 );
pg.box( 100 );

pg.translate( 10, 10, 100 );
pg.fill( #FF0000 );
pg.box( 20 );

image( pg , 0,0 );

fill( 255 );
rect( bb,bb,20,20 );
rect( bb-40,bb,20,20 );
rect( bb,bb-40,20,20 );
bb += 3;
bb %= width;
}

float rot = 0.0;
int bb = 0;


F
Re: the best way to add a 2D text interface over G
Reply #19 - May 15th, 2005, 5:08am
 
hey Florian

actually you did something that I was trying to; I was trying to create the 2D overlay in a buffer and then appling it over everything, but it wasn't working... I'll leave this by now, although It would be great to see a definite solution for an overlay in opengl...
Re: the best way to add a 2D text interface over G
Reply #20 - May 15th, 2005, 4:17pm
 
well .. it's only working if you call defaults() on it after creation. ben mentioned somewhere it's gonna change in the future, so consider this a temporary hack ...

F
Pages: 1 2