1 of 1 people found this helpful
What is the size of your texture?
> The statement where I check if the format is R16F, and if so, add 1 extra pixel in both dimensions is required for glGetTexImage to not crash.
I am not sure what you mean by crash but I believe you see a buffer write out of bounds.
What is your GL_PACK_ALIGNMENT?
The problem could be answered in this stackoverflow post: https://stackoverflow.com/a/26048033
Basically, if you did not change GL_PACK_ALIGNMENT it is set to 4 bytes whereas R16F is only 2 byte aligned.
For an odd number of pixels per scanline (width) this means the end of the scanline is unaligned and needs additional padding which you are doing via adding one pixel.
In theory it should be sufficient to add 1 to width when it is odd to fix the problem.
Sorry for being vague with the error, but you were right by assuming it was a buffer write which was out of bounds that caused it. Just calculating a valid alignment (or setting it to 1) solved the issue.