read buffer crashes in separate thread (nvidia)

Now here is something weird. If am reading the buffer (either front or back) using glReadPixels in a main thread everything is OK. If I read the buffer in a separate thread, it crashes immediately at this function. An older NVidia driver 4191 did not crash, but only newer (from 4496 onwards) crash. Is this an NVidia problem? Or should reading buffer only be done in the main thread program? Really weird…


A gl context can only be current to one thread.
Why are you doing that anyway? Read pixels will block, there’s no way around that.

I think he believes that he can ReadPixels in one thread, and keep rendering in another thread.

Alas, that’s not true. A context can only be current in a single thread at a time, and another thread trying to make the context current will (typically) block until it can make the context current, so the first thread has to first give up the context.

If you want asynchronous pixel reading, NVIDIA has a current extension called NV_pixel_data_range (or something very similar).