So I've taken apart my code and hacked it down to the bare minimum, removing lighting, shading and all, and the screenshots are still pink. Here is the entire code of a program that displays an empty OpenGL scene. Perhaps you could remove even more, but I removed all the stuff that seemed superfluous.
The scene is dark grey when seen real-time, or captured with PrintScreen (with Windows, not within the program), but pressing F1 (which uses the SFML function) creates a pink/magenta image rather than a dark grey one as expected. There are no polygons, but they aren't necessary to see the problem.
#define GLEW_STATIC
#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <cstdlib>
#include <iostream>
int main()
{
//WindowSize
int WindowWidth = 800;
int WindowHeight = 600;
// Create the main window
sf::RenderWindow App(sf::VideoMode(WindowWidth, WindowHeight, 32), "OpenGL Magenta Problem");
// Set color and depth clear value
glClearDepth(1.f);
//Color here is in RGB, converted to a 0-1 scale.
glClearColor(0.3f, 0.3f, 0.3f, 0.f);
// Enable Z-buffer read and write
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.f, 1.33f, 0.1f, 512.f);
// Start game loop
while (App.isOpen())
{
sf::Event Event;
while (App.pollEvent(Event))
{
// Close window : exit
if (Event.type == sf::Event::Closed)
{
App.close();
}
// Escape key : exit
if (Event.type == sf::Event::KeyPressed &&
Event.key.code == sf::Keyboard::Escape)
{
App.close();
}
if (Event.type == sf::Event::KeyPressed &&
Event.key.code == sf::Keyboard::F1)
{
sf::Image Screen = App.capture();
Screen.saveToFile("screenshot.bmp");
std::cout << "Screenshot saved!\n";
}
}
//Clear color and depth buffer, and reset the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//Display
App.display();
}
return 0;
}