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

03-12-2011, 01: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.

03-12-2011, 07: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).

03-14-2011, 11:25 AM
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);

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


and in Initialize i have used

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);