SFML error from loadFromFile Absolute path

1
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(600,600), "sfml work");//윈도우 명령어 지칭하는 대상의 이름이 window라고 하는거다. 
    sf::Sprite background;
    sf::Texture texture;    
    
    if (!texture.loadFromFile("firepunch.png"))
    {
        std::cout<< "ERROR" << std::endl;
    }

    background.setTexture(texture);

    while (window.isOpen()) //만약 윈도우창이 열린다면
    {
        sf::Event ss; // Event는 명령어 이벤트 이름이 ss라고 하는거다 명령어+명령어 이름 순인듯
        
        while (window.pollEvent(ss))
        {
            switch (ss.type)
            {
            case sf::Event::Closed:
                window.close();
                break;

            case sf::Event::Resized:
                    sf::FloatRect visibleArea(0, 0, ss.size.width, ss.size.height);
                    window.setView(sf::View(visibleArea));
                    break;
            }
        }
        window.clear();
        window.draw(background);
        window.display();

    }
    return 0;
}

enter image description here

I am beginner of sfml when write this code debuger says this code have excess error. I think "if (!texture.loadFromFile("firepunch.png"))" is error but i can fix it 3 hours. search a google but can't find the solution. this error says 'while read 0xC0000005: 0x00000000 An access violation has occurred.' please help me.... what can i do?

c
sfml
asked on Stack Overflow Feb 27, 2021 by 전재원 • edited Feb 27, 2021 by tuket

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0