PDA

View Full Version : How can I get relation between pixels and gl.gltra



somnath
03-12-2011, 02:40 AM
hello sir
How can I get relation between pixels and gl.gltranslatef(floatx,y,z)?

what is the relation of viewer position ,glFrustum and maximum x and y co-ordinate .

plz reply me ...i m doing my project using glFrustum.

ravage
03-12-2011, 08:49 AM
if its supposed to be 2d I would use glOrtho instead of glFrustum for your projection matrix and make it match the window size something like glOrtho(0,width,height,0,0,1). That way when you use gltranslate the range to stay in the window would be (x: [0,width]),(y: [0,height]), and (z: [0,1] you can use this for depth or increase the number and treat as layer value).

somnath
03-14-2011, 12:25 PM
thanks for ur reply sir

i m using the following

In my reshape function

void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

if (w <= h)
glOrtho(-4.0, 4.0, -4.0 * (GLfloat) h / (GLfloat) w,
4.0 * (GLfloat) h / (GLfloat) w, -10.0, 10.0);
else
glOrtho(-4.0 * (GLfloat) w / (GLfloat) h,
4.0 * (GLfloat) w / (GLfloat) h, -4.0, 4.0, -10.0, 10.0);

glMatrixMode(GL_MODELVIEW);
}



and in Initialize i have used
glOrtho(0,width,height,0,0,1);


and in main i have used

glutInitWindowSize(width = 800, height = 500);


then what is the range of x ,y ,z
plz reply me

i have used glTranslatef(4.0,4.0,0.0);