Summer Adventure 2018: Prelude To OpenGL 4.5 & CMake

In Semester 2 2016 (which for us Australians is from August to November) I took an undergraduate course in computer graphics at the University of New South Wales (UNSW), Sydney. I've always been fascinated by video games, which necessarily involve computer graphics (why else is 'video' in the phrase?), and so to me this felt like an obvious course to take. In the course we learnt about various concepts in CG, and to punctuate what we were learning we had two assignments in OpenGL. The rub however was that we were using old JOGL (Java bindings for OpenGL) bindings and so the version of OpenGL was also old - core version 3.x (I don't remember exactly which version). Modern OpenGL (as of writing) is at 4.6 so clearly if I want to carry over that knowledge to the future I'm going to need to get used to the modern library. Personally, my language of choice is C++ because despite its oft times crazy, overwhelming (to those uninitiated) syntax it is fast, and also offers as good as abstraction as languages like Java, and probably Python. Python makes me feel like an idiot when I use it because everything is so far from the computer it's like I'm not sure how efficient the code I write is. That aside, C++ is my sweetheart.
   In JOGL alot was done behind the scenes and one could get into writing rendering code almost immediately. OpenGL for C++ is not at all like that; C++ has no standard windowing toolkit (libraries like Qt are used by they aren't always standards compliant), and the OpenGL functionality is loaded, at runtime, from whatever graphics driver is being used. To complicate matters further, there is no canonical tutorial on how to get those setup AND there is more than one windowing toolkit and extension loader for OpenGL, some defunct, others apparently not being flexible enough. This was my first hurdle to overcome - how the hell to set things up.
   At UNSW there was never a course about so-called 'boilerplate' setup such as an in-depth look into a build system, or how production code is written, packaged, and exported. There was one course, COMP2041, called 'Software Design & Construction' but it was more a joke than a practical intro into these matters. So I began to scour various wikis and online tutorials (which by the way are all outdated) about how to set these things up.
   I eventually settled on using GLFW as the window toolkit mostly because the website documentation is readable. And since GLFW recommended using GLAD as the extension loader, I settled on that too for my linux box. Now GLFW source is built using CMake. I had heard of Cmake before but never actually touched it. It was at this point I decided in a joint project I would dabble in using CMake as a proper build system, and in learning the modern OpenGL. Or at least as modern as I can get it, the latest version of the OpenGL Super Bible uses OpenGL 4.5, so that's what Im going for. My IDE on Linux for C++ is CLion (because educational license ;) ) and on Windows I use Visual Studio (like everyone...). Upon starting my new project I was face-to-face with my first CMakeLists.txt. And so the adventure down the rabbit hole began.

Comments

Popular Posts