I have found that drawing triangles is not accurate to the coordinates I specify. I am having issues with vertex pixels being cut off, as well as edges. I am experiencing this with different orientations of triangles. I am only using integers, so it is not a decimal issue.
Below is the code, texture, and screenshot. In the screenshot below, the leftmost vertex is cut off, as is the rightmost edge.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(512, 256), "Triangle");
sf::VertexArray triangle(sf::Triangles, 3);
sf::Texture tex;
if (!tex.loadFromFile("texture.png"))
return -1;
triangle[0].position = sf::Vector2f ( 0, 16);
triangle[1].position = sf::Vector2f ( 27, 0);
triangle[2].position = sf::Vector2f ( 27, 32);
triangle[0].texCoords = sf::Vector2f ( 0, 16);
triangle[1].texCoords = sf::Vector2f ( 27, 0);
triangle[2].texCoords = sf::Vector2f ( 27, 32);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(triangle, &tex);
window.display();
}
return 0;
}