Bladeren bron

ALRenderer should be const correct

mikymod 12 jaren geleden
bovenliggende
commit
4069c86722
2 gewijzigde bestanden met toevoegingen van 29 en 29 verwijderingen
  1. 18 18
      engine/renderers/al/ALRenderer.cpp
  2. 11 11
      engine/renderers/al/ALRenderer.h

+ 18 - 18
engine/renderers/al/ALRenderer.cpp

@@ -103,19 +103,19 @@ void ALRenderer::shutdown()
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_listener(Vec3& position, Vec3& velocity, Vec3& orientation_up, Vec3& orientation_at)
+void ALRenderer::set_listener(const Vec3& pos, const Vec3& vel, const Vec3& or_up, const Vec3& or_at) const
 {
-	AL_CHECK(alListener3f(AL_POSITION, position.x, position.y, position.z));
-	AL_CHECK(alListener3f(AL_VELOCITY, velocity.x, velocity.y, velocity.z));
+	AL_CHECK(alListener3f(AL_POSITION, pos.x, pos.y, pos.z));
+	AL_CHECK(alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z));
 
-	ALfloat orientation[] = { orientation_up.x, orientation_up.y, orientation_up.z,
-								orientation_at.x, orientation_at.y, orientation_at.z };
+	ALfloat orientation[] = { or_up.x, or_up.y, or_up.z,
+								or_at.x, or_at.y, or_at.z };
 
 	AL_CHECK(alListenerfv(AL_ORIENTATION, orientation));
 }
 
 //-----------------------------------------------------------------------------
-SoundBufferId ALRenderer::create_buffer(const void* data, uint32_t size, uint32_t sample_rate, uint32_t channels, uint32_t bxs)
+SoundBufferId ALRenderer::create_buffer(const void* data, const uint32_t size, const uint32_t sample_rate, const uint32_t channels, const uint32_t bxs)
 {
 	SoundBufferId id = m_buffers_id_table.create();
 
@@ -188,7 +188,7 @@ void ALRenderer::destroy_buffer(SoundBufferId id)
 
 
 //-----------------------------------------------------------------------------
-SoundSourceId ALRenderer::create_source(Vec3& position, Vec3& velocity, Vec3& direction, bool loop)
+SoundSourceId ALRenderer::create_source(const Vec3& pos, const Vec3& vel, const Vec3& dir, const bool loop)
 {
 	SoundSourceId id = m_sources_id_table.create();
 
@@ -203,11 +203,11 @@ SoundSourceId ALRenderer::create_source(Vec3& position, Vec3& velocity, Vec3& di
 
 	AL_CHECK(alSourcef(al_source.id, AL_MAX_DISTANCE, 1000.0f));
 
-	AL_CHECK(alSource3f(al_source.id, AL_POSITION, position.x, position.y, position.z));
+	AL_CHECK(alSource3f(al_source.id, AL_POSITION, pos.x, pos.y, pos.z));
 
-	AL_CHECK(alSource3f(al_source.id, AL_VELOCITY, velocity.x, velocity.y, velocity.z));
+	AL_CHECK(alSource3f(al_source.id, AL_VELOCITY, vel.x, vel.y, vel.z));
 
-	AL_CHECK(alSource3f(al_source.id, AL_DIRECTION, direction.x, direction.y, direction.z));
+	AL_CHECK(alSource3f(al_source.id, AL_DIRECTION, dir.x, dir.y, dir.z));
 
 	if (loop)
 	{
@@ -267,7 +267,7 @@ void ALRenderer::bind_buffer(SoundSourceId sid, SoundBufferId bid)
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_source_min_distance(SoundSourceId id, float min_distance)
+void ALRenderer::set_source_min_distance(SoundSourceId id, const float min_distance)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 
@@ -277,7 +277,7 @@ void ALRenderer::set_source_min_distance(SoundSourceId id, float min_distance)
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_source_max_distance(SoundSourceId id, float max_distance)
+void ALRenderer::set_source_max_distance(SoundSourceId id, const float max_distance)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 
@@ -287,7 +287,7 @@ void ALRenderer::set_source_max_distance(SoundSourceId id, float max_distance)
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_source_position(SoundSourceId id, Vec3& pos)
+void ALRenderer::set_source_position(SoundSourceId id, const Vec3& pos)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 
@@ -297,7 +297,7 @@ void ALRenderer::set_source_position(SoundSourceId id, Vec3& pos)
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_source_velocity(SoundSourceId id, Vec3& vel)
+void ALRenderer::set_source_velocity(SoundSourceId id, const Vec3& vel)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 
@@ -307,7 +307,7 @@ void ALRenderer::set_source_velocity(SoundSourceId id, Vec3& vel)
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_source_direction(SoundSourceId id, Vec3& dir)
+void ALRenderer::set_source_direction(SoundSourceId id, const Vec3& dir)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 
@@ -316,7 +316,7 @@ void ALRenderer::set_source_direction(SoundSourceId id, Vec3& dir)
 	AL_CHECK(alSource3f(al_source.id, AL_DIRECTION, dir.x, dir.y, dir.z));
 }
 
-void ALRenderer::set_source_pitch(SoundSourceId id, float pitch)
+void ALRenderer::set_source_pitch(SoundSourceId id, const float pitch)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 
@@ -326,7 +326,7 @@ void ALRenderer::set_source_pitch(SoundSourceId id, float pitch)
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_source_gain(SoundSourceId id, float gain)
+void ALRenderer::set_source_gain(SoundSourceId id, const float gain)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 
@@ -336,7 +336,7 @@ void ALRenderer::set_source_gain(SoundSourceId id, float gain)
 }
 
 //-----------------------------------------------------------------------------
-void ALRenderer::set_source_rolloff(SoundSourceId id, float rolloff)
+void ALRenderer::set_source_rolloff(SoundSourceId id, const float rolloff)
 {
 	CE_ASSERT(m_sources_id_table.has(id), "SoundSource does not exist");
 

+ 11 - 11
engine/renderers/al/ALRenderer.h

@@ -85,21 +85,21 @@ public:
 
 	/// Sets listener parameters. In OpenAL, @a position affects audibility of sounds, 
 	/// @a velocity affects doppler shift and @a orientation affects how a sound could be heard
-	void					set_listener(Vec3& position, Vec3& velocity, Vec3& orientation_up, Vec3& orientation_at);
+	void					set_listener(const Vec3& pos, const Vec3& vel, const Vec3& or_up, const Vec3& or_at) const;
 
 	/// Creates AL buffer's @a data, with a specific @a size, which contains sound raw data.
 	/// More parameters must be specified, such as @a sample_rate, that is the number of sample per unit of time 
 	/// taken from a continuous signal to make a discrete signal, @a channels which specifies if sound is mono or stereo and @ bxs
 	/// (bits per sample) which specifies the magnitude of samples information.
 	/// N.B: stereo sound can not be attenuated
-	SoundBufferId			create_buffer(const void* data, uint32_t size, uint32_t sample_rate, uint32_t channels, uint32_t bxs);
+	SoundBufferId			create_buffer(const void* data, const uint32_t size, const uint32_t sample_rate, const uint32_t channels, const uint32_t bxs);
 
 	/// Destroys AL buffer
 	void					destroy_buffer(SoundBufferId id);
 
 	/// Creates AL source of sound at the given @position in 3D space
 	/// @a velocity affects doppler shift and @a direction affects how a sound could be heard
-	SoundSourceId			create_source(Vec3& position, Vec3& velocity, Vec3& direction, bool loop);
+	SoundSourceId			create_source(const Vec3& pos, const Vec3& vel, const Vec3& dir, const bool loop);
 
 	/// Plays a sound, specified by @a id, previously created
 	void 					play_source(SoundSourceId id);
@@ -114,22 +114,22 @@ public:
 	void					bind_buffer(SoundSourceId sid, SoundBufferId bid);
 	///	Sets source's @a min_distance. From @a min_distance to @a max_distance, sound
 	/// scales from full volume to silence
-	void					set_source_min_distance(SoundSourceId id, float min_distance);
+	void					set_source_min_distance(SoundSourceId id,  const float min_distance);
 	///	Sets source's @a max_distance. From @a min_distance to @a max_distance, sound
 	/// scales from full volume to silence
-	void					set_source_max_distance(SoundSourceId id, float max_distance);
+	void					set_source_max_distance(SoundSourceId id,  const float max_distance);
 	/// Sets source's @a position. It affects sound audibility
-	void					set_source_position(SoundSourceId id, Vec3& pos);
+	void					set_source_position(SoundSourceId id, const Vec3& pos);
 	/// Sets source's @a velocity. It affects doppler shift
-	void					set_source_velocity(SoundSourceId id, Vec3& vel);
+	void					set_source_velocity(SoundSourceId id, const Vec3& vel);
 	/// Sets source's @a direction. It affects how a sound could be heard
-	void					set_source_direction(SoundSourceId id, Vec3& dir);
+	void					set_source_direction(SoundSourceId id, const Vec3& dir);
 	/// Sets source's @a pitch.
-	void					set_source_pitch(SoundSourceId id, float pitch);
+	void					set_source_pitch(SoundSourceId id, const float pitch);
 	/// Sets source's @a gain, that is measure sound's amplification
-	void 					set_source_gain(SoundSourceId id, float gain);
+	void 					set_source_gain(SoundSourceId id, const float gain);
 	/// Sets source's @a rolloff factor. Greater it is, greater sound's attenuation is
-	void					set_source_rolloff(SoundSourceId id, float rolloff);
+	void					set_source_rolloff(SoundSourceId id, const float rolloff);
 	/// Is source #@a id playing?
 	bool					source_playing(SoundSourceId id);