Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/sound/resource_sound_buffer.cc @ 9854

Last change on this file since 9854 was 9854, checked in by bensch, 18 years ago

more nice comments, and also updated the KeepLevel loading (if you want to load a Resource to a KeepLevel just append it at loadtime:
eg.:
Texture tex = ResourceTexture(orxonox.png, GL_TEXTURE_2D, GameEnd);
where GameEnd is the KeepLevel as defined in orxonox.cc→initResources()

File size: 1.4 KB
Line 
1
2#include "resource_sound_buffer.h"
3#include "debug.h"
4
5
6namespace OrxSound
7{
8  ObjectListDefinition(ResourceSoundBuffer);
9
10  ResourceSoundBuffer::ResourceSoundBuffer(const std::string& soundName, const Resources::KeepLevel& keepLevel)
11      : SoundBuffer(), Resource(&ResourceSoundBuffer::type)
12  {
13    this->registerObject(this, ResourceSoundBuffer::_objectList);
14    Resources::StorePointer* ptr = this->acquireResource(soundName);
15
16    if (ptr)
17    {
18      assert(!static_cast<ResourceSoundBuffer::SoundBufferResourcePointer*>(ptr)->ptr().isNull());
19      PRINTF(5)("FOUND SOUND: %s\n", soundName.c_str());
20      this->acquireData(static_cast<ResourceSoundBuffer::SoundBufferResourcePointer*>(ptr)->ptr());
21    }
22    else
23    {
24      PRINTF(5)("SOUND NOT FOUND: %s\n", soundName.c_str());
25      std::string fileName = this->Resource::locateFile(soundName);
26      this->SoundBuffer::load(fileName);
27      this->Resource::addResource(new ResourceSoundBuffer::SoundBufferResourcePointer(soundName, keepLevel, this->SoundBuffer::dataPointer()));
28    }
29  }
30
31
32  Resources::tType<ResourceSoundBuffer> ResourceSoundBuffer::type("SoundBuffer");
33
34  ResourceSoundBuffer::SoundBufferResourcePointer::SoundBufferResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const SoundBufferData::Pointer& data)
35      : Resources::StorePointer(loadString, keepLevel) , pointer(data)
36{}}
Note: See TracBrowser for help on using the repository browser.