Changeset 5878 for code/branches/core5/src/orxonox
- Timestamp:
- Oct 5, 2009, 1:36:33 AM (15 years ago)
- Location:
- code/branches/core5/src/orxonox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc
r5876 r5878 59 59 // and a Camera 60 60 this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera"); 61 // Load sound 62 this->ambient_ = new SoundMainMenu(); 61 if (GameMode::playsSound()) 62 { 63 // Load sound 64 this->ambient_ = new SoundMainMenu(); 65 } 63 66 } 64 67 65 68 GSMainMenu::~GSMainMenu() 66 69 { 70 if (GameMode::playsSound()) 71 { 72 this->ambient_->destroy(); 73 } 74 67 75 InputManager::getInstance().destroyState("mainMenu"); 68 76 … … 87 95 InputManager::getInstance().enterState("mainMenu"); 88 96 89 this->ambient_->play(true); 97 if (GameMode::playsSound()) 98 { 99 this->ambient_->play(true); 100 } 90 101 } 91 102 92 103 void GSMainMenu::deactivate() 93 104 { 94 this->ambient_->stop(); 105 if (GameMode::playsSound()) 106 { 107 this->ambient_->stop(); 108 } 95 109 96 110 InputManager::getInstance().leaveState("mainMenu"); -
code/branches/core5/src/orxonox/sound/SoundManager.cc
r5877 r5878 31 31 #include <AL/alut.h> 32 32 33 #include "util/Exception.h" 33 34 #include "util/Math.h" 35 #include "util/ScopeGuard.h" 36 #include "core/GameMode.h" 34 37 #include "core/ScopedSingletonManager.h" 35 38 #include "CameraManager.h" … … 42 45 ManageScopedSingleton(SoundManager, ScopeID::Graphics, true); 43 46 44 /**45 * Default constructor46 */47 47 SoundManager::SoundManager() 48 48 { 49 this->device_ = NULL; 50 this->soundavailable_ = true; 51 if(!alutInitWithoutContext(NULL,NULL)) 52 { 53 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 54 this->soundavailable_ = false; 55 } 49 if (!alutInitWithoutContext(NULL,NULL)) 50 ThrowException(InitialisationFailed, "OpenAL ALUT error: " << alutGetErrorString(alutGetError())); 51 Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit); 52 53 COUT(3) << "OpenAL: Opening sound device..." << std::endl; 54 this->device_ = alcOpenDevice(NULL); 55 if (this->device_ == NULL) 56 ThrowException(InitialisationFailed, "OpenAL error: Could not open sound device."); 57 Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_); 58 59 COUT(3) << "OpenAL: Sound device opened" << std::endl; 60 this->context_ = alcCreateContext(this->device_, NULL); 61 if (this->context_ == NULL) 62 ThrowException(InitialisationFailed, "OpenAL error: Could not create sound context"); 63 Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_); 64 65 if (alcMakeContextCurrent(this->context_) == AL_TRUE) 66 COUT(3) << "OpenAL: Context " << this->context_ << " loaded" << std::endl; 67 68 COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl; 69 70 const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER); 71 if (str == NULL) 72 COUT(2) << "OpenAL ALUT error: " << alutGetErrorString(alutGetError()) << std::endl; 56 73 else 57 { 58 assert(this->device_ == NULL); 59 COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl; 60 this->device_ = alcOpenDevice(NULL); 74 COUT(4) << "OpenAL ALUT supported MIME types: " << str << std::endl; 75 ThrowException(InitialisationFailed, "Just testing"); 61 76 62 if(this->device_ == NULL) 63 { 64 COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl; 65 this->soundavailable_ = false; 66 } 67 else 68 { 69 COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl; 70 this->context_ = alcCreateContext(this->device_, NULL); 71 if(this->context_ == NULL) 72 { 73 COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl; 74 this->soundavailable_ = false; 75 } 76 else 77 { 78 if(alcMakeContextCurrent(this->context_) == AL_TRUE) 79 COUT(3) << "Sound: OpenAL: Context " << this->context_ << " loaded" << std::endl; 80 81 COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl; 82 const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER); 83 if (str == NULL) 84 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 85 else 86 COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << str << std::endl; 87 } 88 } 89 } 77 GameMode::setPlaysSound(true); 78 // Disarm guards 79 alutExitGuard.Dismiss(); 80 closeDeviceGuard.Dismiss(); 81 desroyContextGuard.Dismiss(); 90 82 } 91 83 92 84 SoundManager::~SoundManager() 93 85 { 86 GameMode::setPlaysSound(false); 94 87 alcDestroyContext(this->context_); 95 88 alcCloseDevice(this->device_);
Note: See TracChangeset
for help on using the changeset viewer.