I am trying to make an isometric tile map with vertices. I managed to complete it without vertices. In my head it should be as easy as not doing it with vertices, but I can not get it to work. Dozens of attempts have been made, but I am missing something important.
const uint16_t tileMapSize = 16;
quad = &this->tilesDiamond[(x + y * tileMapSize) * 4]; // tilesDiamond is the vertexarray
const uint16_t blockWidth = 64, blockHeight = 64;
pos.x = (x-y) * blockWidth/2;
pos.y = (x + y) * blockWidth/2;
quad[0].position = sf::Vector2f(pos.x, pos.y);
quad[1].position = sf::Vector2f(pos.x+ blockWidth/2, pos.y+ blockWidth/2);
quad[2].position = sf::Vector2f(pos.x, pos.y + blockWidth);
quad[3].position = sf::Vector2f(pos.x - blockWidth/2, pos.y+ blockWidth/2);
This is the result and it is supposed to look like a diamond shaping with the tiles together. https://i.sstatic.net/ac1hJ.jpg.
quad[0].texCoords = sf::Vector2f(tu * tileSize.x, tv * tileSize.y);
quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.x, tv * tileSize.y);
quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.x, (tv + 1) * tileSize.y);
quad[3].texCoords = sf::Vector2f(tu * tileSize.x, (tv + 1) * tileSize.y);
Since i made an error in the texture coordinated everything was rotated the wrong way.