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

Pages: 1 ... 10 11 [12]
166
General / Pass data to a thread function
« on: October 02, 2010, 04:19:34 am »
Hi, I have a simple question about passing a variable to a thread function that I think it's easy to answer.

I was following this tutorial:
http://www.sfml-dev.org/tutorials/1.6/system-threads.php
And I read the part that explains my question, however I'm not having success when I try to pass a variable to the thread function.


I have the variable int n declared on the main, where n's value is 5.
Now I want to pass this value to a threaded function.
I tried the following:

Code: [Select]

void print_Console(void *UserData)
{
int* n = static_cast<int*>(UserData);
cout << "n=" << *n << endl;
}

int main()
{
int n=2; //EDITED AT Sat Oct 02, 2010 11:50 am
Thread th1(&print_Console, &n);
th1.Launch();
}



But it's not outputting n correctly.
So, what could be wrong here?

Thanks in advance

167
Audio / Failed to load sound buffer from file
« on: September 29, 2010, 08:26:38 pm »
Hi, I'm new to the forums so I'm not sure if I'm posting in the correct section, but here it goes.

I tried making a program in Visual Studio C++ 2008 using SFML, that would play a simple .wav file. However when I run it I only get the message:
"Failed to load sound buffer from file "sound.wav".

The code is the default one provided on the Audio tutorial:
http://www.sfml-dev.org/tutorials/1.6/audio-sound.php

source file in: http://www.sfml-dev.org/tutorials/1.6/sources/audio-sound.cpp

I've included libsndfile-1 and openal32 on the exe folder. The sound is present on the folder as well and is named sound.wav

What could be wrong?

Thanks in advance for any help

Pages: 1 ... 10 11 [12]