I am new to SFML and am having trouble playing music. I have looked at the tutorial and documentation and through the forum and internet but I can't find the solution to my problem.
I am using VS 2010 Express and the program builds and debugs and works fine UNTIL I add this:
sf::Music (name);
then the program builds without errors but as soon as I debug this window pops up:
(Name).exe - Application Error
-------------------------------------------------
"The application was unable to start correctly (0xc000007b). Click OK to close the application."
-------------------------------------------------
If I remove sf::Music it will debug correctly again, and moving it around will also cause the error.
I have all of the sfml-(whatever) dlls linked in my additional dependencies under debug and release (for whatever one they need) and copied into my project directory.
-- I have included openal32.dll and libsndfile-1.dll in my project directory but haven't added them to additional dependencies (maybe the problem? If so- what do I label them as?)
I am the using SFML 2.0 library.
The code is:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
int main()
{
sf::VideoMode Vmode = sf::VideoMode::GetDesktopMode()
sf::RenderWindow Window(Vmode, "Window Name", sf::Style::Fullscreen);
sf::Texture Texture1; // create a texture variable for an image
if (!Texture1.LoadFromFile("waterfall2.jpg")) // checks to see if the image is valid
return EXIT_FAILURE;
sf::Sprite Sprite1;
Sprite1.SetTexture(Texture1);
Sprite1.SetPosition(0.0f, 0.0f);
Sprite1.SetScale((float)Window.GetWidth()/(float)Texture1.GetWidth(), (float)Window.GetHeight()/(float)Texture1.GetHeight());
while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
case sf::Event::KeyPressed:
if (Event.Key.Code == sf::Keyboard::M)
{
sf::Music mTitle;
if (!mTitle.OpenFromFile("Song.mp3"))
return EXIT_FAILURE;
mTitle.Play();
}
default:
break;
}
}
Window.Clear(sf::Color(0, 0, 255));to blue (RGB)
Window.Draw(Sprite1);
Window.Display();
}
return 0;
}
Any suggestions are appreciated.