You might want to take a look at this question that asks about converting from glReadPixelsto cv::Mat, which is exactly the same problem when used glGetTexImageinstead glReadPixels.
My answer to this question explains how to directly read texture data into the repository cv::Matwith all possible traps (e.g. filling, color sorting, ...).
source
share