I create a screenshot of my opengl window with help of SDL library, but it was all black and i dont understand why. How to fix it?
Code:
SDL_Surface * image = SDL_CreateRGBSurface(SDL_SWSURFACE, current_w, current_h, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, current_w, current_h, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
SDL_SaveBMP(image, "pic.bmp");
SDL_FreeSurface(image);