Making a module: Void *?
BlitzMax Forums/BlitzMax Programming/Making a module: Void *?
| ||
Hi, I'm making a module for OpenAL, and I'm having some problems. My small test crashes while trying to load a wav file. The point where my test is crashing is here at the alutLoadWAVfile: Local format:Int Local size:Int Local data:Byte Ptr ' <- Not sure if this is the bmax version of void * Local freq:Int Local loop:Int alGenBuffers(1, wav_data ) If alGetError() <> AL_NO_ERROR Then Return False alutLoadWAVFile("test.wav".tocstring(), format, data, size, freq, loop ) And this is how the original C source looked like: ALenum format; ALsizei size; ALvoid* data; ALsizei freq; ALboolean loop; alGenBuffers(1, &Buffer); if (alGetError() != AL_NO_ERROR) return AL_FALSE; alutLoadWAVFile("wavdata/FancyPants.wav", &format, &data, &size, &freq, &loop); I think it's the void *data -> data:byte ptr part that I got wrong, but if somebody can spot any other errors I would be grateful. Thankful for any help. |
| ||
You should use $z in the function definition instead of .toCString() for the first argument of alutLoadWAVFile. That won't solve the problem, though. Could you post some more, like the function definitions (from an Extern block, presumably)? |
| ||
Here is everything I have so far. It's not much but it's a start. It's for OSX. I'm going to try to make it work on windows later when I have something up and running. test code: And finaly, the tutorial I'm following to learn OpenAL: http://www.devmaster.net/articles/openal-tutorials/lesson1.php Edit: Never used the $z thing before. Is this correct? Function alutLoadWAVFile( path$z, '... and the rest It compiles anyway and, as you said , didn't solve the crashing issue. :) Edit2: Also, OpenAL works just fine if I write a small test in C using the source from that tutorial. |
| ||
*bump?* No one able to help me? |
| ||
As far as I know a byte ptr is used to represent any kind of pointer in C including/especially void* . Your function definition is corrent for using $z, and when you call the function you can use a normal string literal and just drop the .toCString(). Your problem, or a problem, is you're trying to pass an array to C. Since Max's arrays are objects you'll have to pass arrays as pointers to the first element. alSourcefv(speaker, AL_POSITION, varptr(SpeakerPos[0])) alSourcefv(speaker, AL_VELOCITY, varptr(SpeakerVel[0])) If C wants a float[] instead of a float* I don't know if that'd work. |
| ||
Been busy with my new job, but here's the reply. Changed the code but it still crashes at alutLoadWAVFile for some strange reason. :( |