|
dev.gamez.lv Latvian Game Developers Community
|
View previous topic :: View next topic |
Author |
Message |
elvman Indago Uzvarētājs
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Thu Jul 06, 2006 8:41 pm Post subject: OpenAL probleema |
|
Te buus kods,kas 100% straadaa ar DirectSound,bet nestraadaa ar OpenAL:
Code: | CWaveFile* pWaveFile=NULL;
DWORD dwWavDataRead= 0; // Amount of data read from the wav file
pWaveFile = new CWaveFile();
if (FAILED(pWaveFile->Open(sFilename, NULL, WAVEFILE_READ )))
{
return false;
}
ALenum format=pWaveFile->GetFormat()->wFormatTag;
ALsizei size=pWaveFile->GetSize();
ALvoid* data=new BYTE[size];
ALsizei freq=pWaveFile->GetFormat()->nSamplesPerSec;
if (FAILED(pWaveFile->ResetFile()))
return false;
if (FAILED(pWaveFile->Read((BYTE*)data,size,&dwWavDataRead)))
return false;
alGenBuffers(1,&m_unBuffer);
alBufferData(m_unBuffer, format, data, size, freq);
//--SHEIT KODS APRAUJAS
alGenSources(1,&m_unSource);
alSourcei(m_unSource,AL_BUFFER,m_unBuffer); |
Kods apstajas pie alBufferData.pWaveFile->GetFormat() ir WAVEFORMATEX struktuura.Nesaprotu.Varbut es freq ir kautkaa jaaprekjina?Vai kadi citi gljuki? _________________ long time; /* know C */ |
|
Back to top |
|
|
elvman Indago Uzvarētājs
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Thu Jul 06, 2006 8:53 pm Post subject: |
|
Atradu kljuudu.Formaats OpenAL ir savs(ne taads,ka wave failaa).Te buus kods,kas jaapievieno:
Code: | switch(pWaveFile->GetFormat()->wBitsPerSample)
{
case 8:
1 == pWaveFile->GetFormat()->nChannels ? (format) = AL_FORMAT_MONO8 : AL_FORMAT_STEREO8;
break;
case 16:
1 == pWaveFile->GetFormat()->nChannels ? (format) = AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
break;
default:
return false;
} |
_________________ long time; /* know C */ |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Thu Jul 06, 2006 8:53 pm Post subject: |
|
Vai tad OpenAL formats sakrīt ar WAVEFILEEX wFormatTag?
Manuprāt OpenAL ir savi iekšējie formāti (līdzīgi kā OpenGL GL_RGB, GL_RGBA, ...), kuri nav tie paši WAV faila formāti.
OpenAL ir:
AL_FORMAT_MONO8
AL_FORMAT_MONO16
AL_FORMAT_STEREO8
AL_FORMAT_STEREO16
Tev vajag pašam vienu no tiem izsecināt no wav faila formāta un padot alBufferData fjai.
Edit: heh.. dažas sekundes par vēlu. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|