瀏覽代碼

see previous commit

mikymod 12 年之前
父節點
當前提交
8ad9e7e910
共有 2 個文件被更改,包括 10 次插入34 次删除
  1. 8 31
      engine/renderers/al/ALRenderer.cpp
  2. 2 3
      engine/renderers/al/ALRenderer.h

+ 8 - 31
engine/renderers/al/ALRenderer.cpp

@@ -199,7 +199,7 @@ void ALRenderer::destroy_buffer(SoundBufferId id)
 
 
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-SoundSourceId ALRenderer::create_source(const Vec3& pos, const Vec3& vel, const Vec3& dir, const bool loop)
+SoundSourceId ALRenderer::create_source()
 {
 {
 	SoundSourceId id = m_sources_id_table.create();
 	SoundSourceId id = m_sources_id_table.create();
 
 
@@ -214,30 +214,19 @@ SoundSourceId ALRenderer::create_source(const Vec3& pos, const Vec3& vel, const
 
 
 	AL_CHECK(alSourcef(al_source.id, AL_MAX_DISTANCE, 1000.0f));
 	AL_CHECK(alSourcef(al_source.id, AL_MAX_DISTANCE, 1000.0f));
 
 
-	AL_CHECK(alSource3f(al_source.id, AL_POSITION, pos.x, pos.y, pos.z));
-
-	AL_CHECK(alSource3f(al_source.id, AL_VELOCITY, vel.x, vel.y, vel.z));
-
-	AL_CHECK(alSource3f(al_source.id, AL_DIRECTION, dir.x, dir.y, dir.z));
-
-	if (loop)
-	{
-		AL_CHECK(alSourcei(al_source.id, AL_LOOPING, AL_TRUE));
-	}
-	else
-	{
-		AL_CHECK(alSourcei(al_source.id, AL_LOOPING, AL_FALSE));
-	}
-
 	return id;
 	return id;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void ALRenderer::play_source(SoundSourceId id)
+void ALRenderer::play_source(SoundSourceId sid, SoundBufferId bid)
 {
 {
-	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
+	CE_ASSERT(m_sources_id_table.has(sid), "SoundSource does not exist");
+	CE_ASSERT(m_buffers_id_table.has(bid), "SoundBuffer does not exist");
 
 
-	SoundSource& al_source = m_sources[id.index];
+	SoundSource& al_source = m_sources[sid.index];
+	SoundBuffer& al_buffer = m_buffers[bid.index];
+
+	alSourcei(al_source.id, AL_BUFFER, al_buffer.id);
 
 
 	AL_CHECK(alSourcePlay(al_source.id));
 	AL_CHECK(alSourcePlay(al_source.id));
 }
 }
@@ -267,18 +256,6 @@ void ALRenderer::destroy_source(SoundSourceId id)
 	m_sources_id_table.destroy(id);
 	m_sources_id_table.destroy(id);
 }
 }
 
 
-//-----------------------------------------------------------------------------
-void ALRenderer::bind_buffer(SoundSourceId sid, SoundBufferId bid)
-{
-	CE_ASSERT(m_sources_id_table.has(sid), "SoundSource does not exist");
-	CE_ASSERT(m_buffers_id_table.has(bid), "SoundBuffer does not exist");
-
-	SoundSource& al_source = m_sources[sid.index];
-	SoundBuffer& al_buffer = m_buffers[bid.index];
-
-	alSourcei(al_source.id, AL_BUFFER, al_buffer.id);
-}
-
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void ALRenderer::set_source_min_distance(SoundSourceId id, const float min_distance)
 void ALRenderer::set_source_min_distance(SoundSourceId id, const float min_distance)
 {
 {

+ 2 - 3
engine/renderers/al/ALRenderer.h

@@ -29,7 +29,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <AL/al.h>
 #include <AL/al.h>
 #include <AL/alc.h>
 #include <AL/alc.h>
 
 
-#include "Types.h"
 #include "AudioRenderer.h"
 #include "AudioRenderer.h"
 #include "HeapAllocator.h"
 #include "HeapAllocator.h"
 #include "Vec3.h"
 #include "Vec3.h"
@@ -68,9 +67,9 @@ public:
 
 
 	void					destroy_buffer(SoundBufferId id);
 	void					destroy_buffer(SoundBufferId id);
 
 
-	SoundSourceId			create_source(const Vec3& pos, const Vec3& vel, const Vec3& dir, const bool loop);
+	SoundSourceId			create_source();
 
 
-	void 					play_source(SoundSourceId id);
+	void 					play_source(SoundSourceId sid, SoundBufferId bid);
 
 
 	void					pause_source(SoundSourceId id);
 	void					pause_source(SoundSourceId id);