Class tools
We will use the following tools in class. Don't install them yet, but you can check out the links if you want more information.
- C++
High-performance, low level language. - CMake
Cross platform build toolkit. - OpenGL
Cross platform library for graphics rendering, mostly used to access GPU hardware. - SFML
Cross platform library for OpenGL setup, events, and more. - GLM
Helper library to make using OpenGL easier.
C++
C++ is a very powerful and complex language and inherits all the good and bad of C. It is often used in graphics development, so we will be using it. You will need to learn C++ on your own, but get help if you can't figure something out. Some important points:
-
Classes declared with the
class
keyword. Note the semicolon!class MyTestClass { };
-
Encapsulation is similar to Java:
class MyTestClass { private: ... public: ... };
-
Self reference through pointer to 'this':
class MyTestClass { private: int a; public: MyTestClass() { this->a = 5; } };
-
Inheritance looks like this:
class MyTestClass : public OtherClass { private: ... public: ... };
-
Method overrides for polymorphism require the 'virtual' keyword on parent and child:
class OtherClass { public: virtual int getFive() { return 5; } }; class MyTestClass : public OtherClass { public: virtual int getFive() { return 6; } };
-
Supports references with & symbol
-
Generic programming by metaprogramming
template <int dimension> class GenVector { public: static const int dim = dimension; float c[dimension]; GenVector() { for(int i=0; i<dimension; i++) c[i] = 0; } } GenVector<3> threeVec; GenVector<4> fourVec;
-
Often comes with a Standard Template Library of algorithms and collections (we will use this)
#include <vector> std::vector<int> integers; for(int i=0; i<10; i++) integers.push_back( i ); for(int i=0; i<integers.size(); i++) printf("%d ", integers[i]);
-
Objects can have constructors and destructors