Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gamedev/fggl
  • onuralpsezer/fggl
2 results
Show changes
Showing
with 601 additions and 51 deletions
...@@ -12,61 +12,58 @@ ...@@ -12,61 +12,58 @@
* If not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef FGGL_GFX_OGL_COMPAT_HPP //
#define FGGL_GFX_OGL_COMPAT_HPP // Created by webpigeon on 04/09/22.
/** //
* Legacy/Direct OpenGL calls.
*
* This shouldn't be exposed to the demo app, but the ECS we're using isn't smart enouph to allow us to
* abstract this yet. It's next thing on the list, but this branch is about cleaning up OpenGL not about
* extending our ECS.
*
* Should be removed when the engine has suitable abstractions in place.
*/
#include <functional> #ifndef FGGL_DEMO_INCLUDE_ROBOT_PROGRAMMER_HPP
#define FGGL_DEMO_INCLUDE_ROBOT_PROGRAMMER_HPP
#include <fggl/gfx/ogl/shader.hpp> #include <functional>
#include <fggl/gfx/ogl/renderer.hpp>
#include <fggl/gfx/common.hpp> #include "fggl/gui/containers.hpp"
#include <fggl/gfx/camera.hpp>
#include <utility> namespace demo::robot {
#include <fggl/input/camera_input.hpp>
#include <fggl/data/heightmap.hpp>
#include "fggl/gfx/phong.hpp" struct Instruction {
const char* name;
std::function<void(void)> m_func;
};
namespace fggl::gfx { struct Program {
std::vector<Instruction> m_instructions;
uint32_t m_currInstruction;
bool playing = false;
// inline std::size_t size() {
// fake module support - allows us to still RAII return m_instructions.size();
// }
/*struct SceneUtils : ecs3::Module {
SceneUtils() = default; inline void step() {
m_instructions[ m_currInstruction ].m_func();
m_currInstruction++;
}
[[nodiscard]] inline void stop() {
std::string name() const override { playing = false;
return "gfx::scene"; m_currInstruction = 0;
} }
};
void onLoad(ecs3::ModuleManager &manager, ecs3::TypeRegistry &types) override { class Timeline : public fggl::gui::Panel {
// mesh dependencies public:
types.make<math::Transform>(); explicit Timeline(Program& program);
types.make<data::StaticMesh>();
types.make<data::HeightMap>();
types.make<gfx::PhongMaterial>(); void update(float deltaTime) override;
void render(fggl::gfx::Paint& paint) override;
// camera dependencies protected:
types.make<fggl::gfx::Camera>(); void renderInstructions(fggl::gfx::Paint& paint);
types.make<fggl::input::FreeCamKeys>();
}
};*/ private:
std::vector<std::reference_wrapper<Program>> m_tracks;
};
} }
#endif #endif //FGGL_DEMO_INCLUDE_ROBOT_PROGRAMMER_HPP
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "fggl/scenes/game.hpp" #include "fggl/scenes/game.hpp"
#include "fggl/phys/service.hpp" #include "fggl/phys/service.hpp"
#include "fggl/script/engine.hpp"
namespace demo { namespace demo {
...@@ -40,11 +41,7 @@ namespace demo { ...@@ -40,11 +41,7 @@ namespace demo {
fggl::entity::EntityID player = fggl::entity::INVALID; fggl::entity::EntityID player = fggl::entity::INVALID;
fggl::entity::EntityID closestPickup; fggl::entity::EntityID closestPickup;
DebugMode mode = DebugMode::NORMAL; DebugMode mode = DebugMode::NORMAL;
std::vector<fggl::entity::EntityID> collectables;
std::array<fggl::entity::EntityID, 3> collectables {
fggl::entity::INVALID,
fggl::entity::INVALID,
fggl::entity::INVALID };
float time = 0.0f; float time = 0.0f;
}; };
...@@ -57,13 +54,14 @@ namespace demo { ...@@ -57,13 +54,14 @@ namespace demo {
void activate() override; void activate() override;
void deactivate() override; void deactivate() override;
void update() override; void update(float dt) override;
void render(fggl::gfx::Graphics& gfx) override; void render(fggl::gfx::Graphics& gfx) override;
private: private:
constexpr static fggl::math::vec3 HINT_COLOUR{0.5f, 0.0f, 0.0f}; constexpr static fggl::math::vec3 HINT_COLOUR{0.5f, 0.0f, 0.0f};
RollState state; RollState state;
fggl::phys::PhysicsEngine* m_phys; fggl::phys::PhysicsEngine* m_phys;
fggl::script::ScriptEngine* m_scripts;
fggl::math::vec3 cameraOffset = {-15.0F, 15.0F, 0.0F}; fggl::math::vec3 cameraOffset = {-15.0F, 15.0F, 0.0F};
void closestPickup(fggl::entity::EntityManager& world); void closestPickup(fggl::entity::EntityManager& world);
......
...@@ -29,7 +29,7 @@ namespace demo { ...@@ -29,7 +29,7 @@ namespace demo {
explicit TopDown(fggl::App& app); explicit TopDown(fggl::App& app);
void activate() override; void activate() override;
void update() override; void update(float dt) override;
void render(fggl::gfx::Graphics& gfx) override; void render(fggl::gfx::Graphics& gfx) override;
private: private:
......
...@@ -5,6 +5,8 @@ file(GLOB_RECURSE HEADER_LIST CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/include/fgg ...@@ -5,6 +5,8 @@ file(GLOB_RECURSE HEADER_LIST CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/include/fgg
# Should be shared linkage for legal reasons (LGPL) # Should be shared linkage for legal reasons (LGPL)
add_library(fggl ${HEADER_LIST}) add_library(fggl ${HEADER_LIST})
target_link_libraries(fggl PUBLIC entt)
# we need to tell people using the library about our headers # we need to tell people using the library about our headers
target_include_directories(fggl target_include_directories(fggl
PUBLIC PUBLIC
...@@ -34,6 +36,7 @@ endif () ...@@ -34,6 +36,7 @@ endif ()
# the important stuff everything else uses # the important stuff everything else uses
add_subdirectory(math) add_subdirectory(math)
add_subdirectory(util) add_subdirectory(util)
add_subdirectory(grid)
add_subdirectory(assets) add_subdirectory(assets)
add_subdirectory(phys) add_subdirectory(phys)
...@@ -53,27 +56,17 @@ target_sources(${PROJECT_NAME} ...@@ -53,27 +56,17 @@ target_sources(${PROJECT_NAME}
input/input.cpp input/input.cpp
input/mouse.cpp input/mouse.cpp
input/camera_input.cpp input/camera_input.cpp
)
gui/widget.cpp # GUI support
gui/widgets.cpp add_subdirectory(gui)
gui/containers.cpp
gui/fonts.cpp
)
# yaml-cpp for configs and storage # yaml-cpp for configs and storage
find_package(yaml-cpp) find_package(yaml-cpp)
target_link_libraries(fggl PUBLIC yaml-cpp) target_link_libraries(fggl PUBLIC yaml-cpp)
# model loading # model loading
find_package(assimp CONFIG) add_subdirectory(data/assimp)
if (MSVC)
target_link_libraries(${PROJECT_NAME} PUBLIC assimp::assimp)
else ()
target_link_libraries(${PROJECT_NAME} PUBLIC assimp)
endif ()
find_package(Freetype)
target_link_libraries(${PROJECT_NAME} PUBLIC Freetype::Freetype)
# Graphics backend # Graphics backend
add_subdirectory(gfx) add_subdirectory(gfx)
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
*/ */
#include <cstdlib> #include <cstdlib>
#include <memory>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <fggl/app.hpp> #include <fggl/app.hpp>
...@@ -29,7 +28,7 @@ namespace fggl { ...@@ -29,7 +28,7 @@ namespace fggl {
m_states(), m_states(),
m_subsystems(services) {} m_subsystems(services) {}
int App::run(int argc, const char **argv) { auto App::run(int /*argc*/, const char **/*argv*/) -> int {
auto *windowing = m_subsystems->get<display::WindowService>(); auto *windowing = m_subsystems->get<display::WindowService>();
{ {
...@@ -39,7 +38,13 @@ namespace fggl { ...@@ -39,7 +38,13 @@ namespace fggl {
state.activate(); state.activate();
} }
auto lastTime = glfwGetTime();
while (m_running) { while (m_running) {
auto currTime = glfwGetTime();
auto delta = currTime - lastTime;
lastTime = currTime;
// trigger a state change if expected // trigger a state change if expected
if (m_expectedScene != m_states.activeID()) { if (m_expectedScene != m_states.activeID()) {
auto result = m_states.change(m_expectedScene); auto result = m_states.change(m_expectedScene);
...@@ -55,7 +60,7 @@ namespace fggl { ...@@ -55,7 +60,7 @@ namespace fggl {
//m_modules->onUpdate(); //m_modules->onUpdate();
auto &state = m_states.active(); auto &state = m_states.active();
state.update(); state.update((float)delta);
// window rendering to frame buffer // window rendering to frame buffer
if (m_window != nullptr) { if (m_window != nullptr) {
......
target_sources(fggl PRIVATE target_sources(fggl PRIVATE
module.cpp module.cpp
) types.cpp
\ No newline at end of file packed/module.cpp
)
\ No newline at end of file
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
namespace fggl::assets { namespace fggl::assets {
bool AssetFolders::factory(modules::ModuleService service, modules::Services &services) { auto AssetFolders::factory(modules::ServiceName service, modules::Services &services) -> bool {
if (service == Loader::service) { if (service == Loader::service) {
auto storage = services.get<data::Storage>(); auto *storage = services.get<data::Storage>();
services.create<Loader>(storage); auto *checkin = services.get<CheckinAdapted>();
services.create<Loader>(storage, checkin);
return true; return true;
} }
if (service == AssetManager::service) { if (service == AssetManager::service) {
......
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 20/08/22.
//
#include "fggl/assets/packed/module.hpp"
namespace fggl::assets {
auto PackedAssets::factory(modules::ServiceName service, modules::Services &services) -> bool {
if (service == RawCheckin::service) {
services.create<RawCheckin>();
return true;
}
if (service == CheckinAdapted::service) {
auto* storage = services.get<data::Storage>();
auto* rawCheckin = services.get<RawCheckin>();
services.create<CheckinAdapted>(storage, rawCheckin);
return true;
}
return false;
}
} // namespace fggl::assets
\ No newline at end of file
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 19/11/22.
//
#include <stack>
#include <vector>
#include <memory>
#include <set>
#include <map>
#include <concepts>
#include "fggl/util/guid.hpp"
namespace fggl::assets {
using AssetName = util::OpaqueName<uint64_t, struct AssetRefStruct>;
/**
* The base class representing an asset.
*
* This can be combined with the templated version.
*/
class Asset {
public:
Asset(AssetName name) : m_name(name) {}
virtual ~Asset() = default;
inline void release() {
releaseImpl();
}
bool operator==(const Asset& asset) const {
return m_name == asset.m_name;
}
bool operator!=(const Asset& asset) const {
return m_name != asset.m_name;
}
private:
AssetName m_name;
virtual void releaseImpl() = 0;
};
/**
* Wrapper for types that cannot extend Asset themselves.
*
* @tparam T the asset to wrap
*/
template<typename T>
class AssetBox : public Asset {
public:
AssetBox(T* ptr) : m_ptr(ptr) {}
~AssetBox() override {
release();
}
T* ptr() {
return m_ptr;
}
private:
T* m_ptr;
void releaseImpl() override {
delete m_ptr;
m_ptr = nullptr;
}
};
/**
* Asset Library.
*
* The currently usable set of assets loaded into the engine.
*/
class AssetLibrary {
public:
void load(AssetName name);
void unload(AssetName name);
template<typename T>
requires std::derived_from<T, Asset>
void store(AssetName name, T* ptr) {
m_assets[name] = std::make_unique<T>(ptr);
}
template<typename T>
requires std::derived_from<T, Asset>
void get(AssetName name) const {
Asset* asset = m_assets.at(name).get();
return dynamic_cast<T>(asset);
}
inline Asset* get(AssetName name) const {
return m_assets.at( name ).get();
}
private:
std::map<AssetName, std::unique_ptr<Asset>> m_assets;
};
struct AssetRecord {
AssetName id;
std::vector<AssetName> dependencies;
bool hasDepends(AssetName name) const;
void addDepend(AssetName name);
};
class AssetGraph {
public:
AssetGraph(AssetLibrary* loader);
/**
*
*
* @param name
*/
void require(AssetName& name) {
if ( m_loaded.find(name) != m_loaded.end() ) {
return;
}
m_required.push(name);
}
/**
*
*
* @return
*/
[[nodiscard]]
inline bool isLoadComplete() const {
return m_required.empty();
}
/**
*
*
* @param name
* @return
*/
[[nodiscard]]
inline bool isLoaded(AssetName name) const {
return m_loaded.find(name) != m_loaded.end();
}
/**
*
* @param name
* @param description
*/
void addDependency(AssetName& name, AssetName& description) {
auto& assets = m_assets.at(name);
assets.addDepend(description);
}
/**
*
* @param name
* @param dependency
* @return
*/
[[nodiscard]]
bool hasDependency(AssetName& name , AssetName& dependency) const {
try {
auto &assets = m_assets.at(name);
return assets.hasDepends(dependency);
} catch ( std::out_of_range& ) {
return false;
}
}
/**
*
*/
void process() {
auto asset = m_required.top();
m_loader->load( asset );
m_required.pop();
}
/**
*
*/
void finishLoading() {
while ( !m_loaded.empty() ) {
process();
}
}
private:
std::stack<AssetName> m_required;
std::set<AssetName> m_loaded;
std::map<AssetName, AssetRecord> m_assets;
AssetLibrary* m_loader;
};
} // namespace fggl::assets
\ No newline at end of file
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 20/11/22.
//
#include "fggl/assets/types.hpp"
namespace fggl::assets {
auto make_asset_id_rt(const std::string &pack, const std::string &path, const std::string &view) -> AssetID {
auto fullPath = pack + ":" + path;
if (!view.empty()) {
fullPath += "[" + view + "]";
}
#ifndef NDEBUG
util::intern_string(fullPath.c_str());
#endif
auto hash = util::hash_fnv1a_64(fullPath.c_str());
return AssetID::make(hash);
}
auto asset_from_user(const std::string &input, const std::string &pack) -> AssetID {
if (input.find(':') != std::string::npos ) {
// probably fully qualified
#ifndef NDEBUG
util::intern_string(input.c_str());
#endif
auto hash = util::hash_fnv1a_64(input.c_str());
return AssetID::make(hash);
}
// probably local
return make_asset_id_rt(pack, input);
}
}
\ No newline at end of file
...@@ -3,4 +3,5 @@ target_sources(fggl ...@@ -3,4 +3,5 @@ target_sources(fggl
types.cpp types.cpp
) )
add_subdirectory(openal) add_subdirectory(openal)
\ No newline at end of file add_subdirectory(fallback)
\ No newline at end of file
target_sources(fggl
PRIVATE
audio.cpp
)
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 05/11/22.
//
#include "fggl/audio/null_audio.hpp"
namespace fggl::audio {
void NullAudioService::play(const std::string &, bool) {
}
void NullAudioService::play(const fggl::audio::AudioClipShort &, bool) {
}
auto NullAudio::factory(modules::ServiceName service, modules::Services &services) -> bool{
if (service == SERVICE_AUDIO_PLAYBACK) {
services.bind<audio::AudioService, audio::NullAudioService>();
return true;
}
return false;
}
} // namespace fggl::audio
\ No newline at end of file
...@@ -18,7 +18,8 @@ else () ...@@ -18,7 +18,8 @@ else ()
endif () endif ()
target_sources(fggl target_sources(fggl
PRIVATE PRIVATE
audio.cpp audio.cpp
) module.cpp
)
...@@ -27,28 +27,98 @@ ...@@ -27,28 +27,98 @@
*/ */
#include "fggl/audio/openal/audio.hpp" #include "fggl/audio/openal/audio.hpp"
#include "fggl/data/storage.hpp" #include "fggl/assets/types.hpp"
#include "fggl/assets/manager.hpp"
#include "../../stb/stb_vorbis.h"
namespace fggl::audio::openal { namespace fggl::audio::openal {
auto load_vorbis(assets::Loader* /*loader*/, const assets::AssetID &guid, const assets::LoaderContext &data, void* userPtr) -> assets::AssetRefRaw {
auto *manager = static_cast<assets::AssetManager*>(userPtr);
auto filePath = data.assetPath;
// vorbis
auto* clip = new AudioClipShort();
clip->sampleCount = stb_vorbis_decode_filename( filePath.c_str(), &clip->channels, &clip->sampleRate, &clip->data);
debug::info("clip loaded: channels={}, sampleRate={}, sampleCount={}", clip->channels, clip->sampleRate, clip->sampleCount);
if ( clip->sampleCount == -1 ) {
return nullptr;
}
manager->set(guid, clip);
return nullptr;
}
auto load_vorbis_short(std::filesystem::path path, assets::MemoryBlock& /*block*/) -> bool {
// vorbis
auto* clip = new AudioClipShort();
clip->sampleCount = stb_vorbis_decode_filename( path.c_str(), &clip->channels, &clip->sampleRate, &clip->data);
debug::info("clip loaded: channels={}, sampleRate={}, sampleCount={}", clip->channels, clip->sampleRate, clip->sampleCount);
return clip->sampleCount != 1;
}
auto check_vorbis(const std::filesystem::path& path ) -> assets::AssetTypeID {
if ( path.extension() != ".ogg" ) {
return assets::INVALID_ASSET_TYPE;
}
auto* clip = new AudioClipShort();
clip->sampleCount = stb_vorbis_decode_filename( path.c_str(), &clip->channels, &clip->sampleRate, &clip->data);
if ( clip->sampleCount == -1 ) {
return assets::INVALID_ASSET_TYPE;
}
delete clip;
return ASSET_CLIP_SHORT;
}
void AudioSource::play(const AudioClipShort &clip, bool looping) {
check_error("pre play");
AudioType format = clip.channels == 1 ? AudioType::MONO_16 : AudioType::STEREO_16;
m_splat.setData(format, clip.data, clip.size(), clip.sampleRate);
check_error("saving to buffer");
play(m_splat, looping);
check_error("post play");
}
void AudioServiceOAL::play(const std::string &filename, bool looping) { void AudioServiceOAL::play(const std::string &filename, bool looping) {
debug::info("beginning audio: {}", filename);
// load audio clip into temp storage // load audio clip into temp storage
AudioClip clip; auto assetRef = assets::make_asset_id_rt("core", filename);
bool result = m_storage->load(data::StorageType::Data, filename, &clip); auto* clip = m_assets->get<AudioClipShort>(assetRef);
if (!result) { if ( clip == nullptr ) {
std::cerr << "error: can't load audio data" << std::endl; debug::warning("audio asset requested, but not loaded: {}", filename);
return; return;
} }
play(clip, looping); play(*clip, looping);
debug::info("played audio: {}", filename);
} }
void AudioServiceOAL::play(AudioClip &clip, bool looping) { void AudioServiceOAL::play(const AudioClipShort &clip, bool looping) {
// play the audio on the default (non-positioned) source if ( m_defaultSource == nullptr ){
if (m_defaultSource != nullptr) { return;
m_defaultSource->play(clip, looping);
} }
// play the audio on the default (non-positioned) source
m_defaultSource->play(clip, looping);
}
void AudioServiceOAL::release() {
m_defaultSource = nullptr;
alcMakeContextCurrent(nullptr);
alcDestroyContext(m_context);
alcCloseDevice(m_device);
m_context = nullptr;
m_device = nullptr;
} }
} }
\ No newline at end of file
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 05/11/22.
//
#include "fggl/audio/openal/module.hpp"
namespace fggl::audio {
auto OpenAL::factory(modules::ServiceName service, modules::Services &services) -> bool {
if (service == SERVICE_AUDIO_PLAYBACK) {
auto* assets = services.get<assets::AssetManager>();
{
auto *assetLoader = services.get<assets::Loader>();
assetLoader->setFactory( ASSET_CLIP_SHORT, openal::load_vorbis, assets::LoadType::PATH);
}
{
auto *checkin = services.get<assets::CheckinAdapted>();
checkin->setLoader( RES_OGG_VORBIS, openal::load_vorbis_short, openal::check_vorbis );
}
services.bind<audio::AudioService, openal::AudioServiceOAL>(assets);
return true;
}
return false;
}
}
\ No newline at end of file
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "fggl/data/storage.hpp" #include "fggl/data/storage.hpp"
#include "fggl/audio/audio.hpp" #include "fggl/audio/audio.hpp"
#include "../stb/stb_vorbis.h"
namespace fggl::audio { namespace fggl::audio {
...@@ -23,13 +22,4 @@ namespace fggl::audio { ...@@ -23,13 +22,4 @@ namespace fggl::audio {
namespace fggl::data { namespace fggl::data {
template<>
bool fggl_deserialize<audio::AudioClip>(std::filesystem::path &data, audio::AudioClip *out) {
out->sampleCount = stb_vorbis_decode_filename(data.string().c_str(),
&out->channels,
&out->sampleRate,
&out->data);
return out->sampleCount != -1;
}
} // namespace fggl::data } // namespace fggl::data
find_package(assimp CONFIG)
if (MSVC)
target_link_libraries(${PROJECT_NAME} PUBLIC assimp::assimp)
else ()
target_link_libraries(${PROJECT_NAME} PUBLIC assimp)
endif ()
target_sources(fggl
PRIVATE
module.cpp
image.cpp
)
\ No newline at end of file
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 22/10/22.
//
#define STB_IMAGE_IMPLEMENTATION
#include "../../stb/stb_image.h"