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

Pages: [1]
1
System / sf::Thread no apropriate default constructor
« on: December 05, 2010, 02:14:52 am »
Thank you very much!

2
System / sf::Thread no apropriate default constructor
« on: December 04, 2010, 06:19:08 pm »
Quote from: "Laurent"
Quote
I built SFML 2.0 [...] using example code found in http://www.sfml-dev.org/tutorials/1.6/system-threads.php

Well, you can't read the 1.6 documentation/tutorials and use 2.0. A lot of things have changed, you should rather refer to the 2.0 documentation:
http://www.sfml-dev.org/documentation/2.0/

Tutorials haven't been updated yet, but the documentation should be enough.


Sorry - you're right.  I should have mentioned I also took a look at the documentation here: http://www.sfml-dev.org/documentation/2.0/classsf_1_1Thread.htm

The Usage Example for creating a derived class using sf::Thread also uses the same setup, unless I am mistaken.  That's where my confusion lies - since the 1.6 and 2.0 doc seems to match up, and the error still happens even when copying the code from the 2.0 docs.

Thanks for your help.

3
System / sf::Thread no apropriate default constructor
« on: December 04, 2010, 06:33:29 am »
I built SFML 2.0 this evening and was reading documentation - I'm having issues with sf::Thread giving me errors when using example code found in http://www.sfml-dev.org/tutorials/1.6/system-threads.php

I'm doing the example with a class inheriting from sf::Thread (pretty much the exact code you see there) - and I get a "'MyThread' : no appropriate default constructor available" error.  Is there a way to resolve it?

Source is below:

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

sf::Mutex GlobalMutex; // This mutex will be used to synchronize our threads

class MyThread : public sf::Thread {
private :

    virtual void Run() {
        // Lock the mutex, to make sure no thread will interrupt us while we are displaying text
        GlobalMutex.Lock();

        // Print something...
        for (int i = 0; i < 10; ++i)
            std::cout << "I'm the thread number 2" << std::endl;

        // Unlock the mutex
        GlobalMutex.Unlock();
    }
};

int main() {
    // Create an instance of our custom thread class
    MyThread Thread;

    // Start it !
    Thread.Launch();

    // Lock the mutex, to make sure no thread will interrupt us while we are displaying text
    GlobalMutex.Lock();

    // Print something...
    for (int i = 0; i < 10; ++i)
        std::cout << "I'm the main thread" << std::endl;

    // Unlock the mutex
    GlobalMutex.Unlock();

    return EXIT_SUCCESS;
}

Pages: [1]
anything