B_old
03-17-2003, 05:47 AM
Hello!
I read the markmorley tutorial on a viewfrustum with OGL. Now I have the desire to build any frustum with a similiar method but have failed.
EDIT:
In case you wonder, I want to use this to cull a spotlight (no, I don't want to use a cone).
//Radius is how far the frustum goes
//Angle is the FOV, kind of
void cFrustum::Update(cVector3 Pos, cVector3 Dir, float Radius, float Angle)
{
float proj[16];
float modl[16];
float clip[16];
float t;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPerspective(Angle, (float)Config.ScreenWidth / Config.ScreenHeight, 0.0f, Radius);
gluLookAt(Pos.X, Pos.Y, Pos.Z,
Dir.X, Dir.Y, Dir.Z,
0, 1, 0);
glGetFloatv(GL_PROJECTION_MATRIX, proj);
glGetFloatv(GL_MODELVIEW_MATRIX, modl);
glPopMatrix();
//and so on as markmorley describes
This gives ugly artifacts when I call it and does not really work out anyway.
Maybe should I use gluProjection instead of gluPerspective? I do not know though and am confused.
Some code snippet would be great, any help is appreciated. Thanks!
[This message has been edited by B_old (edited 03-17-2003).]
I read the markmorley tutorial on a viewfrustum with OGL. Now I have the desire to build any frustum with a similiar method but have failed.
EDIT:
In case you wonder, I want to use this to cull a spotlight (no, I don't want to use a cone).
//Radius is how far the frustum goes
//Angle is the FOV, kind of
void cFrustum::Update(cVector3 Pos, cVector3 Dir, float Radius, float Angle)
{
float proj[16];
float modl[16];
float clip[16];
float t;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPerspective(Angle, (float)Config.ScreenWidth / Config.ScreenHeight, 0.0f, Radius);
gluLookAt(Pos.X, Pos.Y, Pos.Z,
Dir.X, Dir.Y, Dir.Z,
0, 1, 0);
glGetFloatv(GL_PROJECTION_MATRIX, proj);
glGetFloatv(GL_MODELVIEW_MATRIX, modl);
glPopMatrix();
//and so on as markmorley describes
This gives ugly artifacts when I call it and does not really work out anyway.
Maybe should I use gluProjection instead of gluPerspective? I do not know though and am confused.
Some code snippet would be great, any help is appreciated. Thanks!
[This message has been edited by B_old (edited 03-17-2003).]