Understanding glm::lookAt()

The up vector is basically a vector defining your world’s “upwards” direction. In almost all normal cases, this will be the vector (0, 1, 0) i.e. towards positive Y. eye is the position of the camera’s viewpoint, and center is where you are looking at (a position). If you want to use a direction vector D instead of a center position, you can simply use eye … 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

Best C/C++ Network Library

Aggregated List of Libraries Boost.Asio is really good. Asio is also available as a stand-alone library. ACE is also good, a bit more mature and has a couple of books to support it. C++ Network Library POCO Qt Raknet ZeroMQ (C++) nanomsg (C Library) nng (C Library) Berkeley Sockets libevent Apache APR yield Winsock2(Windows only) wvstreams zeroc libcurl libuv (Cross-platform C library) SFML’s Network Module C++ … Read more

timestamp of time(0) at multiple places in a C++ program

The resolution of the time() function isn’t fine grained enough to result in different values to make a different result for each call you make, i.e. the CPU is faster. You might try to insert std::this_thread::sleep_for calls to check what timing resolution fits for your needs with the hardware and OS you have at hand.

Get Unix timestamp with C++

C++20 introduced a guarantee that time_since_epoch is relative to the UNIX epoch, and cppreference.com gives an example that I’ve distilled to the relevant code, and changed to units of seconds rather than hours: Using C++17 or earlier, time() is the simplest function – seconds since Epoch, which for Linux and UNIX at least would be the UNIX epoch. Linux manpage here. The … Read more

error MSB3073: How do I fix this?

For anyone else that comes across this question my problem was that the target directory contained spaces i.e. So for me the solution was to wrap $(TargetDir) in double quotes i.e.

Run C++ in command prompt – Windows

It depends on what compiler you’re using. For example, if you are using Visual C++ .NET 2010 Express, run Visual C++ 2010 Express Command Prompt from the start menu, and you can simply compile and run the code. or from the regular command line, you can run vcvars32.bat first to set up the environment. Alternatively search for setvcvars.cmd (part … Read more

class not declared in scope – even though .h was included

The common circular include problem occurs with:a.h b.h If some cpp includes “a.h” you might get away with it (if b.h didn’t really need a.h). But if that cpp instead includes b.h then b.h includes a.h BEFORE declaring things needed by a.h. Then a.h tries to include b.h but the include guard blocks that, so the compiler … Read more

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