The relationship between OpenGL's Glulookat and Glortho

Source: Internet
Author: User

The relationship between OpenGL's Glulookat and Glortho

Never understood the relationship between Glulookat () and Glortho ():
Glulookat () is an observation transformation, and Glortho () is an orthographic projection.
Gllookat () is the location of the camera, and Glortho () is the current visual space set to the positive projection space.
Glulookat () Action Modelview Matrix, Glortho () Action projection matrix.

Sometimes the graphics can not be seen, and sometimes can be seen, then what is their connection? We look down:

First look at the definitions of these two functions:
void Glortho        ( gldouble left,
  Gldouble right,
    gldouble bottom,
    gldouble top,
    gldouble near,
    gldouble far);

void Glulookat (gldouble eyex, gldouble eyey, gldouble Eyez,
gldouble CenterX, gldouble centery, gldouble Centerz,
gldouble upx, gldouble upy, gldouble Upz);

code example:

Glortho (-1,1,-1,1,-3,3); Glulookat (0,0,2.9,0,0,0,0,1,0); glcolor3f (1.0,0.0,0.0); Glviewport (0,0, -, -); Glbegin (Gl_lines); glvertex3f (-1.0,0,-0.1); glvertex3f (1.0,0,-0.1); glvertex3f (0.0, -1.0,-0.1); glvertex3f (0.0,1.0,-0.1); Glend ();

The camera range is set using the Glulookat function, but its field of view is near and far in the Glortho. As the above program is near (2.9+3,2.9-3) this range, so-0.1 just grazing, these two lines can also be seen.

Also, if your graphic is in the back of the camera, it is within the range of the <5.9 (both horizons are open intervals), or you can see the graphic.

So for logical correspondence, we should write both near and far as positive, and this positive direction refers to the distance from the camera pointing to the negative axis direction.

The relationship between OpenGL's Glulookat and Glortho

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.