Major - Adds FMOD audio library - V13.0.0
Adds precompiled FMOD audio library binaries for various platforms (x86, x64, arm64) and build configurations (Debug, Release). Also adds a basic audio component header file.
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include "camera_class.h"
|
||||
#include "light_class.h"
|
||||
|
||||
#include "Fmod/core/inc/fmod.hpp"
|
||||
|
||||
#include "bitmap_class.h"
|
||||
#include "sprite_class.h"
|
||||
#include "timer_class.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "entity.h"
|
||||
#include "component.h"
|
||||
#include "components/audio_component.h"
|
||||
#include "components/identity_component.h"
|
||||
#include "components/render_component.h"
|
||||
#include "components/transform_component.h"
|
||||
@@ -50,5 +51,6 @@ inline void EnregistrerTousLesComposants() {
|
||||
factory.EnregistrerComposant<ecs::ModelPathComponent>("ModelPathComponent");
|
||||
factory.EnregistrerComposant<ecs::IdentityComponent>("IdentityComponent");
|
||||
factory.EnregistrerComposant<ecs::RenderComponent>("RenderComponent");
|
||||
factory.EnregistrerComposant<ecs::AudioComponent>("AudioComponent");
|
||||
// Ajouter d'autres composants ici
|
||||
}
|
||||
|
||||
35
enginecustom/src/inc/system/ecs/components/audio_component.h
Normal file
35
enginecustom/src/inc/system/ecs/components/audio_component.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// AudioComponent.h
|
||||
#pragma once
|
||||
#include "ecs/component.h"
|
||||
#include <Fmod/core/inc/fmod.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace ecs {
|
||||
class AudioComponent : public Component {
|
||||
public:
|
||||
AudioComponent() : m_system(nullptr), m_sound(nullptr), m_channel(nullptr) {}
|
||||
~AudioComponent() override {
|
||||
if (m_sound) m_sound->release();
|
||||
}
|
||||
|
||||
bool Load(FMOD::System* system, const std::string& path) {
|
||||
m_system = system;
|
||||
return m_system->createSound(path.c_str(), FMOD_DEFAULT, nullptr, &m_sound) == FMOD_OK;
|
||||
}
|
||||
|
||||
void Play() {
|
||||
if (m_system && m_sound)
|
||||
m_system->playSound(m_sound, nullptr, false, &m_channel);
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
if (m_channel)
|
||||
m_channel->stop();
|
||||
}
|
||||
|
||||
private:
|
||||
FMOD::System* m_system;
|
||||
FMOD::Sound* m_sound;
|
||||
FMOD::Channel* m_channel;
|
||||
};
|
||||
}
|
||||
@@ -5,20 +5,20 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
|
||||
{
|
||||
system_class* System;
|
||||
bool result;
|
||||
|
||||
|
||||
wchar_t path[MAX_PATH];
|
||||
HMODULE hmodule = GetModuleHandle(NULL);
|
||||
if (hmodule != NULL)
|
||||
{
|
||||
GetModuleFileName(hmodule, path, (sizeof(path) / sizeof(wchar_t)));
|
||||
}
|
||||
|
||||
|
||||
std::filesystem::path exePath(path);
|
||||
std::filesystem::path WFolder = exePath.parent_path();
|
||||
|
||||
|
||||
// Create the system object.
|
||||
System = new system_class;
|
||||
|
||||
|
||||
// initialize and run the system object.
|
||||
result = System->initialize();
|
||||
if (result)
|
||||
@@ -27,7 +27,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
|
||||
System->send_path(path,WFolder);
|
||||
System->run();
|
||||
}
|
||||
|
||||
|
||||
// shutdown and release the system object.
|
||||
System->shutdown();
|
||||
delete System;
|
||||
|
||||
Reference in New Issue
Block a user