Do I understand what
GLORTHO can recalculate the coordinates?
I want to disassemble this part of the code:
glviewport (0,0, screenwidth, screenHeight); GlMatrixMode (GL_Projection); glloadidentity (); Glortho (0, ScreenWidth, 0, ScreenHeight, 0, 1); glmatrixmode (GL_Modelview);
After this code has become pixel values (
Windowheight ). But this is not convenient for working with 3D so? Probably more suitable for working with 2D?
Answer 1, Authority 100%
When the vertices are in the space of the species, they will have three spatial coordinates. But your screen is flat, two-dimensional, and you can not take and draw a three-dimensional top on this screen – you need to do this three-dimensional vertex on the plane.
We can make it very different ways. The most commonly used promising and orthographic projection.
Imagine rails. They lie parallel to each other. But when they are far away, then it seems to us that they intersect. That is, objects that are far seem to us less. This is a promising projection.
orthographic projection works otherwise – it displays each point of three-dimensional space perpendicular to the plane. In a particular case, the third coordinate is not taken into account and simply take the coordinates of
Perspective projection is more suitable for three-dimensional graphics, computer games, and so on, because we see in real life. Orthographic projection is most often used in various CAD systems, when drawing, in engineering graphics …
So the function
glortho just asks the matrix of the orthographic projection. That is, you demand from OpenGL so that your vertices from the view space are projected to the plane using an orthographic projection.
† by the way, you use the old OpenGL version. In new versions in the Core Profile, the projection matrix must be set independently.
is a legacy. https://www.khronos.org/opengl/wiki/legacy_opengl
Need this feature so that the old programs continue to work.