介绍了openal的基本用法
ALCfloatsourceTwoPos[] = {-2,0,-2}; ALCfloatsourceTwoVel[] = {1,1,1}; alSourcefv(sourceTwoIndex,AL_POSITION,sourceTwoPos); alSourcefv(sourceTwoIndex,AL_VELOCITY,sourceTwoVel); alSourcei(sourceTwoIndex,AL_LOOPING,AL_TRUE); alSourcef(sourceTwoIndex,AL_GAIN,1); alSourcef(sourceTwoIndex,AL_PITCH,1); // 设置听者的信息 ALCfloatlistenerPos[] = {0,0,-1}; ALCfloatlistenerVel[] = {0,0,0}; ALCfloatlistenerOri[] = {0,0,-1,0,1,0}; alListenerfv(AL_POSITION,listenerPos); alListenerfv(AL_VELOCITY,listenerVel); alListenerfv(AL_ORIENTATION,listenerOri); charchoose = '0'; alSourcePlay(sourceIndex); alSourcePlay(sourceTwoIndex); while (choose != 'q') { choose = getchar(); switch(choose) { case'w': sourcePos[0] -= sourceVel[0]; sourcePos[1] -= sourceVel[1]; sourcePos[2] -= sourceVel[2]; alSourcefv(sourceIndex,AL_POSITION,sourcePos); if (alGetError() != AL_NO_ERROR) { } alSourcei(sourceIndex, AL_SOURCE_RELATIVE, AL_FALSE); break; sourcePos[0] += sourceVel[0]; sourcePos[1] += sourceVel[1]; sourcePos[2] += sourceVel[2]; alSourcefv(sourceIndex,AL_POSITION,sourcePos); if (alGetError() != AL_NO_ERROR) { // 出错 exit(0); case's':
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库OpenAl笔记(7)在线全文阅读。
相关推荐: