Learning OpenGL. Log 3

This post is part of a series of logs of my journey in learning OpenGL (or as some say, modern OpenGL).

—————————————————————————————————————————————–

I’ve started an other log, dedicated for the engine project, so I won’t talk about it any more here unless it’s very cool or related.

Today I worked with the glm library a bit more and wrote a TransformationMatrix class.

A very simple class. The name is a bit deceiving. The entire class is actually compose of 4 glm::mat4 objects. 3 for the basic transformations, and the final one being the product of the other 3. The comments are a bit incomplete but you can probably tell what the member functions do already. There are 3 setter methods, for scaling, translation and rotation. There are also two getter methods for getting the final transformation matrix.

What interesting here is that, at the moment the final transformation matrix is only evaluated when it needs to be re-evaluated. Calling any of the setter methods will not trigger the evaluation, but they will m_Evaluated to false. When the getter methods are called. They will re-evaluate the final transformation matrix only if it’s been previous modified.

There are no methods such as TranslateFromCurrentPos or RotateFromCurrentAngle at the moment because I believed those should be implemented in a entity class which will compose one or multiple TransformationMatrix in the render component. This will allow me to implement higher level movement stuff on top while keeping the matrix class lightweight and encapsulated.

Here’s the cpp part of the class:

Of course. The class is incomplete. I will overload some operators for matrix multiplication and what not. At the moment I have to call “GetGLMMatrix()” to pass the matrix to my ShaderProgram class. I will need to add support for this new class into my shader code.

I will begin work on a camera class next, once I’m up to date with this week’s lab work.

Leave a Reply

Your email address will not be published. Required fields are marked *