You can either do this by hand and by opening the NVIDIA X Server Settings window. It’s the second from above “X Server Display Configuration” and there you click on “Advanced…”. It’s then at the bottom and its called “Force Composition Pipeline”, which you have to enable. You might also want to try the full version of it if the first one doesn’t already do it.
You can also save it and merge it with your existing xorg.conf where it will simply add the following to it:
Option Section "Screen"
...
"metamodes" "nvidia-auto-select +0+0 {ForceCompositionPipeline=On}"
...
EndSection
It will make the OpenGL driver comply better with your window compositor as these often add their own little magic on top of everything. It also fixes window tearing for video players such as MPV that also use OpenGL.