Today marks the first release of Overwatch Player Log. It’s a little utility program that allows you to record your favorite (or not!) players that you have met in Overwatch!
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.
static const glm::mat4 sk_IdentityMatrix;
TransformationMatrix & SetScale(const float p_ScaleX, const float p_ScaleY, const float p_ScaleZ);
/*! Rotate angles in degrees. */
TransformationMatrix & SetRotation(const float p_AngleX, const float p_AngleY, const float p_AngleZ);
TransformationMatrix & SetTranslation(const float p_PosX, const float p_PosY, const float p_PosZ);
/*! Return the raw pointer to the matrix. Evaluates final transformation matrix if it hasn't already. */
const GLfloat * const GetRawPtr(void);
const glm::mat4 & GetGLMMatrix(void);
/*! Evaluate the final transformation matrix if it's not done already. */
TransformationMatrix & Evaluate(void);
}; // MatrixPipeline 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:
const glm::mat4 TransformationMatrix::sk_IdentityMatrix(1);
TransformationMatrix & TransformationMatrix::SetScale(const float p_ScaleX, const float p_ScaleY, const float p_ScaleZ)
m_ScaleMatrix = glm::scale(p_ScaleX, p_ScaleY, p_ScaleZ); m_Evaluated = false; return *this;
TransformationMatrix & TransformationMatrix::SetRotation(const float p_AngleX, const float p_AngleY, const float p_AngleZ)
m_Evaluated = false;
m_RotationMatrix = glm::rotate(sk_IdentityMatrix, p_AngleX, glm::vec3(1, 0, 0));
m_RotationMatrix = glm::rotate(m_RotationMatrix, p_AngleY, glm::vec3(0, 1, 0));
m_RotationMatrix = glm::rotate(m_RotationMatrix, p_AngleZ, glm::vec3(0, 0, 1));
TransformationMatrix & TransformationMatrix::SetTranslation(const float p_PosX, const float p_PosY, const float p_PosZ)
m_TranslationMatrix = glm::translate(p_PosX, p_PosY, p_PosZ); m_Evaluated = false; return *this;
const GLfloat * const TransformationMatrix::GetRawPtr(void)
const glm::mat4 & TransformationMatrix::GetGLMMatrix(void)
TransformationMatrix & TransformationMatrix::Evaluate(void)
m_FinalMatrix = m_TranslationMatrix * m_RotationMatrix * m_ScaleMatrix;
m_Evaluated = true;
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.
It’s been 2 weeks since Uni started. As I am doing an Interactive Computer Graphics this semester, which uses OpenGL. I have therefore, started it.
Besides learning to draw the basic primitives and the usual rainbow colored triangles. Plus a little bit of shader programming. I’ve spent a lot of the time in the past 2 weeks just playing and experimenting with a couple of utility tool kits and graphics libraries for window creation and input handling. Namely Freeglut, GLFW, and SFML. Today, I will talk about my experience with them so far, and what not.
From a beginner point of view, getting started with learning how to setup a basic window and OpenGL context up was such a pain. Going from a C++ programmer to using libraries/API’s that are written in C also made me quite uncomfortable. To those who are a novice like me. Fear not, you will get used to it after a while. The hardest part is actually just getting the few concepts down. Specifically window and context initialization and the way OpenGL’s API is defined. This is not a tutorial, so I won’t go into the details, but I will provide a list of the online tutorials I’ve been using that are very good.
Freeglut is an API compatible clone of the now obsolete Glut. It is under active development, where as work on Glut halted back in 2005. All it does is providing means to create a window which an OpenGL context will be attached to. The reason I took a dip into Freeglut is because the Interactive Computer Graphics unit uses it (because the text book uses it…). It has been the de facto choice for tutorials and teaching materials, even though it should just die after the original project halted. now Just a quick rank: the lecturer seems like a nice guy, but he is just NOT lecturer materials. The textbook that he chose is also horrible. From what I’ve gathered, the same textbook has been used for the last couple years for this unit, which is sad. The text attempts to teach theories and concepts in computer graphics and tries to mix OpenGL into it.
The way Freeglut/Glut works is by providing a couple callbacks for different things while keeping completely control over it’s own main loop. This is good for making applications like interactive graphics render and model viewers, application which it was designed for developing. If you intend to develop applications such as games, that are much more interactive and resource intensive, then Freeglut is not for you. At first I wasn’t too sure why, but control over the main loop is very important.
To use Freeglut, you initialize the library and set your call backs, and then you begin Freeglut’s mainloop. At this point, Freeglut takes over control until it exits.
The next tool kit I tried is GLFW. It is a very minimal tool kit and does not do as much as what Freeglut give you, but it does give you control over your mainloop. Instead of entering Freeglut’s mainloop, you have something along the line of “pollevents()”, which it internally calls callbacks that can you set, just like Freeglut. GLFW and Freeglut are quite similar with their functions, in terms of initialization and configurating the window. I spent about a week on Freeglut. By the time I moved to GLFW, it wasn’t too hard picking it up.
What I did was I ended up wrapping the GLFW stuff into a RenderWindow class, and wrote a simple event queue and wrote custom callbacks to translate most of the call backs into my own events, which I then handled by polling my own event queue. I modeled it after SFML because I’ve been using it for a while now and the OOP aspect of it made it very elegant.
One thing that I do miss that Freeglut has and GLFW doesn’t is menu creation. Pop-up menus will be used extensively for this unit so I spent a lot of time investigating what alternative there is for GLFW besides writting my own. The problem is, there isn’t really any. I did managed to discover CEGUI, nui3, glui2 and AntTweakBar. The AntTweakBar library seems like the easiest to implement with the others looking quite complicated. I did not give any of them a try so I could be wrong. What bothered me is that they were GUI/widget tool kits and do not provide the ‘traditional’ menu.
Finally. I remember that SFML uses OpenGL internally. SFML (short for simple, fast, multi-media library). It’s popular for creating 2D games and applications. Bit of a rival to SDL. Best of all, it’s written in C++, and under active development. The library provides a lot to developers with 5 different modules. Providing classes for not just handling 2D graphics, but there are also classes for handling audio, network and other things. SFML allows you to use the OpenGL API directly, and it’s very simple to do some. What’s nice is that you can use it’s 2D graphics module along side of it. There are quite a few GUI libraries built for SFML but I havn’t look too deep into yet. The best thing yet is that I’ve been using SFML for the last couple dozen weeks on my 2D game engine project.
I spent the afternoon today and extended the engine enough to get some basic OpenGL primitive drawn. The engine is no where near completion. If I could use SFML for the interactive computer graphics unit then I will have the opportunity to develop and grow the engine along side the course project, instead of pausing work on my game project.
This blog has turned out to be a lot more formal and a bit more longer than I expected, but that’s cool. In closing, the libraries I mentioned today are not all there is out there. They are simply the ones that I’ve discovered and explored so far. There are many more out there that can be used for creating window and OpenGL context. The ones that I could think of on top of my head are Qt and SDL. I’ve used Qt before and it’s awesome for lots of things.
The next thing I will do is work a bit more on OpenGL with SFML for a bit more, and do so by extending my engine. I will also have to contatct my unit coordinator to accquire permission on developing on VS2012 with SFML on Windows (the project is meant to be done on a POSIX system with Freeglut). Lastly, I will continue learning OpenGL.
Stay tuned for the next log. Peace out!
(in order of most favored):
(no particular order):
With work already started on my first game project, I’ve came up with a name for my own “studio” and registered a new domain with new hosting. The game will be a remake of the old Stick Soldiers franchise, with new features coming later(more posts on this in the future). Stick Soldiers 2 was never completed, and Stick Soldiers 3 was also abandoned. I liked the game enough that I think I should try bringing it back.
The DDNS on my Synology NAS has been causing me a lot of grief lately so I’ve also moved my personal website along with my little brother Kevin’s little website onto the new domain. I will probably keep it around for site development and update testing.
There isn’t much content as for now, but stay tuned!
At last, links to the new and old sites: