I'm trying to save the output of my rendering to file. I'm already using FreeImage as a dependency so I'd like to continue using it. I'm using glReadPixels
to read the RGB values from the buffer. These values were entered into the buffer as GLubytes, so I figure I need to read them as such. However, when I run the following code snippet, the FreeImage_ConvertFromRawBits
call seg faults and I don't understand why. I've consulted the docs, and it seems that I'm doing everything correctly. Has anyone else run into this issue?
GLubyte pixels[3*_winWidth*_winHeight];
glReadPixels(0, 0, _winWidth, _winHeight, GL_RGB, GL_UNSIGNED_BYTE, pixels);
FIBITMAP *bitmap = FreeImage_ConvertFromRawBits(pixels, _winWidth,
_winHeight, 3 *_winWidth, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK,
FI_RGBA_BLUE_MASK, false);