SFML community forums
Help => Audio => Topic started by: VUT on April 16, 2011, 09:59:41 pm
-
hello ,
I compiled SounBuffer's example found on DOC sfml 2.0
unfortunately compiler return this message:
error: aggregate ‘sf::SoundBuffer buffer’ has incomplete type and cannot be defined
I found the same example on forum.
Can you help me ? thanks
-
Can you show the complete code?
-
sure
#include <iostream>
#include <stdio.h>
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Audio/Sound.hpp>
using namespace std;
using namespace sf;
int main()
{
char w;
//
SoundBuffer buffer;
buffer.LoadFromFile("Shot3.wav");
Sound sound(buffer);
cout << "Hello world!" << endl;
sound.Play();
do
{
w = getchar();
}
while (w!= 'e');
sound.Stop();
return 0;
}
-
You forgot to include the SFML/Audio/SoundBuffer.hpp header (or simply SFML/Audio.hpp for the whole module).
-
There is an example with audio.hpp and I have read again the whole doc
SoundBuffer buffer;
buffer.LoadFromFile("Shot3.wav");
Sound sound;
sound.SetBuffer(buffer);
sound.Play();
it is my fault , thanks. :oops: