So strange. I cut it down to a bare minimum and I located the problem at the window declaration.
In main.h
#include <SFML\Graphics.hpp>
extern sf::RenderWindow window;
In main.cpp
#include <SFML\Graphics.hpp>
#include <SFML\Audio.hpp>
#include "main.h"
#include <windows.h>
sf::RenderWindow window(sf::VideoMode(960,540),"Weather Dodger");
int main()
{
sf::Music themusic;
if(!themusic.openFromFile("ASSETS/snow.wav"))
{
MessageBox(NULL,"Not found","Error",MB_OK);
}
themusic.setVolume(100);
themusic.play();
while(window.isOpen())
{
sf::Event e;
while(window.pollEvent(e))
{
if(e.type==sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
}
With this code the music does not play.
But with window declared locally theres no problem.Any ideas why this problem occurs?
In main.cpp with window local.
#include <SFML\Graphics.hpp>
#include <SFML\Audio.hpp>
#include "main.h"
#include <windows.h>
int main()
{
sf::RenderWindow window(sf::VideoMode(960,540),"Weather Dodger");
sf::Music themusic;
if(!themusic.openFromFile("ASSETS/snow.wav"))
{
MessageBox(NULL,"Not found","Error",MB_OK);
}
themusic.setVolume(100);
themusic.play();
while(window.isOpen())
{
sf::Event e;
while(window.pollEvent(e))
{
if(e.type==sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
}
Seems like a window error to me.But why?