Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Avency

Pages: 1 2 [3] 4 5 ... 7
31
Audio / Buffers not deleted
« on: September 05, 2008, 04:58:28 pm »
Quote
Which version of SFML are you using ?

Revision 858 (latest).

32
Feature requests / Video player
« on: September 05, 2008, 03:09:18 pm »

33
Audio / Buffers not deleted
« on: September 05, 2008, 03:01:53 pm »
I solved it: the buffer has to be destroyed after the sound.

This will give you the error:

Code: [Select]
#include <SFML/Audio.hpp>

class SoundBuffer
{
public:
   SoundBuffer()
   {
   }

   virtual ~SoundBuffer()
   {
   }

   bool Init(const std::string& Filename)
   {
      bool Success = Buffer.LoadFromFile(Filename);

      Sound.SetBuffer(Buffer);

      return Success;
   }

   sf::Sound Sound;

private:
   sf::SoundBuffer Buffer;
};

int main()
{
   SoundBuffer Buffer;

   if (!Buffer.Init("test.wav"))
   {
      return EXIT_FAILURE;
   }

   Buffer.Sound.Play();

   while (Buffer.Sound.GetStatus() == sf::Sound::Playing)
   {
      sf::Sleep(0.1f);
   }

   sf::Sleep(1.f);

   return EXIT_SUCCESS;
}


This however will work:

Code: [Select]
#include <SFML/Audio.hpp>

class SoundBuffer
{
public:
SoundBuffer()
{
Buffer = new sf::SoundBuffer;
Sound  = new sf::Sound;
}

virtual ~SoundBuffer()
{
delete Sound;
delete Buffer;
}

bool Init(const std::string& Filename)
{
bool Success = Buffer->LoadFromFile(Filename);

Sound->SetBuffer(*Buffer);

return Success;
}

sf::Sound* Sound;

private:
sf::SoundBuffer* Buffer;
};

int main()
{
SoundBuffer Buffer;

if (!Buffer.Init("test.wav"))
{
return EXIT_FAILURE;
}

Buffer.Sound->Play();

while (Buffer.Sound->GetStatus() == sf::Sound::Playing)

{
sf::Sleep(0.1f);
}

sf::Sleep(1.f);

return 0;
}

34
Audio / Buffers not deleted
« on: September 05, 2008, 09:45:21 am »
Linux, and yes, I'm using openal-soft.

35
Audio / Buffers not deleted
« on: September 04, 2008, 11:55:11 pm »
If my application exits, I get the following error message (replace 1 with the number of sounds loaded at runtime):

Code: [Select]
AL lib: alBuffer.c:1097: exit() 1 Buffer(s) NOT deleted

I keep a sf::Sound and a sf::SoundBuffer inside a class to make it easier to keep track of the resources (for my resource-manager and script bindings).

The destructor is called as expected, so I'm not sure what causes it.

Code: [Select]
class SoundBuffer
{
public:
SoundBuffer()
{
std::cerr << "sound created" << std::endl;
}

virtual ~SoundBuffer()
{
std::cerr << "sound destroyed" << std::endl;
}

bool Init(File& Data)
{
bool Success = Buffer.LoadFromMemory(Data.GetContent(), Data.Size());

Sound.SetBuffer(Buffer);

return Success;
}

sf::Sound Sound;

private:
sf::SoundBuffer Buffer;
};


Can anyone help?

36
Feature requests / C++ (And others too) aliases for functions
« on: August 22, 2008, 05:26:48 pm »
Besides, SFML isn't the only library that uses this naming convention.

37
Graphics / Draw Missing!?
« on: August 20, 2008, 08:40:08 pm »
That part sure looks weird:
Code: [Select]
  for (int i = 0; i < 5; i++)
   {
      Money[i].SetImage(money[i]);
      Money[(i + 5)].SetImage(money[i]);
      Money[(i + 10)].SetImage(money[i]);
      Money[(i + 15)].SetImage(money[i]);
      Money[(i + 20)].SetImage(money[i]);
      Money[(i + 25)].SetImage(money[i]);
   };


You have 30 sprites but set only 5 images.

38
Audio / MIDI support
« on: August 20, 2008, 10:53:05 am »
As far as I know, sfml doesn't support midi.
You can try to render them into another format like ogg vorbis.
Also, portable midi support is unlikely to happen.

39
Window / Input usage out of scope
« on: August 18, 2008, 08:35:57 pm »
I didn't quite get what you mean, but sf::Window::GetInput returns a const reference (think of it as a kind of pointer) to the sf::Input object that is a member of sf::Window. It gets updated when you call sf::Window::GetEvent.

40
Graphics / Fullscreen and wide monitors
« on: August 17, 2008, 11:53:20 am »
You could try to set the fullscreen resolution to desktop resolution (sf::VideoMode::GetDesktopMode) and use a centered sf::View depending on the desktop resolution.

41
Feature requests / True OOP
« on: August 15, 2008, 01:38:14 pm »
Getters/setters are quite common.
It's to allow internal changes without changing to public interface (otherwise you will need good refactoring tools).
And if nothing is calculated, most compilers will inline them, so it's only a personal matter of taste if you prefer input.GetX() or input.X.
And how do you access a protected property without a friend declaration?
You would need to inherit, which often makes sense, but not always.

A side note on OOP:
I think OOP is great, but no always the best way to do things.
I've seen pretty ugly constructs, just because "it had to be OOP".

42
Graphics / Draw Missing!?
« on: August 13, 2008, 09:58:23 pm »
If it fails to load an image, the function will return. Check your console output (or whatever you redirected cerr to). Maybe the problem is a broken image file.

43
General discussions / [Solved] 100% CPU - no matter what code I use.
« on: August 11, 2008, 10:09:02 am »
If you don't limit your CPU usage, it will try to execute as fast as possible.
Try sf::Window::SetFramerateLimit() or sf::Sleep().

44
Graphics / Draw Missing!?
« on: August 10, 2008, 06:06:06 pm »
I'd suggest that you should use relative path names, get the working directory or use some sort of system variable instead of using hardcoded pathnames...seriously!!!
Is there any error output (like "can't fopen")?
Maybe your "Convert" function produces a  unwanted result.

45
Window / Trouble Building in VS2008
« on: August 08, 2008, 11:49:55 am »
You need to link both, window and system package.

Pages: 1 2 [3] 4 5 ... 7