SFML community forums

Help => Audio => Topic started by: svante112 on August 25, 2013, 08:20:25 pm

Title: When trying to load in music i get an error
Post by: svante112 on August 25, 2013, 08:20:25 pm
As the title says i get an error when i try to run this

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>

int main()
{
        float spritePosX = 50;
        float spritePosY = 50;

        sf::Music music;
       
        if(!music.openFromFile("music.ogg"))
        {
                return -1;
        }
        music.play();

    sf::RenderWindow window(sf::VideoMode(640, 480), "SFML test");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

        //Fixing texture
        sf::Texture texture;
        if(!texture.loadFromFile("wood.png"))
        {
                return EXIT_FAILURE;
        }
        texture.setSmooth(true);
        texture.setRepeated(false);

        //Fixing sprite
        sf::Sprite sprite;
        sprite.setTexture(texture);
        sprite.setColor(sf::Color::Green);
        sprite.setPosition(sf::Vector2f(spritePosX, spritePosY));

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {

                               
                       

            if (event.type == sf::Event::Closed)
                window.close();

                        if(event.type == sf::Event::KeyPressed)
                        {
                                if(event.key.code == sf::Keyboard::Up)
                                {
                                        sprite.move(0, -5);
                                }
                                if(event.key.code == sf::Keyboard::Down)
                                {
                                        sprite.move(0, 5);
                                }
                                if(event.key.code == sf::Keyboard::Left)
                                {
                                        sprite.move(-5, 0);
                                }
                                if(event.key.code == sf::Keyboard::Right)
                                {
                                        sprite.move(5, 0);
                                }
                                if(event.key.code == sf::Keyboard::R)
                                {
                                        sprite.setColor(sf::Color::Red);
                                }
                                if(event.key.code == sf::Keyboard::G)
                                {
                                        sprite.setColor(sf::Color::Green);
                                }
                                if(event.key.code == sf::Keyboard::B)
                                {
                                        sprite.setColor(sf::Color::Blue);
                                }
                                if(event.key.code == sf::Keyboard::Y)
                                {
                                        sprite.setColor(sf::Color::Yellow);
                                }
                        }

       
                }

                window.clear();
                window.draw(sprite);
        window.display();
    }

    return 0;
}
When i try to run it it says it cant start the program and then (0xc000007b)

When i check output from debug it says

Quote
The program '[8204] SFML 2.1 game.exe' has exited with code -1073741701 (0xc000007b).

I have no clue whats going on  :-[
Title: Re: When trying to load in music i get an error
Post by: AlexxanderX on August 25, 2013, 09:03:32 pm
Tried the code and it's works( instead of *.ogg I had *.ogv). You are sure the problem is from the music/audio?
Title: Re: When trying to load in music i get an error
Post by: G. on August 25, 2013, 09:07:24 pm
http://en.sfml-dev.org/forums/index.php?topic=9570.msg65322#msg65322
Maybe.
Title: Re: When trying to load in music i get an error
Post by: svante112 on August 25, 2013, 09:23:45 pm
Tried the code and it's works( instead of *.ogg I had *.ogv). You are sure the problem is from the music/audio?

I am sure its the audio becuse if i delete the code it works :/
Title: Re: When trying to load in music i get an error
Post by: svante112 on August 25, 2013, 09:24:53 pm
http://en.sfml-dev.org/forums/index.php?topic=9570.msg65322#msg65322
Maybe.

Didnt really help me but i may be following the instructions wrong ^^
Title: Re: When trying to load in music i get an error
Post by: svante112 on August 27, 2013, 05:23:08 pm
bump
Title: Re: When trying to load in music i get an error
Post by: eXpl0it3r on August 27, 2013, 05:40:32 pm
The fact that nobody really answered is, that the given information is not enough. As a programmer your most useful tool is the debugger. Run the application through the debugger and find out where it crashes, trace it back and check the states of the classes.

An issue that comes up often is, that you're mixing debug and release modes/libraries.