Minor - Adds FMOD integration for audio support - V13.4.0
Initializes FMOD sound system within the application class and propagates it to the entity manager and entities. This allows for audio components to access and use the FMOD system for playing sounds. Removes redundant FMOD system initialization from the audio component.
This commit is contained in:
@@ -6,10 +6,8 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/camera_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/camera_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/audio_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/audio_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" />
|
||||
@@ -259,7 +257,8 @@
|
||||
<workItem from="1757952605657" duration="117000" />
|
||||
<workItem from="1757952791669" duration="4499000" />
|
||||
<workItem from="1757959923169" duration="1930000" />
|
||||
<workItem from="1757961888820" duration="8937000" />
|
||||
<workItem from="1757961888820" duration="9053000" />
|
||||
<workItem from="1758030961823" duration="1895000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||
<option name="closed" value="true" />
|
||||
|
||||
@@ -662,6 +662,13 @@ private :
|
||||
|
||||
input inputs_;
|
||||
bool tab_was_pressed_;
|
||||
|
||||
// ------------------------------------------------- //
|
||||
// ------------------- SOUND ----------------------- //
|
||||
// ------------------------------------------------- //
|
||||
|
||||
// shared pointer to the FMOD system
|
||||
FMOD::System* sound_system_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace ecs {
|
||||
class AudioComponent : public Component {
|
||||
public:
|
||||
AudioComponent() : m_system(nullptr), m_sound(nullptr), m_channel(nullptr) {}
|
||||
AudioComponent() : m_sound(nullptr), m_channel(nullptr) {}
|
||||
~AudioComponent() override {
|
||||
if (m_sound) m_sound->release();
|
||||
// Ne pas lib<69>rer m_system ici car il peut <20>tre partag<61>
|
||||
@@ -24,27 +24,12 @@ public:
|
||||
|
||||
void Initialize() override
|
||||
{
|
||||
// create FMOD system if not already created
|
||||
if (!m_system)
|
||||
{
|
||||
FMOD_RESULT result = FMOD::System_Create(&m_system);
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de la cr<63>ation du syst<73>me FMOD: " + std::to_string(result);
|
||||
return;
|
||||
}
|
||||
|
||||
result = m_system->init(512, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED, nullptr);
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de l'initialisation du syst<73>me FMOD: " + std::to_string(result);
|
||||
m_system->release();
|
||||
m_system = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
auto parent = GetParent();
|
||||
if (parent && parent->GetCamera())
|
||||
{
|
||||
SetCamera(parent->GetCamera());
|
||||
SetSoundSystem(parent->GetSoundSystem());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -392,7 +377,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SetSoundSystem(FMOD::System* system) {
|
||||
m_system = system;
|
||||
}
|
||||
|
||||
private:
|
||||
FMOD::System* m_system;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "camera_class.h"
|
||||
#include <Fmod/core/inc/fmod.hpp>
|
||||
|
||||
namespace ecs {
|
||||
/**
|
||||
@@ -140,6 +141,9 @@ public:
|
||||
void SetCamera(camera_class* camera) {m_camera = camera; }
|
||||
camera_class* GetCamera() const { return m_camera; }
|
||||
|
||||
void SetSoundSystem(FMOD::System* soundSystem) {m_soundSystem = soundSystem; }
|
||||
FMOD::System* GetSoundSystem() const { return m_soundSystem; }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -154,6 +158,9 @@ private:
|
||||
|
||||
// camera
|
||||
camera_class* m_camera = nullptr;
|
||||
|
||||
// FMOD sound system
|
||||
FMOD::System* m_soundSystem = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
|
||||
auto entity = std::make_shared<Entity>(id);
|
||||
entity->SetCamera(camera_);
|
||||
entity->SetSoundSystem(sound_system_);
|
||||
m_Entities[id] = entity;
|
||||
|
||||
return entity;
|
||||
@@ -148,11 +149,15 @@ public:
|
||||
void SetCamera(camera_class* camera) { camera_ = camera; }
|
||||
camera_class* GetCamera() const { return camera_; }
|
||||
|
||||
void SetSoundSystem(FMOD::System* sound_system) { sound_system_ = sound_system; }
|
||||
FMOD::System* GetSoundSystem() const { return sound_system_; }
|
||||
|
||||
private:
|
||||
EntityID m_NextEntityID;
|
||||
std::unordered_map<EntityID, std::shared_ptr<Entity>> m_Entities;
|
||||
std::queue<EntityID> m_FreeIDs; // IDs <20> r<>utiliser
|
||||
camera_class* camera_ = nullptr;
|
||||
FMOD::System* sound_system_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
||||
|
||||
@@ -46,6 +46,7 @@ application_class::application_class() : should_quit_(false)
|
||||
light_model_ = nullptr;
|
||||
render_count_ = 0;
|
||||
tab_was_pressed_ = false;
|
||||
sound_system_ = nullptr;
|
||||
}
|
||||
|
||||
application_class::~application_class()
|
||||
@@ -503,8 +504,23 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
|
||||
culling_active_ = true;
|
||||
culling_thread_ = std::thread(&application_class::culling_thread_function, this);
|
||||
|
||||
|
||||
FMOD_RESULT FMOD_result = FMOD::System_Create(&sound_system_);
|
||||
std::string m_lastError;
|
||||
if (FMOD_result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de la cr<63>ation du syst<73>me FMOD: " + std::to_string(FMOD_result);
|
||||
return false;
|
||||
}
|
||||
|
||||
FMOD_result = sound_system_->init(512, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED, nullptr);
|
||||
if (FMOD_result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de l'initialisation du syst<73>me FMOD: " + std::to_string(FMOD_result);
|
||||
sound_system_->release();
|
||||
sound_system_ = nullptr;
|
||||
}
|
||||
|
||||
entity_manager_->SetCamera(camera_);
|
||||
entity_manager_->SetSoundSystem(sound_system_);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user