Hi thanks for looking...sorry I wasn't more specific - by nothing I meant the image is not displayed. The window opens fine and no errors. I simply get a black background and that's it. If I change the last to values to something that doesn't make sense...say 300, 400 I do see something. I see a large rectangle of the colour of one of the quadrants in the sheet.
The other thing is, is if I display the whole sheet as is - just as a single image its truncated at the top. I think it seems to be because the title of the window cuts off the image?
https://imgur.com/a/vopWmrUHere is a 800x600 image displayed in a 800x600 window...there is some of the image missing at the top. I think that is my issue - the sprite is beneath the title bar.
(some further experimenting later) Yes that is the issue. My sprites were so small they were hidden beneath the title bar. Is that expected behaviour? If I offset the sprite vertically bay say 32 pixels it's visible.Anyway here's the code :
// Demonstrate creating a spritesheet
#include "SFML/Graphics.hpp"
int main(int argc, char** argv) {
sf::RenderWindow renderWindow(sf::VideoMode(640, 480), "Demo Game");
sf::Event event;
sf::Texture texture;
texture.loadFromFile("sheet.png");
sf::Sprite sprite(texture, sf::IntRect(0, 0, 32, 32));
sprite.setPosition(32, 32);
while (renderWindow.isOpen()) {
while (renderWindow.pollEvent(event)) {
if (event.type == sf::Event::EventType::Closed)
renderWindow.close();
}
renderWindow.clear();
renderWindow.draw(sprite);
renderWindow.display();
}
}
Thanks for looking...I'll definitely check those links.