Changeset 9805 in orxonox.OLD for branches/new_class_id/src/lib
- Timestamp:
- Sep 24, 2006, 3:21:12 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/lang/base_object.cc
r9730 r9805 45 45 for (it = this->_classes.begin(); it != this->_classes.end(); ++it) 46 46 { 47 PRINTF(5)("DELETING OBJECT %s::%s FROM %s\n", this->getClassCName(), getCName(), (*it)._objectList->name().c_str()); 47 48 (*it)._objectList->unregisterObject((*it)._iterator); 48 49 delete (*it)._iterator; -
branches/new_class_id/src/lib/lang/object_list.cc
r9757 r9805 272 272 ++it) 273 273 { 274 printf(" + %s::%s \n", (*it)->getClassCName(), (*it)->getCName());274 printf(" + %s::%s (%p)\n", (*it)->getClassCName(), (*it)->getCName(), (*it)); 275 275 } 276 276 } -
branches/new_class_id/src/lib/shell/some_shell_commands.cc
r9800 r9805 67 67 ->setAlias("orxoquit"); 68 68 69 #include "object_list.h" 70 SHELL_COMMAND_STATIC(debugAll, ObjectListBase, &ObjectListBase::debugAll); -
branches/new_class_id/src/lib/sound/sound_buffer.cc
r9804 r9805 20 20 namespace OrxSound 21 21 { 22 ObjectListDefinition(SoundBuffer);23 22 ////////////////// 24 23 /* SOUND-BUFFER */ 25 24 ////////////////// 26 25 SoundBuffer::SoundBuffer() 27 : data(new SoundBufferData)26 : data(new SoundBufferData) 28 27 { 29 this->registerObject(this, SoundBuffer::_objectList);30 28 } 31 29 /** … … 34 32 */ 35 33 SoundBuffer::SoundBuffer(const std::string& fileName) 36 : data(new SoundBufferData)34 : data(new SoundBufferData) 37 35 { 38 this->registerObject(this, SoundBuffer::_objectList);39 this->setName(fileName);40 41 36 this->load(fileName); 42 37 } 38 39 SoundBuffer::SoundBuffer(const SoundBuffer& buffer) 40 : data(buffer.data) 41 { } 42 43 SoundBuffer::SoundBuffer(const SoundBufferData::Pointer& dataPointer) 44 : data(dataPointer) 45 { }; 43 46 } -
branches/new_class_id/src/lib/sound/sound_buffer.h
r9804 r9805 7 7 #define _SOUND_BUFFER_H 8 8 9 #include "base_object.h"10 #include "alincl.h"11 12 9 #include "sound_buffer_data.h" 13 10 … … 15 12 { 16 13 //! A class that represents a datastructure to play Sounds. 17 class SoundBuffer : public BaseObject14 class SoundBuffer 18 15 { 19 ObjectListDeclaration(SoundBuffer);20 16 public: 21 17 SoundBuffer(); 22 SoundBuffer(const SoundBuffer& buffer) { this->data = buffer.data; }23 SoundBuffer(const SoundBufferData::Pointer& dataPointer) { this->data = dataPointer; };18 SoundBuffer(const SoundBuffer& buffer); 19 SoundBuffer(const SoundBufferData::Pointer& dataPointer); 24 20 SoundBuffer(const std::string& fileName); 21 22 bool operator==(const SoundBuffer& buffer) const {return this->data == buffer.data; }; 25 23 26 24 /** @see SoundBufferData::load */ … … 33 31 /** @returns the ID of the buffer used in this SoundBuffer */ 34 32 inline ALuint getID() const { return this->data->getID(); } 33 inline bool loaded() const { return this->data->loaded(); } 35 34 36 35 /** @returns the DataPointer */ … … 38 37 /** @param dataPointer the data to acquire @brief Buffer shall acquire dataPointers data */ 39 38 void acquireData(const SoundBufferData::Pointer& dataPointer) { data = dataPointer; }; 39 40 40 private: 41 SoundBufferData::Pointer data; 41 SoundBufferData::Pointer data; //!< Pointer to the Stored Data 42 42 }; 43 43 } -
branches/new_class_id/src/lib/sound/sound_buffer_data.cc
r9803 r9805 50 50 this->size = 0; 51 51 this->loop = AL_FALSE; 52 53 52 this->bLoaded = false; 54 53 } 55 54 … … 112 111 SDL_FreeWAV(wavBuffer); 113 112 if (SoundEngine::checkError("Could not load Wave file", __LINE__)) 113 { 114 this->bLoaded = true; 114 115 return true; 116 } 115 117 else 116 118 return false; … … 160 162 return false; 161 163 164 this->bLoaded = true; 162 165 return true ; 163 164 166 } 165 167 -
branches/new_class_id/src/lib/sound/sound_buffer_data.h
r9803 r9805 33 33 /** @returns the ID of the buffer used in this SoundBuffer */ 34 34 inline ALuint getID() const { return this->bufferID; } 35 inline bool loaded() const { return bLoaded; }; 35 36 36 37 private: … … 42 43 ALsizei size; //!< The size of the Buffer. 43 44 ALboolean loop; //!< loop information. 45 bool bLoaded; //!< If the Sound was loaded this is true. 44 46 }; 45 47 } -
branches/new_class_id/src/lib/sound/sound_engine.cc
r9721 r9805 26 26 #include "util/preferences.h" 27 27 #include "globals.h" 28 #include "resource_sound_buffer.h" 28 29 29 30 namespace OrxSound … … 119 120 SoundSource* SoundEngine::createSource(const std::string& fileName, PNode* sourceNode) 120 121 { 121 SoundBuffer * buffer = NULL;122 SoundBuffer buffer; 122 123 if (!fileName.empty()) 123 124 { 124 buffer = (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL);125 if ( buffer == NULL)125 buffer = ResourceSoundBuffer(fileName); 126 if (!buffer.loaded()) 126 127 PRINTF(2)("Wav-Sound %s could not be loaded onto new Source\n", fileName.c_str()); 127 128 } … … 215 216 if(play == AL_PLAYING) 216 217 { 217 218 if (likely((*sourceIT)->getNode() != NULL)) 218 219 { 219 220 alSource3f((*sourceIT)->getID(), AL_POSITION, -
branches/new_class_id/src/lib/sound/sound_source.cc
r9715 r9805 19 19 #include "sound_engine.h" 20 20 21 #include "alincl.h"22 21 #include "compiler.h" 23 22 #include "debug.h" … … 29 28 * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer 30 29 */ 31 SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer *buffer)30 SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer& buffer) 32 31 { 33 32 this->registerObject(this, SoundSource::_objectList); … … 120 119 void SoundSource::play() 121 120 { 122 if (this-> buffer && this->retrieveSource())121 if (this->retrieveSource()) 123 122 { 124 123 if (this->bPlay) 125 124 alSourceStop(this->sourceID); 126 125 127 alSourcei (this->sourceID, AL_BUFFER, this->buffer ->getID());126 alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID()); 128 127 alSourcei (this->sourceID, AL_LOOPING, AL_FALSE); 129 128 alSourcef (this->sourceID, AL_GAIN, 1); … … 141 140 * @param buffer the buffer to play back on this Source 142 141 */ 143 void SoundSource::play(const SoundBuffer *buffer)142 void SoundSource::play(const SoundBuffer& buffer) 144 143 { 145 144 if (!this->retrieveSource()) … … 150 149 151 150 alSourceStop(this->sourceID); 152 alSourcei (this->sourceID, AL_BUFFER, buffer ->getID());151 alSourcei (this->sourceID, AL_BUFFER, buffer.getID()); 153 152 alSourcei (this->sourceID, AL_LOOPING, AL_FALSE); 154 153 alSourcef (this->sourceID, AL_GAIN, 1); … … 156 155 alSourcePlay(this->sourceID); 157 156 158 if (unlikely(this->buffer != NULL))159 alSourcei (this->sourceID, AL_BUFFER, this->buffer ->getID());157 if (unlikely(this->buffer.getID() != 0)) 158 alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID()); 160 159 this->bPlay = true; 161 160 … … 170 169 * @param gain the gain of the sound buffer 171 170 */ 172 void SoundSource::play(const SoundBuffer *buffer, float gain)171 void SoundSource::play(const SoundBuffer& buffer, float gain) 173 172 { 174 173 if (!this->retrieveSource()) … … 179 178 180 179 alSourceStop(this->sourceID); 181 alSourcei (this->sourceID, AL_BUFFER, buffer ->getID());180 alSourcei (this->sourceID, AL_BUFFER, buffer.getID()); 182 181 alSourcei (this->sourceID, AL_LOOPING, AL_FALSE); 183 182 alSourcef (this->sourceID, AL_GAIN, gain); … … 185 184 alSourcePlay(this->sourceID); 186 185 187 if (unlikely(this->buffer != NULL))188 alSourcei (this->sourceID, AL_BUFFER, this->buffer ->getID());186 if (unlikely(this->buffer.getID() != 0)) 187 alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID()); 189 188 this->bPlay = true; 190 189 … … 199 198 * @param loop if true, sound gets looped 200 199 */ 201 void SoundSource::play(const SoundBuffer *buffer, float gain, bool loop)200 void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop) 202 201 { 203 202 if (!this->retrieveSource()) … … 208 207 209 208 alSourceStop(this->sourceID); 210 alSourcei (this->sourceID, AL_BUFFER, buffer ->getID());209 alSourcei (this->sourceID, AL_BUFFER, buffer.getID()); 211 210 212 211 if (loop) … … 219 218 alSourcePlay(this->sourceID); 220 219 221 if (unlikely(this->buffer != NULL))222 alSourcei (this->sourceID, AL_BUFFER, this->buffer ->getID());220 if (unlikely(this->buffer.getID() != 0)) 221 alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID()); 223 222 this->bPlay = true; 224 223 … … 232 231 * @param gain the new gain value 233 232 */ 234 void SoundSource::gain(const SoundBuffer *buffer, float gain)233 void SoundSource::gain(const SoundBuffer& buffer, float gain) 235 234 { 236 235 // alSourcei (this->sourceID, AL_BUFFER, buffer->getID()); … … 347 346 * @param duration time perios to fade in 348 347 */ 349 void SoundSource::fadein(const SoundBuffer *buffer, ALfloat duration)348 void SoundSource::fadein(const SoundBuffer& buffer, ALfloat duration) 350 349 { 351 350 //if (this->buffer && this->retrieveSource()) -
branches/new_class_id/src/lib/sound/sound_source.h
r9715 r9805 8 8 9 9 #include "base_object.h" 10 #include "sound_buffer.h" 10 11 #include "alincl.h" 11 12 … … 14 15 namespace OrxSound 15 16 { 16 class SoundBuffer;17 17 //! A class that represents a SoundSource 18 18 class SoundSource : public BaseObject … … 20 20 ObjectListDeclaration(SoundSource); 21 21 public: 22 SoundSource(const PNode* sourceNode = NULL, const SoundBuffer * buffer = NULL);22 SoundSource(const PNode* sourceNode = NULL, const SoundBuffer& buffer = SoundBuffer()); 23 23 SoundSource(const SoundSource& source); 24 24 SoundSource& operator=(const SoundSource& source); … … 29 29 // user interaction 30 30 void play(); 31 void play(const SoundBuffer *buffer);32 void play(const SoundBuffer *buffer, float gain);33 void play(const SoundBuffer *buffer, float gain, bool loop);31 void play(const SoundBuffer& buffer); 32 void play(const SoundBuffer& buffer, float gain); 33 void play(const SoundBuffer& buffer, float gain, bool loop); 34 34 35 void gain(const SoundBuffer *buffer, float gain);35 void gain(const SoundBuffer& buffer, float gain); 36 36 37 37 void stop(); 38 38 void pause(); 39 39 void rewind(); 40 void fadein(const SoundBuffer *buffer, ALfloat duration);40 void fadein(const SoundBuffer& buffer, ALfloat duration); 41 41 42 42 // development functions … … 47 47 void setSourceNode(const PNode* sourceNode); 48 48 /** @returns the SoundBuffer of this Source */ 49 inline const SoundBuffer *getBuffer() const { return this->buffer; };49 inline const SoundBuffer& getBuffer() const { return this->buffer; }; 50 50 /** @returns the SourceNode of this Source */ 51 51 inline const PNode* getNode() const { return this->sourceNode; }; … … 66 66 bool resident; //!< If the alSource should be resident (if true, the alSource will be returned on deletion). 67 67 ALuint sourceID; //!< The ID of the Source 68 const SoundBuffer*buffer; //!< The buffer to play in this source.68 SoundBuffer buffer; //!< The buffer to play in this source. 69 69 const PNode* sourceNode; //!< The SourceNode representing the position/velocity... of this source. 70 70 }; -
branches/new_class_id/src/lib/util/loading/resource_manager.cc
r9721 r9805 442 442 case WAV: 443 443 if(File(fullName).isFile()) 444 tmpResource->pointer = new OrxSound::SoundBuffer(fullName);444 // tmpResource->pointer = new OrxSound::SoundBuffer(fullName); 445 445 break; 446 446 case OGG:
Note: See TracChangeset
for help on using the changeset viewer.