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.

Topics - Perde

Pages: [1]
Audio / [Solved] Need help identifying the problem with my sounds.
« on: March 15, 2014, 05:59:43 pm »
I'm in dire need of help once more.  ::)
I have a small class that manages my sf::SoundBuffers and also sf::Sounds.

It contains this method right here, whose task is to first search for sounds that stopped playing and possibly remove them from a vector (of structs that contain the sound itself and a std::string), and continue by playing the desired sound.
As you can see, I search a vector of sf::SoundBuffers (same structure as above) for the name of the file, create a new sound instance, add it to the vector and play it. It works perfectly fine as long as sounds from different files are played at the same time. However, if I try to play the sound from a single file/buffer more than once at the same time, the first just stops abruptly.
If I play the same sound more than two times, it's a complete mess. Sometimes it works and some of the sounds play, sometimes all get cut off.
If I remove "this->sounds.back().sound.play();", everything seems to work (the cleanup gets triggered all the time, but only as expected).
It's obvious that I'm doing something wrong, but I simply can't figure it out.

void ac::SoundStorageDebug::play(std::string file)
    std::vector<ac::SoundStorageDebug::Sound>::iterator i = this->sounds.begin();
    while(i != this->sounds.end())
        if(i->sound.getStatus() != sf::Sound::Playing)
            std::cout << i->sound.getStatus() << std::endl;
            i = this->sounds.erase(i);
            std::cout << "sound removed" << std::endl;
    for(std::vector<ac::SoundStorageDebug::Buffer>::iterator i = this->buffers.begin(); i != this->buffers.end(); ++i)
        if(i->file.compare(file) == 0)
            ac::SoundStorageDebug::Sound tmp;
            std::cout << "sound created" << std::endl;

Graphics / Acceleration-Effect with sprite-based cursor.
« on: March 13, 2014, 01:03:02 pm »
Now that I've found the time to code again, I want to solve an issue that has bugged me ever since. I don't think the code is necessary, since all I'm doing is draw a shape and make it follow the cursor, but there you go.

The problem I have is, that there is an acellerated-mouse efect present when using a sprite-based custom cursor, that gets dramatically amplified by activating vsync. The video shows what I mean. While the effect may become less obvious when hiding the cursor, it is still bothersome.
(The effect with vsync turned off, or an uncapped framerate, however the movement is much more crisp.)

The little game I've set my mind to requires precise and quick mouse input, even while the cursor is moving. This issue however opens up the possibility of registering a click on a location that differs from the one of the cursor-sprite.
Also, but that's a personal opinion, I think the whole acceleration effect is just awful, even if deliberately built in.

(It doesn't even look that bad in the video. But especially when moving in a constant motion, the sprite clearly lags behind. )

#include <SFML/Graphics.hpp>

int main()
    sf::RenderWindow window(sf::VideoMode(1280, 720), "Title");
    sf::CircleShape shape(10.f);
    shape.setOrigin(10, 10);

    while (window.isOpen())
        sf::Event event;
        while (window.pollEvent(event))
            if (event.type == sf::Event::Closed)


    return 0;

I have considered alternatives already, like using windows-functionality like "LoadCursorFromFile()", but then I'd have to look for equivalent functions on other Platforms, or lose portability (I'd like to avoid both). Also, I'm wondering if getting the input from a different thread would help. (I have yet to try the latter, as I haven't worked with threads before)

Anyway, any input is very welcome!

General / Slow execution on first start.
« on: August 25, 2012, 05:44:41 pm »
[edit] The problem seems to have disappeared after updating to the latest snapshot. Should've thought of that before. While it would still be interesting to know what caused that behaviour, everything seems to work now.

This is something that has been bugging me for a very long time now, but never to a point that made me look for a solution. Whenever I start up a program that uses the SFML for the first time after a fresh boot the execution is terribly slow. I often get around 1fps, or even less.
Then, after ending the program and restarting it again, everything works perfectly fine (every other program that is using SFML works fine after that as well).
After the next reboot of my system however, the whole issue starts again.

It's probably caused by something else than SFML, but only happens with apps using it.
I'm currently using the RC and it's pre-compiled libs. OS is Win7 64 bit, gcc is 4.4.1 if I'm not mistaken.

Would be glad about any hint.

SFML projects / MyGui - Yet another GUI-System!
« on: May 31, 2012, 02:03:37 am »
Okay, creating a thread in this section. premiere for me, hooray!  ;D

This is an older project and was the first real thing I did with SFML (other than playing around). And also right after reading half a book about C++ (existing programming experience, like ... writing a calculator that does the 4 basic operations in C and stuff).

Anyway, I've spent the last evenings reviewing and updating everything to work with the current RC, did some debugging and, thank god, everything works flawlessly.


Everything is as slim and flexible as possible, so no title bars or buttons for the windows right from the start or stuff like that. You can basically make it look and work however you want (as long as the existing controls allow it, of course).

Well, hope you like my first real project and all. Thanks to Laurent for all his work and an amazing library.

Graphics / sf::Text bounds not updated
« on: May 31, 2012, 12:35:35 am »
Okay, I have a little problem with sf::Text that I need some help with, or some clarification.

Basically this happens:
sf::Text text;
std::cout << text.getGlobalBounds().width << std::endl; // 0
std::cout << text.getGlobalBounds().width << std::endl; // 0
std::cout << text.getGlobalBounds().width << std::endl; // 16
std::cout << text.getGlobalBounds().width << std::endl; //16

In words: Once sf::Text had some sort of string and is set to an empty string it still keeps the bounds of the previous one.

Now I'd like to know if this is intended, if I'm doing something wrong or if this shouldn't be that way. Is there maybe a better way to clear the string?

Oh yes, I'm using 2.0 RC.

Graphics / Image::Copy causing crash.
« on: May 03, 2011, 04:57:50 pm »

Okay, after deleting my first thread this will be my new first one.  :D

Once again, I'm quite new to programming, so please excuse if my problems might be caused by my wrong understanding.

My problem is the following:
I'm trying to create an Image of variable size that copies certain information from a "dummy-image". My problem occurs while trying to slice the dummy into four parts and copy each part into the corresponding corners of the new Image.

My actual try looks something like this:
Code: [Select]
NI ... The new (variable) image.
DI ... The dummy.
NW/NH ... New image Width/Height
DW/DH ... Dummy Width/Height

NI.Copy(DI, 0, 0, rect(0, 0, DW/2, DH/2))
NI.Copy(DI, NW-DW/2, 0, rect(DW/2, 0, DW/2, DH/2))
NI.Copy(DI, 0, NH-DH/2, rect(0, DH/2, DW/2, DH/2))
NI.Copy(DI, (NW-DW/2)-2, NH-DH/2, rect(DW/2, DH/2, DW/2, DH/2))

The dummy looks like this:

And the code is creating this:

The crash seems to be caused by the last line (responsible for the box in the lower right corner). Like this, there is an offset of 2 pixels being drawn, but if I change the
Code: [Select]
(NW-DW/2)-2 in the last line into
Code: [Select]
NW-DW/2 the program will crash.

Am I handling the coordinates wrong? If so, why does it work perfectly fine for the other three boxes?

I'm using SFML2 on Windows 7 64 Bit.


Oh, the last line from the actual code:
Code: [Select]
ImgBackground.Copy(*DummyBackground, (ImgBackground.GetWidth() - DummyBackground->GetWidth()/2)-2, ImgBackground.GetHeight() - DummyBackground->GetHeight()/2, sf::IntRect(DummyBackground->GetWidth()/2, DummyBackground->GetHeight()/2, DummyBackground->GetWidth()/2, DummyBackground->GetHeight()/2));

Pages: [1]