OpenGL - Why was the matrix stack removed and what are users now using?

I read OpenGL Superbible Fifth Edition, and they discuss the use of stacks through their own class. All of this is great, but they mention that matrix stacks were obsolete. Why are they obsolete and what do people use instead?

+6
source share
4 answers

Matrix Stack (and other matrix functions) are deprecated only in the main profile. In the Compatibility profile, you can still use them.

From my point of view, it was deleted, because most engines / frameworks have a user-defined math code and a unified style shader for sending matrices to shaders.

Although for simple programs / tutorials it is very inconvenient to use and search for something else.

I suggest using:

+2
source

Reason (s) are political, not technical, and date back to the early 2000s.

OpenGL 3 was the first version to break compatibility. Designers wanted to create an API for experienced users, programmers, and high-performance visualization coders who knew everything about shaders and wrote their own matrix code. The goal was that the OpenGL 3 API should exactly match the actual hardware. (Even in OpenGL 1/2, the matrix stack was usually implemented on the processor side, not on the GPU.)

From the point of view of the game engine programmer, this was better. And hey, if you need to develop a new game engine every couple of years anyway, what's the big deal to throw away the old code?

The result of this design process is the OpenGL 3/4 kernel profile.

As soon as the “new generation” of OpenGL was announced, all the not very experienced coders at universities and companies realized that they would be screwed. These are people (like me) who teach 3D graphics or write useful programs for research or design. We do not need more advanced lighting than the usual external diffuse-mirror. We often have to mix code from different sources together, and it’s easy if everyone uses the same matrices, lighting and texturing rules as those supplied by OpenGL 2.

In addition, I have heard, but cannot confirm, that the large CAD / CAM companies realized that they too would be screwed. Throwing out two million lines of code from ten years of development is not an option when you pay (and pay well: compare prices for Quadro and GeForce users or FireGL versus Radeon).

Thus, both NVIDIA and ATI said they would support the old API as much as they could.

The result of this pressure is compatibility profiles. And now, OpenGL ARB realized that although they want everyone to switch to the main profile, this just won't happen: read the extension specification for tessellation shaders in OpenGL 4, and he mentions that GL_PATCHES will work with glBegin.

+9
source

Why are they out of date

Because no one used it in real OpenGL programs. Take physical modeling, for example: you would have all the placement of objects that would be stored in the physical system as a 4 × 4 matrix anyway. That way you will just use it. The same applies to systems for determining visible objects and animations. All you need is to implement matrix math anyway, so having this in OpenGL is pretty redundant, since most of the time the existing matrices just fit in glLoadMatrix .

and what do people use instead?

What they used before: their animation systems, physical simulators, scene graphics, etc.

+2
source

Well, the first and main reason for me is that with the advent of programmable shaders (mandatory after the third version of opengl) all variables, such as GL_PROJECTION and GL_MODELVIEW, which were automatically transferred to the shaders, are removed from the shaders, so the user must define his own matrix to use it in the shader. Since you need to send the matrix manually using Uniform functions, you no longer need fixed variables.

+1
source

Source: https://habr.com/ru/post/920655/


All Articles