游戏开发论坛

 找回密码
 立即注册
搜索
查看: 5630|回复: 3

请教:怎么得到Device的名字?

[复制链接]

2

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2006-9-8 14:58:00 | 显示全部楼层 |阅读模式
有这么一个语句:
Device = alcOpenDevice((ALubyte*)"DirectSound3D");
这是打开 DirectSound3D 这个Device
还有这么一个语句:
Device = alcOpenDevice(NULL);
这是打开一个默认的设备

我想请教:怎么知道我电脑上的这些Device的Name呢?我怎么知道有
DirectSound3D这个Device呢?
openAL中应该有这样的东西吧:
alcGetNumDevice();      //返回有多少Device
alcGetDeviceName(i);   //返回第i个Device的Name
有没有这样的东东呢?

请多多指点^_^

8

主题

716

帖子

716

积分

高级会员

Rank: 4

积分
716
发表于 2006-9-25 11:24:00 | 显示全部楼层

Re:请教:怎么得到Device的名字?

OpenAL是个high levle and platform independent API
在Windows上通常就是以DirectSound在实现,你可以看NVIDIA和Creative的open source
而device就是指定具体实现,所以NULL是会比较保险
像是能真正意义上的hardware support,目前应该只有Creative的sound card,在它上面,可能你才需要填入如"Creative Device"之类的参数吧

180

主题

3511

帖子

3520

积分

论坛元老

Rank: 8Rank: 8

积分
3520
发表于 2006-11-23 14:08:00 | 显示全部楼层

当然有

Device=alcGetContextsDevice(Context);

2万

主题

2万

帖子

6万

积分

论坛元老

Rank: 8Rank: 8

积分
66489
QQ
发表于 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;
                }
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-2 14:45

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表