I want to draw a single vertex array with a texture. The texture is a 34x34 pixel .png file
I have the following function :
void drawMap(sf::RenderWindow& renderWindow)
{
// create a quad
sf::VertexArray quad(sf::Quads, 4);
// define it as a square, located at (0, 0) and with size 34x34
quad[0].position = sf::Vector2f(0.f, 0.f);
quad[1].position = sf::Vector2f(34.f, 0.f);
quad[2].position = sf::Vector2f(34.f, 34.f);
quad[3].position = sf::Vector2f(0.f, 34.f);
// define its texture area to be a 34x34 square starting at (0, 0)
quad[0].position = sf::Vector2f(0.f, 0.f);
quad[1].position = sf::Vector2f(34.f, 0.f);
quad[2].position = sf::Vector2f(34.f, 34.f);
quad[3].position = sf::Vector2f(0.f, 34.f);
renderWindow.draw(quad, &grass_block);
}
This is how I initialize & load the texture
//initialize grassblock
sf::Texture grass_block;
if (!grass_block.loadFromFile("grass_block.png"))
{
std::cout << "Could not load grass_block!";
}
When my texture does not load, a white square gets drawn with right size & position. When my texture does load properly nothing shows up.