hello guys
i have a problem with well obviously an sfml project my image wont load but the path should be correct if sfml dosnt do anything with it and the file format is .png and the names are right in code now i want to know why it isnt loading here i ahve some code
/code #include<iostream>
#include<fstream>
#include<string>
#include"SFML\Graphics.hpp"
sf::Texture loadImage(std::string);
sf::Sprite createSprite(sf::Texture,float,float);
int main() {
sf::RenderWindow renderWindow(sf::VideoMode(640, 480), "menu");
float pos = 0.0f;
float pos1 = 0.0f;
sf::Texture dirt = loadImage("dirt.png");
sf::Texture grass = loadImage("grass.png");
sf::Texture player = loadImage("dirt.png");
sf::Sprite s_player = createSprite(player, pos, pos1);
sf::Event event;
while (renderWindow.isOpen()) {
while (renderWindow.pollEvent(event)) {
if (event.type == sf::Event::EventType::Closed) {
renderWindow.close();
}
}
renderWindow.clear(sf::Color::White);
renderWindow.draw(s_player);
renderWindow.display();
}
return 0;
}
sf::Texture loadImage(std::string fileName) {
sf::Texture texture;
if (!texture.loadFromFile(fileName)) {
std::cout << "failed to load image" + fileName << std::endl;
}
return texture;
}
sf::Font loadFont(std::string fileName, sf::Font font) {
if (!font.loadFromFile(fileName)) {
std::cout << "failed to load font" + fileName << std::endl;
}
return font;
}
sf::Sprite createSprite(sf::Texture texture, float pos, float pos2) {
sf::Sprite sprite(texture);
sprite.setPosition(pos, pos2);
return sprite;
}
btw if anyone could tell me how to mark some text as code then please do it