There are still problems. This code paints "img.png" to the screen:
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow app(sf::VideoMode(800, 600), "Vertices Test");
sf::Texture tex;
tex.loadFromFile("img.png");
while (true) {
sf::Vertex vertices[4];
vertices[0].position = sf::Vector2f(0, 0);
vertices[0].texCoords = sf::Vector2f(0, 0);
vertices[1].position = sf::Vector2f(0, 100);
vertices[1].texCoords = sf::Vector2f(0, 256);
vertices[2].position = sf::Vector2f(100, 100);
vertices[2].texCoords = sf::Vector2f(256, 256);
vertices[3].position = sf::Vector2f(100, 0);
vertices[3].texCoords = sf::Vector2f(256, 0);
sf::RenderStates state;
state.texture = &tex;
app.clear();
app.draw(vertices, 4, sf::Quads, state);
app.display();
}
}
The same in ruby draws a white rectangle:
require "sfml/graphics"
app = SFML::RenderWindow.new([800, 600], "Vertices Test")
tex = SFML::Texture.new
tex.loadFromFile("img.png")
while true
vertices = Array.new(4) { SFML::Vertex.new }
vertices[0].position = [0, 0]
vertices[0].tex_coords = [0, 0]
vertices[1].position = [0, 100]
vertices[1].tex_coords = [0, 256]
vertices[2].position = [100, 100]
vertices[2].tex_coords = [256, 256]
vertices[3].position = [100, 0]
vertices[3].tex_coords = [256, 0]
state = SFML::RenderStates.new
state.texture = tex
app.clear()
app.draw(vertices, SFML::Quads, state)
app.display()
end