According to Ken, a function passed as a stream callback should be a function of type (void *) (*) (void *).
You can enable this function as a class function, but it must be declared as static. For each type of stream (e.g. draw) you will need a different option.
For instance:
class Game {
protected:
void draw(void);
static void* game_draw_thread_callback(void*);
};
void Game::create_threads(void) {
pthread_create(&draw_t, NULL, Game::game_draw_thread_callback, this);
}
static void* Game::game_draw_thread_callback(void *game_ptr) {
Game * game = (Game*)game_ptr;
game->draw();
}
source
share