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 › converting p3d perspective calls to opengl
Page Index Toggle Pages: 1
converting p3d perspective calls to opengl (Read 1065 times)
converting p3d perspective calls to opengl
Feb 6th, 2010, 2:40am
 
how would i convert thse opengl calls to p3d?

gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();

glu.gluPerspective(1f, 1f, .001f, 10000f);

gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();

i thought it would've been

perspective(1f, 1f, .001f, 10000f);

but that's not working.
Re: converting p3d perspective calls to opengl
Reply #1 - Feb 6th, 2010, 7:29am
 
processing works with radians, opengl works with degrees

perspective( radians(1f), 1f, .001f, 10000f );
Re: converting p3d perspective calls to opengl
Reply #2 - Feb 6th, 2010, 8:27am
 
V is right about the radians and the parameters for both glPerspective and Processing's perspective(0 are the same.

The first parameter represents the vertical field of view but in

Code:
glu.gluPerspective(1f, 1f, .001f, 10000f); 


you have it as 10 where a value of 600 is more likely.

The second is the aspect ratio of the window and is calculated as width/height so 1f is fine for a square window.

the last 2 values are the near and far Z values.

I suspect that you need to increase the Y fov.

You should also be wary about using P3D as there is a bug in the clipping routine which means you can get grossly distorted rendering especially if there are objects to behind the view point.
Re: converting p3d perspective calls to opengl
Reply #3 - Feb 6th, 2010, 9:44am
 
thanks! thats a big different. and yes ive been finding some bugs in doing opengl in processing and vice versa so ive been making two drawing modes for all the draw calls ive been making so i can change between p3d and opengl depending on what im doing...
Re: converting p3d perspective calls to opengl
Reply #4 - Feb 6th, 2010, 10:11am
 
also how would i convert these opengl rotation calls to p3d?

gl.glRotatef(-_phix, 1, 0, 0);
gl.glRotatef(-_phiy, 0, 1, 0);
gl.glRotatef(-_phiz, 0, 0, 1);

i thought it would've been

//rotate(float angle, float vx, float vy, float vz)

parent.rotateX(PApplet.radians(-_phix),TWO_PI, 0, 0);
parent.rotateY(PApplet.radians(-_phiy), 0,TWO_PI, 0);
parent.rotateZ(PApplet.radians(-_phiz), 0, 0,TWO_PI);

or

rotateX(radians(-_phix));
rotateY(radians(-_phiy));
rotateZ(radians(-_phiz));

but neither are working...
Page Index Toggle Pages: 1