地狱程序员,我目前正在用LWJGL学习OpenAL,我无法理解这些代码行是什么(评论代表了我认为他们正在做的事情,请你告诉我正确的事情吗?我已经阅读了Javadocs和我不明白一件事。我用Google搜索并用Google搜索。)
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
答案 0 :(得分:1)
正如您在此处所见: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)