Last active
October 13, 2015 12:17
-
-
Save kenpower/4193984 to your computer and use it in GitHub Desktop.
Simple(est) FMOD manager. Just Creates the FMOD:::system object as a singleton.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "FModManager.h" | |
| FMOD::System *FModManager::system=0; | |
| FMOD::System* FModManager::System(){ | |
| if(!system){ | |
| FMOD_RESULT result; | |
| result = FMOD::System_Create(&system); // Create the main system object. | |
| if (result != FMOD_OK) | |
| { | |
| std::cout << "FMOD error! (%d) %s\n" <<result;// << FMOD_ErrorString(result); | |
| exit(-1); | |
| } | |
| result = system->init(100, FMOD_INIT_NORMAL, 0); // Initialize FMOD. | |
| if (result != FMOD_OK) | |
| { | |
| std::cout << "FMOD error! (%d) %s\n" << result;// << FMOD_ErrorString(result); | |
| exit(-1); | |
| } | |
| } | |
| return system; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #pragma comment(lib,"fmodex_vc.lib") | |
| #include "fmod.hpp" | |
| #include <iostream> | |
| class FModManager | |
| { | |
| public: | |
| static FMOD::System* System(); | |
| private: | |
| static FMOD::System *system; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void OgreApp1::createScene(void) | |
| { | |
| Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); | |
| Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); | |
| headNode->attachObject(ogreHead); | |
| // Set ambient light | |
| mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); | |
| // Create a light | |
| Ogre::Light* l = mSceneMgr->createLight("MainLight"); | |
| l->setPosition(20,80,50); | |
| result = FModManager::System()->createSound("C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API Windows/examples/media/wave.mp3", FMOD_3D, 0, &sound); | |
| } | |
| bool OgreApp1::keyPressed( const OIS::KeyEvent &arg ) | |
| { | |
| if (arg.key == OIS::KC_X) // toggle visibility of advanced frame stats | |
| { | |
| FModManager::System()->playSound(FMOD_CHANNEL_FREE, sound, false, &channel); | |
| } | |
| return BaseApplication::keyPressed(arg ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "../FModManager.hpp" | |
| class OgreApp1 : public BaseApplication | |
| { | |
| public: | |
| OgreApp1(void); | |
| virtual ~OgreApp1(void); | |
| virtual bool keyPressed( const OIS::KeyEvent &arg ); | |
| FMOD_RESULT result; | |
| FMOD::Sound *sound; | |
| FMOD::Channel *channel; | |
| protected: | |
| virtual void createScene(void); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment