I'm loading a texture and passing it to my sprite - I know the texture is being loaded correctly as no error message is displayed (and have tried w/ other images that work correctly), but when trying to draw the Sprite I see no result.
Here is the code:
if (!texture.loadFromFile("Media/Textures/eagle.png")) {
// Error handling as .loadFromFile() returns a boolean.
std::cout << "Could not import texture.";
}
mPlayer.setTexture(texture);
and the player is being drawn in the following:
void Game::render() {
mWindow.clear(sf::Color::Black);
mWindow.draw(mPlayer);
mWindow.display();
}
I've checked to make sure the image is compatible with SFML, that the file is ACTUALLY a png and not manually renamed, that all linkages & directory paths are working (have tried both relative and absolute paths). At this point I'm completely lost and could use some help.
When you say "I see no result", do you just see the black background?
Have you run it through a debugger to ensure that the code you're expecting to be called is actually called?
If you try the following minimal example, does it work?
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::Texture texture;
if (!texture.loadFromFile("Media/Textures/eagle.png"))
return -1;
sf::Sprite sprite(texture);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
window.display();
}
}