Understand Frustum parameters in Pangolin visualizer library

68 views Asked by At

I am rendering a camera frustum using the glDrawFrustum() method available in pangolin. This is the open source code here

In general, I am aware that the frustum parameters are frustum(left, right, bottom, top, near, far)

But pangolin has its function defined as below.

inline void glDrawFrustum( GLfloat u0, GLfloat v0, GLfloat fu, GLfloat fv, int w, int h, GLfloat scale )
{
    const GLfloat xl = scale * u0;
    const GLfloat xh = scale * (w*fu + u0);
    const GLfloat yl = scale * v0;
    const GLfloat yh = scale * (h*fv + v0);

    const GLfloat verts[] = {
        xl,yl,scale,  xh,yl,scale,
        xh,yh,scale,  xl,yh,scale,
        xl,yl,scale,  0,0,0,
        xh,yl,scale,  0,0,0,
        xl,yh,scale,  0,0,0,
        xh,yh,scale
    };

    glDrawVertices(11, verts, GL_LINE_STRIP, 3);
}

Question 1 - Do the parameters correspond to left, right, top, bottom, near and far ??

Question 2 - Here are my parameters for pangolin::glDrawFrustum

float left = -1.f;  // X axis related
float right = 1.f;
float bottom = -1.f;
float top = 1.f;   // Y axis related
float near = -1.f;
float far = 1.f;

pangolin::glDrawFrustum(left, right, top, bottom, near, far);

Sqewed image

I get a skewed image. How do I get a symmetric frustum. I assume I am providing symmetric parameters in my code.

0

There are 0 answers