Greetings!
I’m new to openGL and I want to migrate my screenshot program, written in C and using Windows API, to openGL.
It does BitBlt/GetDIBits/etc. and saves the desktop image as bmp-file.
However, I have problems with OpenGL with this simple task.
Can Anyone show me an example of such a task?
Below is my C-code, however the saved file is always black…
HWND hwnd;
HDC hDC;
HGLRC hRC;
int width = 1024;
int height = 768;
BYTE pRGB = (BYTE )malloc(3widthheight);
hwnd = GetDesktopWindow();
EnableOpenGL(hwnd, &hDC, &hRC);
printf("OpenGL Version: %s
“, glGetString(GL_VERSION));
printf(” Vendor: %s
“, glGetString(GL_VENDOR));
printf(” Renderer: %s
", glGetString(GL_RENDERER));
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pRGB);
FIBITMAP* image = FreeImage_ConvertFromRawBits(pRGB, width, height, 3*width, 24, 0xFF00FF, 0xFF00, 0x0000FF, false);
FreeImage_Save(FIF_JPEG, image, “ScreenShot-GLTest.jpg”, 0);
DisableOpenGL(hwnd, hDC, hRC);
Thanks for reading and hints!