How to use glOrtho() in OpenGL?

Have a look at this picture: Graphical Projections  The glOrtho command produces an “Oblique” projection that you see in the bottom row. No matter how far away vertexes are in the z direction, they will not recede into the distance. I use glOrtho every time I need to do 2D graphics in OpenGL (such as health bars, menus … Read more

Undefined reference to constructor

The error is generated by the linker because it can not see where the definition of the constructor is located. If you are using an IDE, you should add both .cpp files to the project so that they can be compiled together and the definition would be found by the linker. It not, then you … Read more

error: use of deleted function

The error message clearly says that the default constructor has been deleted implicitly. It even says why: the class contains a non-static, const variable, which would not be initialized by the default ctor. Since X::x is const, it must be initialized — but a default ctor wouldn’t normally initialize it (because it’s a POD type). Therefore, to get a … Read more

Error: expected type-specifier before ‘ClassName’

For future people struggling with a similar problem, the situation is that the compiler simply cannot find the type you are using (even if your Intelisense can find it). This can be caused in many ways: You forgot to #include the header that defines it. Your inclusion guards (#ifndef BLAH_H) are defective (your #ifndef BLAH_H doesn’t match your #define BALH_H due … Read more

Remove spaces from std::string in C++

The best thing to do is to use the algorithm remove_if and isspace: Now the algorithm itself can’t change the container(only modify the values), so it actually shuffles the values around and returns a pointer to where the end now should be. So we have to call string::erase to actually modify the length of the container: We … Read more

What does ‘const static’ mean in C and C++?

It has uses in both C and C++. As you guessed, the static part limits its scope to that compilation unit. It also provides for static initialization. const just tells the compiler to not let anybody modify it. This variable is either put in the data or bss segment depending on the architecture, and might be in memory marked read-only. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)