# How to set the positon of the projection plane in OpenGL?

Dear everyone,

Who knows how to set the position of the projection plane in OpenGL, or, is there a way to set focus value when using OpenGL?

I am how working on an algorithm, which needs this value. But I don’t know how to do this I hope who knows this could tell me. Thank you very much!

Originally posted by hawaii:
[b] Dear everyone,

Who knows how to set the position of the projection plane in OpenGL, or, is there a way to set focus value when using OpenGL?

I am how working on an algorithm, which needs this value. But I don’t know how to do this I hope who knows this could tell me. Thank you very much!

[/b]
The projection matrix does not have a position. The position of the observer comes with the modelview matrix.

There is no such thing as a focus in standard OpenGL, because the camera is treated as an infinitely small point. Like a pinhole camera. If you want a point of focus, you should have a look at the “depth of field” effect, which simulates a real camera lens.

god knows what you’re asking for, but in case you’re talking about specifying a frustum that has a different projection plane to the near plane, then here’s some code to do it:-

``````void createFrustum(double left, double right, double bottom, double top, double nearDist, double farDist, double projDist)
{
double m[16];

double x, y, a, b, c, d;
double width = right-left;
double height = top-bottom;
double depth = farDist-nearDist;

x = (2.0*projDist) / width;
y = (2.0*projDist) / height;
a = (right+left) / width;
b = (top+bottom) / height;
c = -(farDist+nearDist) / depth;
d = -(2.0*farDist*nearDist) / depth;

#define M(A,B) m[(B)*4+(A)]
M(0,0) = x;	M(0,1) = 0.0;		M(0,2) = a;		M(0,3) = 0.0;
M(1,0) = 0.0;	M(1,1) = y;		M(1,2) = b;		M(1,3) = 0.0;
M(2,0) = 0.0;	M(2,1) = 0.0;		M(2,2) = c;		M(2,3) = d;
M(3,0) = 0.0;	M(3,1) = 0.0;		M(3,2) = -1.0;		M(3,3) = 0.0;
#undef M

glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);
}
``````

holy cow! this is the first time that i see you post code- what’s wrong, knackered?

I’ve posted code before…not very frequently, but a handful of times.
I’m procrastinating on a problem of my own, so I’ve done all the hoovering, all the washing, re-arranged my front room, and pasted code onto a forum. What else can I do to distract me from the real issue at hand???

hm…hoovering, washing, rearranging the front room…you’re way ahead of myself.

by the way, what’s the real issue? that we all die someday?

re-factoring some code written while doing a balancing act.

how many lines?

too many. way too many.

anything i can do to take some of the pain from you?

nobody can help me now…I’m on my own in this hell.

on your own, maybe, but not alone.

you are actually beginning to scare me now, rigidbody.
even your name is taking on a whole new meaning.

in which sense?

the biblical sense?

ehm- no, not rigid in a religious way. i do not pay church taxes anymore, and i haven’t started my own religion either.

phew, that’s a relief.

Thank you very much for your kindly replies, now I know how to deal with the problem from your posts.

Thanks again:)

Woah woah woah there…
How has any of this helped?

um excuse me but didnt your mum tell u its rude to butt into other ppls conversations