Re: SFML question

2017-07-01 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: SFML question

It doesnt work.ped.cpp:181:36: error: expected primary-_expression_ before ‘,’ token thr = new sf::Thread(std::bind(&Ped, &goToCoords, d, a_ped[d].x, a_ped[d].y - cy, a_ped[d].z));ped.cpp:181:39: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say ‘&Ped::goToCoords’ [-fpermissive] thr = new sf::Thread(std::bind(&Ped, &goToCoords, d, a_ped[d].x, a_ped[d].y - cy, a_ped[d].z));                                       ^~

URL: http://forum.audiogames.net/viewtopic.php?pid=317564#p317564





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-07-01 Thread AudioGames . net Forum — Developers room : visualstudio via Audiogames-reflector


  


Re: SFML question

use this instead:std::bind(&classname, &func, parameters);

URL: http://forum.audiogames.net/viewtopic.php?pid=317553#p317553





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-30 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: SFML question

I have my function in class, and I cant user std::bind(&Class::function, parameters); because i receive this error:/usr/include/c++/7.1.1/functional:588:2: note: candidate: template _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (Ped::*)(int, float, float, float); _Bound_args = {int, float, float, float}]  operator()(_Args&&... __args) const volatile  ^~~~/usr/include/c++/7.1.1/functional:588:2: note:   template argument deduction/substitution failed:

URL: http://forum.audiogames.net/viewtopic.php?pid=317478#p317478





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-30 Thread AudioGames . net Forum — Developers room : visualstudio via Audiogames-reflector


  


Re: SFML question

hello,you can use structures instead of more parameters:typedef struct a {
int a;
int b;
int c;
int d;
};

void some_func(a& s)
{
cout<< s.a+s.b+s.c+s.d;
}

int main()
{
a* as=new a;
sf::thread t(&some_func, &as);
t.launch();
delete as;
}please note, i've didnt test this codealso you can use mutexes to lock things (i havent delt with sfml's thread api)

URL: http://forum.audiogames.net/viewtopic.php?pid=317468#p317468





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-26 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: SFML question

That's not SFML's problem, but you provoking a deadlock or lifelock.Let's take this example:void print_sum(int v1, int v2, int v3, int v4)
{
  std::cout << (v1 + v2 + v3 + v4) << endl;
}
int main()
{
  int a = 1;
  int b = 2;
  int c = 4;
  int d = 8;
  sf::Thread t(std::bind(&print_sum, a, b, c, d));
  t.launch();
}This should work fine and print you the sum of the 4 variables a, b, c and d. If your program is written correctly and it freezes anyway you're accessing variables and/or functions from inside your threaded function which gets accessed from the main thread too and therefore block each other. In this case you'll have to make your program thread safe. If you don't know what that means, you probably shouldn't go with threads anyway or read yourself through thread example on your own first.Best Regards.Hijacker

URL: http://forum.audiogames.net/viewtopic.php?pid=316904#p316904





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: SFML question

My function is freezing my program.

URL: http://forum.audiogames.net/viewtopic.php?pid=316856#p316856





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: SFML question

I have a function with 4 arguments. int number, float number, float number, float number. These arguments haven given when program works. Ped Identificator, float x, float y, and float z destination coordinates. I cant compile it, maybe because I don't write void function(std::bind)..., I will try that.

URL: http://forum.audiogames.net/viewtopic.php?pid=316848#p316848





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: SFML question

There are actually multiple aproaches you could take to reach your goal here, and all of these are shown in the link above. The first one would be to use a lambda which then calls the function you need with all the arguments you require, or, as you already said, using std::bind, which is absolutely easy too.// with std::bind
void func(std::string, int, double)
{
}

sf::Thread thread(std::bind(&func, "hello", 24, 0.5));So what's the actual problem you're facing here?As the link above already says, if you're using C++ and a comparably new compiler, use the native C++11 threads instead, they are safer and more efficient.Best Regards.Hijacker

URL: http://forum.audiogames.net/viewtopic.php?pid=316846#p316846





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: SFML question

I know it because I can't forward more than 3 parameters, so I need std::bind.

URL: http://forum.audiogames.net/viewtopic.php?pid=316834#p316834





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: SFML question

The link I posted above explains everything, and as far as I can see you don't need std::bind for that.Best Regards.Hijacker

URL: http://forum.audiogames.net/viewtopic.php?pid=316823#p316823





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: SFML question

I need call function with one or more argument. I did read about the std::bind, but I don't know what i can implement it in my program.

URL: http://forum.audiogames.net/viewtopic.php?pid=316803#p316803





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: SFML question

That should be obvious. As far as I can see the sf::Thread constructor accepts as many arguments as you need. Meaning that you can give it the function to call as the first parameter and all required arguments after that. For more examples go here.Best Regards.Hijacker

URL: http://forum.audiogames.net/viewtopic.php?pid=316801#p316801





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

SFML question

2017-06-25 Thread AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector


  


SFML question

Hello,I have a question about SFML library. How can I force it that it will open thread with more than one parameter?

URL: http://forum.audiogames.net/viewtopic.php?pid=316797#p316797





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector