2013-12-19 4 views
0

지옥 코더는 현재 LWJGL로 OpenAL을 연구 중이며이 코드 라인이 무엇을하는지 이해할 수 없습니다 (주석은 내가 생각하는 바를 나타냅니다. 올바른 일이? 나는 Javadoc과를 읽었으며 일을 이해하지 않았다. 내가 봤와 봤.)Java - LWJGL - OpenAL - 일부 코드 이해

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. 

이 나를 더 나은 프로그래머가 될 수 있도록하시기 바랍니다. 감사합니다 ~ 테오

답변

1
+0

어떤 다른 사람에 대한 읽기 데이터를 폐기하지만 재설정하지 않는 ByteBuffer를 지워? 따라서 버퍼에 읽기/쓰기 전에 dispose()를 수행하십시오. 그런데 data.dispose()없이 테스트했습니다. 라인이 완벽하게 작동했습니다. – user3029101

+1

예,이 사용 사례에서는 잘 작동합니다. 그러나 응용 프로그램의 다른 곳에서 버퍼를 다시 스트리밍하려는 경우를 상상해보십시오. 시작부터 시작하고 싶지만 버퍼의 내부 위치가 다른 곳을 가리키고 있습니다. 따라서 data.dispose에 대한 호출. – Peter

+0

alBufferData()를 수행 한 후 또는 다시 사용하기 전에 처분 하시겠습니까? – user3029101