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 - Zephilinox

Pages: [1] 2 3
1
General discussions / Re: SFML 3 - What is your vision?
« on: June 25, 2014, 12:26:06 pm »
I'd like Sprite Batching, the ability to modify the style/colour of substrings of sf::Text, and a way of setting an outline for sf::Text.

A Line class would be nice too, I think it was removed from a previous version, I guess for performance issues? Would spite batching resolve those issues?

I'd also like to see more work done on the other areas of SFML, like Audio and Networking, which are generally forgotten. Though I have no specific suggestions in mind. I don't feel like there are any good frameworks out there for audio and networking that are both easy and simple.

2
General discussions / Re: Games
« on: January 17, 2014, 12:07:41 pm »
Would it be practical to use SFML to write a board game such as chess or checkers for two people to play??????
Thanks
WVT

Yep, there's nothing about SFML that would not make it possible.

3
General discussions / Re: Mutual following on Twitter!
« on: January 16, 2014, 08:26:33 am »
I've had a twitter account for a while but I never really had any use for it, this seems like a great idea, I'll be adding all of you.

https://twitter.com/Zephilinox

4
Audio / Re: When the first sound ends, so does the second.
« on: December 13, 2013, 09:12:20 pm »
No need to use smart pointers here.

Be careful if m_Sounds is a std::vector: When inserting new objects, the container may relocate the existing elements, leading to the destruction (and stopping) of the sounds.

Furthermore, don't erase elements in the middle of the iteration in a std::vector. The std::vector::erase() call leads to copies of all the elements behind the one being removed, which has the issues mentioned above, in addition to being terribly inefficient.

You might consider std::list to store sounds, here you can also use erase() without problems. Or directly remove() or remove_if(). However, you have to use iterators instead of indices -- but you should iterate with iterators anyway, for any container (unless you actually need the random access or the numeric value of the index).

Switching from std::vector to std::list fixed it! thanks Nexus. It's obvious I need to learn a lot more about how these basic data structures work. Your description about stopping the sounds was another issue I was having where as soon as a sound is added, even if none of them are at the end it would indeed destroy all of them but that is now fixed too :)

Indices are just a habit for me, I'll try to use iterators from now on.

5
Audio / Re: When the first sound ends, so does the second.
« on: December 13, 2013, 05:09:02 pm »
Are there any obvious mistakes I'm making here?
The irony of your post is, that I can directly quote you as answer:

Noteworthy: m_Sounds and m_SoundBuffer are static private member variables. m_Sounds is a vector and m_SoundBuffer is a map.
Static members are essentially global variables, global variables have an undefined order of destruction and since SFML has global variables as well, it can happen that SFML's audio stuff gets deleted before the sound objects that still reference to the SFML parts, thus leading to a crash.

tl;dr: Don't use global variables! ;)

Thanks, I'll have to think of something else for that just in case another bug creeps up however making it non-static(for both sound and buffers) has not fixed the issue.

Edit: I quickly thought of something and changed the sound() function to this:
void ResourceManager::sound(std::string fileName)
{
    //sf::Sound s(this->soundBuffer(fileName));
    sf::Sound* s = new sf::Sound();
    s->setBuffer(this->soundBuffer(fileName));
    m_Sounds.push_back(s);
    m_Sounds.back()->play();
}
 

and it now works properly, so I then changed it to this to avoid memory management (if it comes to it I'll use smart pointers, just used manual to test quickly)

void ResourceManager::sound(std::string fileName)
{
    sf::Sound s;
    m_Sounds.push_back(s);
    m_Sounds.back().setBuffer(this->soundBuffer(fileName));
    m_Sounds.back().play();
}
 

but that has the same issues as the original version. Something is going on somewhere and I'm not sure what.

6
Audio / When the first sound ends, so does the second.
« on: December 13, 2013, 02:58:36 pm »
Are there any obvious mistakes I'm making here?

Noteworthy: m_Sounds and m_SoundBuffer are static private member variables. m_Sounds is a vector and m_SoundBuffer is a map.

void ResourceManager::Update()
{
    for (unsigned int i = 0; i < m_Sounds.size(); ++i)
    {
        std::cout << "Sound " << i << " = " << m_Sounds[i].getPlayingOffset().asSeconds() << "\n";

        if (m_Sounds[i].getStatus() == sf::Sound::Stopped)
        {
            std::cout << i+1 << " / " << m_Sounds.size() << " was Killed\n";
            m_Sounds.erase(m_Sounds.begin() + i);
            continue;
        }
    }
}

sf::SoundBuffer& ResourceManager::soundBuffer(std::string fileName)
{
        std::map<std::string, sf::SoundBuffer>::iterator it = m_SoundBuffers.find(fileName);

        if (it == m_SoundBuffers.end()) //not found
        {
                sf::SoundBuffer sb;
                assert(sb.loadFromFile("audio/" + fileName + ".wav"));
                std::cout << "SoundBuffer Loaded: " << "audio/" << fileName << ".wav\n";
                m_SoundBuffers.insert(std::make_pair(fileName, sb));
                return m_SoundBuffers.find(fileName)->second;
        }

        return it->second;
}

void ResourceManager::sound(std::string fileName)
{
    sf::Sound s(this->soundBuffer(fileName));
    m_Sounds.push_back(s);
    m_Sounds.back().play();
}
 

case sf::Event::MouseButtonPressed:
{
    ResMan.sound("fireworks");
    break;
}
 



only when I close the RenderWindow do I get the segmentation fault


7
Lo-X a repo would be great, thanks. Whenever you're able.

I'd prefer to stick to SFML's networking module, I like SFML for being in that medium spot between raw, OS-Specific API and Game Engines, I may try SFNUL at a later date but for now I don't feel as if I need it.

Thanks for the link eXpl0it3r, I didn't know there was an FAQ.

8
I've had issues using SFML's networking part of the library in the past and want to create a multiplayer game, are there any open-source games made with SFML that use the SFML networking library that I could take a look at?

9
General discussions / Re: SFML Game Jam
« on: July 22, 2013, 10:34:26 am »
Rating on SFML integration is unrealistic, it assumes that everyone releases the source code of their games and that people have the time and will to go through every bit of it to determine the extent to which SFML is used, which would likely vary greatly by experience and opinion anyway.

I don't use OpenGL but I understand why someone who is proficient in it would rather use it than use SFML's graphics library, however that is not the point of this Jam. I think we need to make it very clear that this is to showcase the quality and speed in which you can make games using SFML without the use of other graphical libraries.

If someone wants to use Box2D or Boost or whatever else I feel that's pretty reasonable, but use of any other library for rendering and/or based on SFML2 (OpenGL, SFGUI, TGUI, Thor) should not be allowed, in my opinion.

10
General discussions / Re: Dev-C++?
« on: October 26, 2012, 10:31:13 am »
And just saying that dev is like paradise for not-so-good coders around here apparently
'oh, why split program into many files, why visual c++, in dev, one file, 2000 lines, everything worked, oh i don't know how to use C or c++ standard library or pointers or arrays'
I don't get your problem... Just because people can't program and use application X doesn't make the application bad. At lot of kiddies use Visual Studio, but that doesn't make the software bad.
Your prejudices aren't really relevant to anyone else than you. ;)

I did read your post expl0iter, but I assumed you meant Orwell Dev-C++ or wxDev-C++, but the actual Dev-C++ has been revived? good to know.

edit: it was Orwell you were referring to, that's not the same as Dev-C++.
So? Just because it's not the official one it isn't usable or what's the argument here? ???

Just so you know, I don't use Dev-C++, but I don't see a reason to hold up the old prejudices when there's a new version that's constantly in development... :-\

I read your post, said Dev-C++ was outdated, and then you said I didn't read your post, so I mentioned I did and that I assumed you meant OrwellDev-C++ or the WX widgets version (I didn't bother clicking the link) and not the actual, outdated, orginal, Dev-C++ which is the only version this thread is referring to, not any of the newer forks.

So the argument is that the several forks of Dev-C++ are not the ones mentioned in this topic, since this topic only cares about the original Dev-C++

11
General / Re: Strange bottleneck
« on: October 25, 2012, 06:45:53 pm »

12
General discussions / Re: Dev-C++?
« on: October 22, 2012, 10:32:20 pm »
Rex = T-Rex = Dinosaur, it was a joke ;)

I did read your post expl0iter, but I assumed you meant Orwell Dev-C++ or wxDev-C++, but the actual Dev-C++ has been revived? good to know.

edit: it was Orwell you were referring to, that's not the same as Dev-C++.

13
General discussions / Re: Dev-C++?
« on: October 22, 2012, 09:09:42 pm »
but..aren't you a dinosaur, Rex?

jokes aside, Dev-CPP is used by people who don't know it is outdated, which normally means they don't know much about C++ but more C, or they learned only a tiny bit during their programming course 10 years ago.

and I too dislike Visual Studio, but mostly because it is microsoft-ware that I can't use on other platforms.

14
Window / Re: Drawing/Displaying sprites from another function
« on: October 22, 2012, 08:57:17 pm »
your float to string function can be written in about 5 lines if you use the C++ header <stringstream>


15
actually it means about 350 FPS, milli = 1000 not 100 :]

Pages: [1] 2 3