|
发表于 2006-11-29 13:17:00
|
显示全部楼层
Re:请教:怎么得到Device的名字?
OpenAL 1.1之后有一个枚举当前系统设备的扩展。
if(!alcIsExtensionPresent)return;
if(!alcIsExtensionPresent(NULL,"ALC_ENUMERATION_EXT"))return;
char *devices;
const char *actual_devicename;
devices=(char *)alcGetString(NULL,ALC_DEVICE_SPECIFIER);
//default_devicename=(char *)alcGetString(NULL,ALC_DEFAULT_DEVICE_SPECIFIER);
while(*devices)
{
ALCdevice *device=alcOpenDevice(devices);
if(device)
{
ALCcontext *context=alcCreateContext(device,NULL);
if(context)
{
alcMakeContextCurrent(context);
actual_devicename=alcGetString(device,ALC_DEVICE_SPECIFIER);
int major,minor;
alcGetIntegerv(device,ALC_MAJOR_VERSION,sizeof(int),&major);
alcGetIntegerv(device,ALC_MINOR_VERSION,sizeof(int),&minor);
PutInfo("OpenAL设备: <%s>,支持OpenAL特性版本: %d.%d",actual_devicename,major,minor);
alcDestroyContext(context);
}
alcCloseDevice(device);
}
devices+=strlen(devices)+1;
} |
|