Hello,
I would like to get a simple screenshot of OpenGL output via glReadPixels and FreeImage.
The problem is that currently I get a messed up Black and White copy of what I am rendering. What am I doing wrong?
Consider the following example that I am using from here: c++ - How to take screenshot in OpenGL - Stack Overflow
And here is the code I am using from that example:
GLubyte* outPixels = new GLubyte[3 * CurrentWindowWidth * CurrentWindowHeight];
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glReadPixels(0, 0, CurrentWindowWidth, CurrentWindowHeight, GL_RGB, GL_UNSIGNED_BYTE, outPixels);
FIBITMAP* image = FreeImage_ConvertFromRawBits(outPixels, CurrentWindowWidth, CurrentWindowHeight, 3 * CurrentWindowWidth, 24, 0x0000FF, 0xFF0000, 0x00FF00, false);
FreeImage_Save(FIF_BMP, image, "C:/Users/Christopher/Desktop/test.bmp", 0);
// Free resources
FreeImage_Unload(image);
And here is the result: