gpt4 book ai didi

Java - LWJGL - OpenAL - 理解一些代码

转载 作者:行者123 更新时间:2023-12-01 13:41:47 25 4
gpt4 key购买 nike

hell 编码员,我目前正在使用 LWJGL 学习 OpenAL,我无法理解这些代码行的作用(这些注释代表了我认为他们正在做的事情,您可以告诉我正确的事情吗?我已经阅读了 Javadocs 和我什么都不明白。我用谷歌搜索了又搜索。)

WaveData data = WaveData.create(new BufferedInputStream(new FileInputStream("res/sound.wav")));//generate data from the file (binary data?)
int buffer = alGenBuffers();//generate an empty buffer
alBufferData(buffer,data.format,data.data,data.samplerate);//assign previously generated data to buffer
data.dispose();//what does this line do? (I can not understand what dispose means. Throw away or give the data?)
int source = alGenSources();//generate source(What does source mean here?)
alSourcei(source , AL_BUFFER, buffer);//set a property the the source. arg # 1 is the property type , arg # 0 is the source to set the property at and arg # 3 is the value to pass as a property.

请帮助我成为一名更好的程序员。 问候 ~ Teo

最佳答案

正如您在这里看到的:https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/util/WaveData.java data.dispose() 清除 ByteBuffer,它不会丢弃数据,而是重置读/写位置(参见 http://docs.oracle.com/javase/7/docs/api/java/nio/Buffer.html#clear%28%29 )

关于Java - LWJGL - OpenAL - 理解一些代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20690011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com