#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!",sf::Style::Default);
window.setVerticalSyncEnabled(true);
sf::Vertex point;
point.color = sf::Color::Red;
point.position = sf::Vector2f(2,2);
window.draw(&point,1,sf::Points),
window.clear();
window.display();
sf::Image img = window.capture();
window.display();
window.clear();
window.draw(&point,1,sf::Points);
img = window.capture();
std::cout << img.getPixel(2,1).toInteger() << '\n'; // gives red
std::cout << img.getPixel(2,2).toInteger() << '\n'; //gives black, this should have given red
window.close();
return 0;
}
Pixel (2,2) is red using draw but is black using getPixel. Why?