Hi,
I want to compare images using SFML I tried to do using shaders (
http://en.sfml-dev.org/forums/index.php?topic=12239.0) and now I want to make non-shader version.
Currently i have something like this:
// drawing some polygons on texture
texture.display();
sf::Image& generatedImage = texture.getTexture().copyToImage();
long double diff = 0;
int j = 0;
for(int j = 0; j<300; j++)
{
for(int i = 0; i<300; i++)
{
diff += std::abs(generatedImage.getPixel(j,i).r - originalImage.getPixel(j,i).r) +
std::abs(generatedImage.getPixel(j,i).g - originalImage.getPixel(j,i).g) +
std::abs(generatedImage.getPixel(j,i).b - originalImage.getPixel(j,i).b);
}
}
as you can see I'm using
sf::Image& generatedImage = texture.getTexture().copyToImage();
and then when I want access pixel values:
generatedImage.getPixel(x,y).r
I have run profiler and it shows that program spend almost whole time in getPixel() insted of copyToImage(). I thpught that when i call .getTexture.copyToImage() the whole image will be copied from GPU to CPU and then accessing pixels will be very quick. Maybe I do something wrong? Can anyone help me?