What does this variable do? For example, if I set it to 4, what does it mean?
GLFW_SAMPLES used to enable multisampling. So glfwWindowHint(GLFW_SAMPLES, 4) is a way to incorporate 4x MSAA into your application.
4x MSAA means that each pixel of the window buffer consists of 4 sub-samples, which means that each pixel consists of 4 pixels, so to speak. Thus, a buffer of 200x100 pixels will be 800x400 pixels.
If you need to create an additional framebuffer, which is 4 times the screen. Then, using the filter as a texture filter with GL_LINEAR as the filter, basically will achieve the same result. Note that this applies only to 4x MSAA, since GL_LINEAR only accepts 4 samples closest to the pixel in question.
When it comes to anti-aliasing, using MSAA is a really effective, but expensive solution. If you want to get a very clean and beautiful result, then this is definitely the way to go. The 4x MSAA is usually chosen as a good balance between quality and performance.
A cheaper alternative in terms of performance is to use FXAA . This is done as a post-processing step and is usually provided free of charge. The difference is that the MSAA displays a larger size and reduces the size to the desired size without losing any quality. Where, like FXAA, it simply averages the pixels as it is, basically masking the image. FXAA usually gives a really decent result.
Also, your driver will most likely enable it by default. But if it does not use, then use glEnable(GL_MULTISAMPLE) .
Finally, if you have not already done so, I highly recommend reading the LearnOpenGL Anti-Aliasing tutorial. This provides a truly detailed explanation of all this.