I’m sure there’s not just 1 answer to this but, do game engines actually change the vectors in memory, or use gltransformations? Because pushing and popping the matrix all the time seems inefficient, but if you keep modifying the verticies you cant make use of display lists. So I’m wondering how it’s done in general. Thanks
Share
Depends on your goals/objects.
Objects that never change are moved by setting matrices (it is possible to do that using glRotatef/glTranslatef and such too). It is certainly faster than transforming object vertex by vertex. Object is stored in DisplayList, VertexArray or in VBO. You CAN send entire object every time using glVertex* command, but if object never changes, there is no need for that.
Characters (skinned/rigged) are transformed using multiple matrices, which is normally handled by vertex shader. You can do it on CPU, if you want, but unless you have a VERY advanced rigging/skinning engine, there is no need for that.
Calculations that cannot be completely performed on Videocard, are performed on CPU. Normally it is particle systems, cloth and procedural geometry, sometimes shadows (for shadow volume calculation using stencil shadows). Objects like this are normally stored in memory, at least partially, and transformations performed on CPU. This is strictly hardware-dependent. Depending on the power of videocard and OpenGL version, it is possible to perform some or all of those tasks on videocard (without involving CPU), but not always. For example, normally it isn’t possible to build shadow volume for procedural geometry (i.e. topology varies each frame as well as vertex positions) on GPU. However, there are tricks to avoid it, and situation might change with future versions.