本文整理汇总了Java中org.lwjgl.openal.ALC10.alcDestroyContext方法的典型用法代码示例。如果您正苦于以下问题:Java ALC10.alcDestroyContext方法的具体用法?Java ALC10.alcDestroyContext怎么用?Java ALC10.alcDestroyContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.openal.ALC10
的用法示例。
在下文中一共展示了ALC10.alcDestroyContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exit
import org.lwjgl.openal.ALC10; //导入方法依赖的package包/类
public void exit(){
channels = null;
ALC10.alcDestroyContext(context);
ALC10.alcCloseDevice(device);
}
示例2: main
import org.lwjgl.openal.ALC10; //导入方法依赖的package包/类
public static void main(String[] args) {
System.setProperty("org.lwjgl.librarypath", new File("natives/windows").getAbsolutePath());
String deviceName = ALC10.alcGetString(0, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER);
long device = ALC10.alcOpenDevice(deviceName);
long context = ALC10.alcCreateContext(device, new int[] {0});
ALC10.alcMakeContextCurrent(context);
ALCCapabilities alcCaps = ALC.createCapabilities(device);
ALCapabilities alCaps = AL.createCapabilities(alcCaps);
if (alCaps.OpenAL10) {
String file = "C:\\Users\\Isaac\\Desktop\\workspace\\assets\\audio\\gunshot2.ogg";
MemoryStack.stackPush();
IntBuffer channelsBuf = MemoryStack.stackMallocInt(1);
MemoryStack.stackPush();
IntBuffer sampleRateBuf = MemoryStack.stackMallocInt(1);
ShortBuffer audioBuffer = STBVorbis.stb_vorbis_decode_filename(file, channelsBuf, sampleRateBuf);
int channels = channelsBuf.get();
int sampleRate = sampleRateBuf.get();
MemoryStack.stackPop();
MemoryStack.stackPop();
int format = -1;
if (channels == 1) {
format = AL10.AL_FORMAT_MONO16;
} else if (channels == 2) {
format = AL10.AL_FORMAT_STEREO16;
}
int buffer = AL10.alGenBuffers();
AL10.alBufferData(buffer, format, audioBuffer, sampleRate);
Stdlib.free(audioBuffer);
int[] sources = new int[4];
AL10.alGenSources(sources);
for (int source : sources) {
AL10.alSourcei(source, AL10.AL_BUFFER, buffer);
AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_TRUE);
}
float length = (float) (AL10.alGetBufferi(buffer, AL10.AL_SIZE) / 2 / channels) / sampleRate;
try {
AL10.alSourcePlay(sources[0]);
Thread.sleep((long) (length * 250));
AL10.alSourcePlay(sources[1]);
Thread.sleep((long) (length * 250));
AL10.alSourcePlay(sources[2]);
Thread.sleep((long) (length * 250));
AL10.alSourcePlay(sources[3]);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {}
new Scanner(System.in).nextLine();
AL10.alSourceStopv(sources);
AL10.alDeleteSources(sources);
AL10.alDeleteBuffers(buffer);
}
ALC10.alcDestroyContext(context);
ALC10.alcCloseDevice(device);
ALC.destroy();
}
示例3: onDestroy
import org.lwjgl.openal.ALC10; //导入方法依赖的package包/类
@Override
public void onDestroy() {
ALC10.alcDestroyContext(this._id);
this._device.destroy();
}
示例4: close
import org.lwjgl.openal.ALC10; //导入方法依赖的package包/类
@Override
public void close() {
ALC10.alcDestroyContext(this.context);
ALC10.alcCloseDevice(this.device);
}