NazaraEngine/emscripten.patch

1209 lines
44 KiB
Diff

diff --git a/examples/DopplerEffect/main.cpp b/examples/DopplerEffect/main.cpp
index 0498da58a..ba817eadd 100644
--- a/examples/DopplerEffect/main.cpp
+++ b/examples/DopplerEffect/main.cpp
@@ -14,6 +14,8 @@
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Platform/Keyboard.hpp>
#include <Nazara/Platform/Platform.hpp>
+#include <Nazara/Platform/Window.hpp>
+#include <Nazara/Utility/BasicMainloop.hpp>
#include <chrono>
#include <iostream>
#include <thread>
@@ -52,28 +54,33 @@ int main()
// On joue le son
sound.Play();
- // La boucle du programme (Pour déplacer le son)
+ Nz::Window window;
+
Nz::Clock clock;
- while (sound.GetStatus() == Nz::SoundStatus::Playing)
- {
- // Comme le son se joue dans un thread séparé, on peut mettre en pause le principal régulièrement
- int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS
+ Nz::BasicMainloop(window, [&] {
+ if (sound.GetStatus() == Nz::SoundStatus::Playing)
+ {
+ // Comme le son se joue dans un thread séparé, on peut mettre en pause le principal régulièrement
+ int sleepTime = int(1000 / 60 - clock.GetMilliseconds()); // 60 FPS
- if (sleepTime > 0)
- std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
+ if (sleepTime > 0)
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
- // On bouge la source du son en fonction du temps depuis chaque mise à jour
- Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity()*clock.GetSeconds();
- sound.SetPosition(pos);
+ // On bouge la source du son en fonction du temps depuis chaque mise à jour
+ Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity() * clock.GetSeconds();
+ sound.SetPosition(pos);
- std::cout << "Sound position: " << pos << std::endl;
+ std::cout << "Sound position: " << pos << std::endl;
- // Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
- if (pos.x > Nz::Vector3f::Left().x*-50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Escape))
- sound.Stop(); // On arrête le son (Stoppant également la boucle)
+ // Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
+ if (pos.x > Nz::Vector3f::Left().x * -50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Escape))
+ sound.Stop(); // On arrête le son (Stoppant également la boucle)
- clock.Restart();
- }
+ clock.Restart();
+ }
+ });
+
+ // La boucle du programme (Pour déplacer le son)
return 0;
}
diff --git a/examples/GraphicsTest/main.cpp b/examples/GraphicsTest/main.cpp
index 1054bd8bd..f51e917d6 100644
--- a/examples/GraphicsTest/main.cpp
+++ b/examples/GraphicsTest/main.cpp
@@ -17,11 +17,12 @@ int main()
resourceDir = "../.." / resourceDir;
Nz::Renderer::Config rendererConfig;
- std::cout << "Run using Vulkan? (y/n)" << std::endl;
+ rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;
+ /*std::cout << "Run using Vulkan? (y/n)" << std::endl;
if (std::getchar() == 'y')
rendererConfig.preferredAPI = Nz::RenderAPI::Vulkan;
else
- rendererConfig.preferredAPI = Nz::RenderAPI::Vulkan;
+ rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;*/
Nz::Modules<Nz::Graphics> nazara(rendererConfig);
@@ -31,7 +32,7 @@ int main()
meshParams.center = true;
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
meshParams.vertexScale = Nz::Vector3f(0.002f);
- meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
+ meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
@@ -122,6 +123,8 @@ int main()
Nz::Mouse::SetRelativeMouseMode(true);
+ Nz::Clock crashClock;
+
Nz::BasicMainloop(window, [&]
{
Nz::WindowEvent event;
@@ -221,6 +224,14 @@ int main()
framePipeline.GetDebugDrawer().DrawLine(Nz::Vector3f::Zero(), Nz::Vector3f::Forward(), Nz::Color::Blue);
+ for (const Nz::WorldInstancePtr& worldInstance : { modelInstance, modelInstance2 })
+ {
+ Nz::Boxf aabb = model.GetAABB();
+ aabb.Transform(worldInstance->GetWorldMatrix());
+
+ framePipeline.GetDebugDrawer().DrawBox(aabb, Nz::Color::Green);
+ }
+
viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(viewerPos, camAngles));
viewerInstance.UpdateEyePosition(viewerPos);
@@ -249,6 +260,9 @@ int main()
// Et on relance l'horloge pour refaire ça dans une seconde
secondClock.Restart();
}
+
+ if (crashClock.GetSeconds() > 3.f)
+ std::abort();
});
return EXIT_SUCCESS;
diff --git a/examples/GraphicsTest/xmake.lua b/examples/GraphicsTest/xmake.lua
index 76c04f596..b439049fd 100644
--- a/examples/GraphicsTest/xmake.lua
+++ b/examples/GraphicsTest/xmake.lua
@@ -1,7 +1,3 @@
target("GraphicsTest")
add_deps("NazaraGraphics")
- add_files("main.cpp")
-
- if is_plat("wasm") then
- add_ldflags("--preload-file assets/", {force = true})
- end
+ add_files("main.cpp")
\ No newline at end of file
diff --git a/examples/PhysicallyBasedRendering/xmake.lua b/examples/PhysicallyBasedRendering/xmake.lua
index 5093554b6..6af2278d6 100644
--- a/examples/PhysicallyBasedRendering/xmake.lua
+++ b/examples/PhysicallyBasedRendering/xmake.lua
@@ -1,7 +1,3 @@
target("PBR")
add_deps("NazaraGraphics")
add_files("main.cpp")
-
- if is_plat("wasm") then
- add_ldflags("--preload-file assets/", {force = true})
- end
diff --git a/examples/PlayMusic/main.cpp b/examples/PlayMusic/main.cpp
index e52b10440..dc5154a2d 100644
--- a/examples/PlayMusic/main.cpp
+++ b/examples/PlayMusic/main.cpp
@@ -8,6 +8,8 @@
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Platform/Keyboard.hpp>
#include <Nazara/Platform/Platform.hpp>
+#include <Nazara/Utility/BasicMainloop.hpp>
+#include <Nazara/Platform/Window.hpp>
#include <chrono>
#include <iostream>
#include <thread>
@@ -18,6 +20,8 @@ int main()
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
resourceDir = "../.." / resourceDir;
+ std::getchar();
+
Nz::Modules<Nz::Audio> audio;
Nz::SoundStreamParams streamParams;
@@ -35,8 +39,10 @@ int main()
std::cout << "Playing sound..." << std::endl;
- while (music.IsPlaying())
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ Nz::Window window;
+
+ Nz::BasicMainloop(window, [&] {
+ });
return EXIT_SUCCESS;
}
diff --git a/examples/PlayMusic/xmake.lua b/examples/PlayMusic/xmake.lua
index 946c770e3..3825e84bd 100644
--- a/examples/PlayMusic/xmake.lua
+++ b/examples/PlayMusic/xmake.lua
@@ -1,3 +1,3 @@
target("PlayMusic")
- add_deps("NazaraAudio")
+ add_deps("NazaraAudio", "NazaraPlatform")
add_files("main.cpp")
diff --git a/examples/RenderTest/main.cpp b/examples/RenderTest/main.cpp
index 7ae60e011..0c17e233e 100644
--- a/examples/RenderTest/main.cpp
+++ b/examples/RenderTest/main.cpp
@@ -129,7 +129,6 @@ int main()
}
Nz::MeshParams meshParams;
- meshParams.bufferFactory = Nz::GetRenderBufferFactory(device);
meshParams.center = true;
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
meshParams.vertexScale = Nz::Vector3f(0.002f);
@@ -153,6 +152,17 @@ int main()
// Vertex buffer
std::cout << "Vertex count: " << meshVB->GetVertexCount() << std::endl;
+ // Create renderbuffers (GPU buffers)
+ const std::shared_ptr<Nz::RenderDevice>& renderDevice = window.GetRenderDevice();
+
+ assert(meshIB->GetBuffer()->GetStorage() == Nz::DataStorage::Software);
+ assert(meshVB->GetBuffer()->GetStorage() == Nz::DataStorage::Software);
+ const Nz::SoftwareBuffer* indexBufferContent = static_cast<const Nz::SoftwareBuffer*>(meshIB->GetBuffer().get());
+ const Nz::SoftwareBuffer* vertexBufferContent = static_cast<const Nz::SoftwareBuffer*>(meshVB->GetBuffer().get());
+
+ std::shared_ptr<Nz::RenderBuffer> renderBufferIB = renderDevice->InstantiateBuffer(Nz::BufferType::Index, indexBufferContent->GetSize(), Nz::BufferUsage::DeviceLocal, indexBufferContent->GetData());
+ std::shared_ptr<Nz::RenderBuffer> renderBufferVB = renderDevice->InstantiateBuffer(Nz::BufferType::Vertex, vertexBufferContent->GetSize(), Nz::BufferUsage::DeviceLocal, vertexBufferContent->GetData());
+
// Texture
Nz::TextureParams texParams;
texParams.renderDevice = device;
@@ -230,13 +240,8 @@ int main()
std::shared_ptr<Nz::RenderPipeline> pipeline = device->InstantiateRenderPipeline(pipelineInfo);
- const std::shared_ptr<Nz::RenderDevice>& renderDevice = window.GetRenderDevice();
-
std::shared_ptr<Nz::CommandPool> commandPool = renderDevice->InstantiateCommandPool(Nz::QueueType::Graphics);
- Nz::RenderBuffer& renderBufferIB = static_cast<Nz::RenderBuffer&>(*meshIB->GetBuffer());
- Nz::RenderBuffer& renderBufferVB = static_cast<Nz::RenderBuffer&>(*meshVB->GetBuffer());
-
Nz::Vector3f viewerPos = Nz::Vector3f::Zero();
Nz::EulerAnglesf camAngles(0.f, 0.f, 0.f);
@@ -253,6 +258,8 @@ int main()
Nz::DebugDrawer debugDrawer(*renderDevice);
+ Nz::Clock crashClock;
+
Nz::BasicMainloop(window, [&]
{
Nz::WindowEvent event;
@@ -379,9 +386,9 @@ int main()
{
builder.BeginRenderPass(windowRT->GetFramebuffer(frame.GetFramebufferIndex()), windowRT->GetRenderPass(), renderRect, { clearValues[0], clearValues[1] });
{
- builder.BindIndexBuffer(renderBufferIB, Nz::IndexType::U16);
+ builder.BindIndexBuffer(*renderBufferIB, Nz::IndexType::U16);
builder.BindPipeline(*pipeline);
- builder.BindVertexBuffer(0, renderBufferVB);
+ builder.BindVertexBuffer(0, *renderBufferVB);
builder.BindShaderBinding(0, *viewerShaderBinding);
builder.BindShaderBinding(1, *textureShaderBinding);
@@ -421,6 +428,9 @@ int main()
// Et on relance l'horloge pour refaire ça dans une seconde
secondClock.Restart();
}
+
+ if (crashClock.GetSeconds() > 2.f)
+ std::abort();
});
return EXIT_SUCCESS;
diff --git a/examples/xmake.lua b/examples/xmake.lua
index 2e114e9dd..c86f78d0b 100644
--- a/examples/xmake.lua
+++ b/examples/xmake.lua
@@ -5,5 +5,9 @@ if has_config("examples") then
set_group("Examples")
set_kind("binary")
+ if is_plat("wasm") then
+ add_ldflags("--preload-file assets/", { force = true })
+ end
+
includes("*/xmake.lua")
end
diff --git a/include/Nazara/Audio.hpp b/include/Nazara/Audio.hpp
index 5b2ad2252..a72eaca2a 100644
--- a/include/Nazara/Audio.hpp
+++ b/include/Nazara/Audio.hpp
@@ -40,11 +40,6 @@
#include <Nazara/Audio/DummyAudioSource.hpp>
#include <Nazara/Audio/Enums.hpp>
#include <Nazara/Audio/Music.hpp>
-#include <Nazara/Audio/OpenAL.hpp>
-#include <Nazara/Audio/OpenALBuffer.hpp>
-#include <Nazara/Audio/OpenALDevice.hpp>
-#include <Nazara/Audio/OpenALLibrary.hpp>
-#include <Nazara/Audio/OpenALSource.hpp>
#include <Nazara/Audio/Sound.hpp>
#include <Nazara/Audio/SoundBuffer.hpp>
#include <Nazara/Audio/SoundEmitter.hpp>
diff --git a/include/Nazara/Audio/OpenAL.hpp b/include/Nazara/Audio/OpenAL.hpp
index d23cd08eb..f50c8bd1a 100644
--- a/include/Nazara/Audio/OpenAL.hpp
+++ b/include/Nazara/Audio/OpenAL.hpp
@@ -2,174 +2,147 @@
// This file is part of the "Nazara Engine - Audio module"
// For conditions of distribution and use, see copyright notice in Config.hpp
-#pragma once
+// no header guards
-#ifndef NAZARA_AUDIO_OPENAL_HPP
-#define NAZARA_AUDIO_OPENAL_HPP
+#if (!defined(NAZARA_AUDIO_AL_FUNCTION) || !defined(NAZARA_AUDIO_ALC_FUNCTION)) && !defined(NAZARA_AUDIO_AL_ALC_FUNCTION)
+#error You must define NAZARA_AUDIO_AL_FUNCTION and NAZARA_AUDIO_ALC_FUNCTION, or NAZARA_AUDIO_AL_ALC_FUNCTION before including this file
+#endif
-// no include reordering
+#ifndef NAZARA_AUDIO_AL_FUNCTION
+#define NAZARA_AUDIO_AL_FUNCTION(func) NAZARA_AUDIO_AL_ALC_FUNCTION(func)
+#endif
-#if defined(NAZARA_AUDIO_OPENAL) || defined(NAZARA_AUDIO_BUILD)
+#ifndef NAZARA_AUDIO_ALC_FUNCTION
+#define NAZARA_AUDIO_ALC_FUNCTION(func) NAZARA_AUDIO_AL_ALC_FUNCTION(func)
+#endif
-#include <cstddef>
+#ifndef NAZARA_AUDIO_AL_EXT_FUNCTION
+#define NAZARA_AUDIO_AL_EXT_FUNCTION(func) NAZARA_AUDIO_AL_FUNCTION(func)
+#endif
-// Inclusion of OpenAL headers
+#ifndef NAZARA_AUDIO_AL_EXT_BEGIN
+#define NAZARA_AUDIO_AL_EXT_BEGIN(ext)
+#endif
-// OpenAL headers does not allow us to only get the signatures without the pointers to the functions
-// And I do no want to modify them, I'm obliged to put them in a different namespace
-// to put only interesting things back in the global namespace (specially typedef)
-namespace OpenALDetail
-{
- #include <AL/al.h>
- #include <AL/alc.h>
- #include <AL/alext.h>
-}
+#ifndef NAZARA_AUDIO_AL_EXT_END
+#define NAZARA_AUDIO_AL_EXT_END()
+#endif
-// If someone has a better idea ...
-using OpenALDetail::ALboolean;
-using OpenALDetail::ALbyte;
-using OpenALDetail::ALchar;
-using OpenALDetail::ALdouble;
-using OpenALDetail::ALenum;
-using OpenALDetail::ALfloat;
-using OpenALDetail::ALint;
-using OpenALDetail::ALshort;
-using OpenALDetail::ALsizei;
-using OpenALDetail::ALubyte;
-using OpenALDetail::ALuint;
-using OpenALDetail::ALushort;
-using OpenALDetail::ALvoid;
+NAZARA_AUDIO_AL_FUNCTION(alBuffer3f)
+NAZARA_AUDIO_AL_FUNCTION(alBuffer3i)
+NAZARA_AUDIO_AL_FUNCTION(alBufferData)
+NAZARA_AUDIO_AL_FUNCTION(alBufferf)
+NAZARA_AUDIO_AL_FUNCTION(alBufferfv)
+NAZARA_AUDIO_AL_FUNCTION(alBufferi)
+NAZARA_AUDIO_AL_FUNCTION(alBufferiv)
+NAZARA_AUDIO_AL_FUNCTION(alDeleteBuffers)
+NAZARA_AUDIO_AL_FUNCTION(alDeleteSources)
+NAZARA_AUDIO_AL_FUNCTION(alDisable)
+NAZARA_AUDIO_AL_FUNCTION(alDistanceModel)
+NAZARA_AUDIO_AL_FUNCTION(alDopplerFactor)
+NAZARA_AUDIO_AL_FUNCTION(alDopplerVelocity)
+NAZARA_AUDIO_AL_FUNCTION(alEnable)
+NAZARA_AUDIO_AL_FUNCTION(alGenBuffers)
+NAZARA_AUDIO_AL_FUNCTION(alGenSources)
+NAZARA_AUDIO_AL_FUNCTION(alGetBoolean)
+NAZARA_AUDIO_AL_FUNCTION(alGetBooleanv)
+NAZARA_AUDIO_AL_FUNCTION(alGetBuffer3f)
+NAZARA_AUDIO_AL_FUNCTION(alGetBuffer3i)
+NAZARA_AUDIO_AL_FUNCTION(alGetBufferf)
+NAZARA_AUDIO_AL_FUNCTION(alGetBufferfv)
+NAZARA_AUDIO_AL_FUNCTION(alGetBufferi)
+NAZARA_AUDIO_AL_FUNCTION(alGetBufferiv)
+NAZARA_AUDIO_AL_FUNCTION(alGetDouble)
+NAZARA_AUDIO_AL_FUNCTION(alGetDoublev)
+NAZARA_AUDIO_AL_FUNCTION(alGetEnumValue)
+NAZARA_AUDIO_AL_FUNCTION(alGetError)
+NAZARA_AUDIO_AL_FUNCTION(alGetFloat)
+NAZARA_AUDIO_AL_FUNCTION(alGetFloatv)
+NAZARA_AUDIO_AL_FUNCTION(alGetInteger)
+NAZARA_AUDIO_AL_FUNCTION(alGetIntegerv)
+NAZARA_AUDIO_AL_FUNCTION(alGetListener3f)
+NAZARA_AUDIO_AL_FUNCTION(alGetListener3i)
+NAZARA_AUDIO_AL_FUNCTION(alGetListenerf)
+NAZARA_AUDIO_AL_FUNCTION(alGetListenerfv)
+NAZARA_AUDIO_AL_FUNCTION(alGetListeneri)
+NAZARA_AUDIO_AL_FUNCTION(alGetListeneriv)
+NAZARA_AUDIO_AL_FUNCTION(alGetProcAddress)
+NAZARA_AUDIO_AL_FUNCTION(alGetSource3f)
+NAZARA_AUDIO_AL_FUNCTION(alGetSource3i)
+NAZARA_AUDIO_AL_FUNCTION(alGetSourcef)
+NAZARA_AUDIO_AL_FUNCTION(alGetSourcefv)
+NAZARA_AUDIO_AL_FUNCTION(alGetSourcei)
+NAZARA_AUDIO_AL_FUNCTION(alGetSourceiv)
+NAZARA_AUDIO_AL_FUNCTION(alGetString)
+NAZARA_AUDIO_AL_FUNCTION(alIsBuffer)
+NAZARA_AUDIO_AL_FUNCTION(alIsEnabled)
+NAZARA_AUDIO_AL_FUNCTION(alIsExtensionPresent)
+NAZARA_AUDIO_AL_FUNCTION(alIsSource)
+NAZARA_AUDIO_AL_FUNCTION(alListener3f)
+NAZARA_AUDIO_AL_FUNCTION(alListener3i)
+NAZARA_AUDIO_AL_FUNCTION(alListenerf)
+NAZARA_AUDIO_AL_FUNCTION(alListenerfv)
+NAZARA_AUDIO_AL_FUNCTION(alListeneri)
+NAZARA_AUDIO_AL_FUNCTION(alListeneriv)
+NAZARA_AUDIO_AL_FUNCTION(alSource3f)
+NAZARA_AUDIO_AL_FUNCTION(alSource3i)
+NAZARA_AUDIO_AL_FUNCTION(alSourcef)
+NAZARA_AUDIO_AL_FUNCTION(alSourcefv)
+NAZARA_AUDIO_AL_FUNCTION(alSourcei)
+NAZARA_AUDIO_AL_FUNCTION(alSourceiv)
+NAZARA_AUDIO_AL_FUNCTION(alSourcePause)
+NAZARA_AUDIO_AL_FUNCTION(alSourcePausev)
+NAZARA_AUDIO_AL_FUNCTION(alSourcePlay)
+NAZARA_AUDIO_AL_FUNCTION(alSourcePlayv)
+NAZARA_AUDIO_AL_FUNCTION(alSourceQueueBuffers)
+NAZARA_AUDIO_AL_FUNCTION(alSourceRewind)
+NAZARA_AUDIO_AL_FUNCTION(alSourceRewindv)
+NAZARA_AUDIO_AL_FUNCTION(alSourceStop)
+NAZARA_AUDIO_AL_FUNCTION(alSourceStopv)
+NAZARA_AUDIO_AL_FUNCTION(alSourceUnqueueBuffers)
+NAZARA_AUDIO_AL_FUNCTION(alSpeedOfSound)
-// SOFT_source_latency
-using OpenALDetail::ALint64SOFT;
-using OpenALDetail::ALuint64SOFT;
+/*
+NAZARA_AUDIO_AL_EXT_BEGIN(AL_SOFT_source_latency)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alGetSource3dSOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alGetSource3i64SOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alGetSourcedSOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alGetSourcedvSOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alGetSourcei64SOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alGetSourcei64vSOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alSource3dSOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alSource3i64SOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alSourcedSOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alSourcedvSOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alSourcei64SOFT)
+NAZARA_AUDIO_AL_FUNCTION_EXT(alSourcei64vSOFT)
+NAZARA_AUDIO_AL_EXT_END()
+*/
-using OpenALDetail::ALCboolean;
-using OpenALDetail::ALCbyte;
-using OpenALDetail::ALCchar;
-using OpenALDetail::ALCcontext;
-using OpenALDetail::ALCdevice;
-using OpenALDetail::ALCdouble;
-using OpenALDetail::ALCenum;
-using OpenALDetail::ALCfloat;
-using OpenALDetail::ALCint;
-using OpenALDetail::ALCshort;
-using OpenALDetail::ALCsizei;
-using OpenALDetail::ALCubyte;
-using OpenALDetail::ALCuint;
-using OpenALDetail::ALCushort;
-using OpenALDetail::ALCvoid;
+NAZARA_AUDIO_ALC_FUNCTION(alcCaptureCloseDevice)
+NAZARA_AUDIO_ALC_FUNCTION(alcCaptureOpenDevice)
+NAZARA_AUDIO_ALC_FUNCTION(alcCaptureSamples)
+NAZARA_AUDIO_ALC_FUNCTION(alcCaptureStart)
+NAZARA_AUDIO_ALC_FUNCTION(alcCaptureStop)
+NAZARA_AUDIO_ALC_FUNCTION(alcCloseDevice)
+NAZARA_AUDIO_ALC_FUNCTION(alcCreateContext)
+NAZARA_AUDIO_ALC_FUNCTION(alcDestroyContext)
+NAZARA_AUDIO_ALC_FUNCTION(alcGetContextsDevice)
+NAZARA_AUDIO_ALC_FUNCTION(alcGetCurrentContext)
+NAZARA_AUDIO_ALC_FUNCTION(alcGetEnumValue)
+NAZARA_AUDIO_ALC_FUNCTION(alcGetError)
+NAZARA_AUDIO_ALC_FUNCTION(alcGetIntegerv)
+NAZARA_AUDIO_ALC_FUNCTION(alcGetProcAddress)
+NAZARA_AUDIO_ALC_FUNCTION(alcGetString)
+NAZARA_AUDIO_ALC_FUNCTION(alcIsExtensionPresent)
+NAZARA_AUDIO_ALC_FUNCTION(alcMakeContextCurrent)
+NAZARA_AUDIO_ALC_FUNCTION(alcOpenDevice)
+NAZARA_AUDIO_ALC_FUNCTION(alcProcessContext)
+NAZARA_AUDIO_ALC_FUNCTION(alcSuspendContext)
-#define NAZARA_AUDIO_FOREACH_AL_FUNC(cb, extCb) \
- cb(alBuffer3f, OpenALDetail::LPALBUFFER3F) \
- cb(alBuffer3i, OpenALDetail::LPALBUFFER3I) \
- cb(alBufferData, OpenALDetail::LPALBUFFERDATA) \
- cb(alBufferf, OpenALDetail::LPALBUFFERF) \
- cb(alBufferfv, OpenALDetail::LPALBUFFERFV) \
- cb(alBufferi, OpenALDetail::LPALBUFFERI) \
- cb(alBufferiv, OpenALDetail::LPALBUFFERIV) \
- cb(alDeleteBuffers, OpenALDetail::LPALDELETEBUFFERS) \
- cb(alDeleteSources, OpenALDetail::LPALDELETESOURCES) \
- cb(alDisable, OpenALDetail::LPALDISABLE) \
- cb(alDistanceModel, OpenALDetail::LPALDISTANCEMODEL) \
- cb(alDopplerFactor, OpenALDetail::LPALDOPPLERFACTOR) \
- cb(alDopplerVelocity, OpenALDetail::LPALDOPPLERVELOCITY) \
- cb(alEnable, OpenALDetail::LPALENABLE) \
- cb(alGenBuffers, OpenALDetail::LPALGENBUFFERS) \
- cb(alGenSources, OpenALDetail::LPALGENSOURCES) \
- cb(alGetBoolean, OpenALDetail::LPALGETBOOLEAN) \
- cb(alGetBooleanv, OpenALDetail::LPALGETBOOLEANV) \
- cb(alGetBuffer3f, OpenALDetail::LPALGETBUFFER3F) \
- cb(alGetBuffer3i, OpenALDetail::LPALGETBUFFER3I) \
- cb(alGetBufferf, OpenALDetail::LPALGETBUFFERF) \
- cb(alGetBufferfv, OpenALDetail::LPALGETBUFFERFV) \
- cb(alGetBufferi, OpenALDetail::LPALGETBUFFERI) \
- cb(alGetBufferiv, OpenALDetail::LPALGETBUFFERIV) \
- cb(alGetDouble, OpenALDetail::LPALGETDOUBLE) \
- cb(alGetDoublev, OpenALDetail::LPALGETDOUBLEV) \
- cb(alGetEnumValue, OpenALDetail::LPALGETENUMVALUE) \
- cb(alGetError, OpenALDetail::LPALGETERROR) \
- cb(alGetFloat, OpenALDetail::LPALGETFLOAT) \
- cb(alGetFloatv, OpenALDetail::LPALGETFLOATV) \
- cb(alGetInteger, OpenALDetail::LPALGETINTEGER) \
- cb(alGetIntegerv, OpenALDetail::LPALGETINTEGERV) \
- cb(alGetListener3f, OpenALDetail::LPALGETLISTENER3F) \
- cb(alGetListener3i, OpenALDetail::LPALGETLISTENER3I) \
- cb(alGetListenerf, OpenALDetail::LPALGETLISTENERF) \
- cb(alGetListenerfv, OpenALDetail::LPALGETLISTENERFV) \
- cb(alGetListeneri, OpenALDetail::LPALGETLISTENERI) \
- cb(alGetListeneriv, OpenALDetail::LPALGETLISTENERIV) \
- cb(alGetProcAddress, OpenALDetail::LPALGETPROCADDRESS) \
- cb(alGetSource3f, OpenALDetail::LPALGETSOURCE3F) \
- cb(alGetSource3i, OpenALDetail::LPALGETSOURCE3I) \
- cb(alGetSourcef, OpenALDetail::LPALGETSOURCEF) \
- cb(alGetSourcefv, OpenALDetail::LPALGETSOURCEFV) \
- cb(alGetSourcei, OpenALDetail::LPALGETSOURCEI) \
- cb(alGetSourceiv, OpenALDetail::LPALGETSOURCEIV) \
- cb(alGetString, OpenALDetail::LPALGETSTRING) \
- cb(alIsBuffer, OpenALDetail::LPALISBUFFER) \
- cb(alIsEnabled, OpenALDetail::LPALISENABLED) \
- cb(alIsExtensionPresent, OpenALDetail::LPALISEXTENSIONPRESENT) \
- cb(alIsSource, OpenALDetail::LPALISSOURCE) \
- cb(alListener3f, OpenALDetail::LPALLISTENER3F) \
- cb(alListener3i, OpenALDetail::LPALLISTENER3I) \
- cb(alListenerf, OpenALDetail::LPALLISTENERF) \
- cb(alListenerfv, OpenALDetail::LPALLISTENERFV) \
- cb(alListeneri, OpenALDetail::LPALLISTENERI) \
- cb(alListeneriv, OpenALDetail::LPALLISTENERIV) \
- cb(alSource3f, OpenALDetail::LPALSOURCE3F) \
- cb(alSource3i, OpenALDetail::LPALSOURCE3I) \
- cb(alSourcef, OpenALDetail::LPALSOURCEF) \
- cb(alSourcefv, OpenALDetail::LPALSOURCEFV) \
- cb(alSourcei, OpenALDetail::LPALSOURCEI) \
- cb(alSourceiv, OpenALDetail::LPALSOURCEIV) \
- cb(alSourcePause, OpenALDetail::LPALSOURCEPAUSE) \
- cb(alSourcePausev, OpenALDetail::LPALSOURCEPAUSEV) \
- cb(alSourcePlay, OpenALDetail::LPALSOURCEPLAY) \
- cb(alSourcePlayv, OpenALDetail::LPALSOURCEPLAYV) \
- cb(alSourceQueueBuffers, OpenALDetail::LPALSOURCEQUEUEBUFFERS) \
- cb(alSourceRewind, OpenALDetail::LPALSOURCEREWIND) \
- cb(alSourceRewindv, OpenALDetail::LPALSOURCEREWINDV) \
- cb(alSourceStop, OpenALDetail::LPALSOURCESTOP) \
- cb(alSourceStopv, OpenALDetail::LPALSOURCESTOPV) \
- cb(alSourceUnqueueBuffers, OpenALDetail::LPALSOURCEUNQUEUEBUFFERS) \
- cb(alSpeedOfSound, OpenALDetail::LPALSPEEDOFSOUND) \
- /* AL_SOFT_source_latency */ \
- extCb(alGetSource3dSOFT, OpenALDetail::LPALGETSOURCE3DSOFT) \
- extCb(alGetSource3i64SOFT, OpenALDetail::LPALGETSOURCE3I64SOFT) \
- extCb(alGetSourcedSOFT, OpenALDetail::LPALGETSOURCEDSOFT) \
- extCb(alGetSourcedvSOFT, OpenALDetail::LPALGETSOURCEDVSOFT) \
- extCb(alGetSourcei64SOFT, OpenALDetail::LPALGETSOURCEI64SOFT) \
- extCb(alGetSourcei64vSOFT, OpenALDetail::LPALGETSOURCEI64VSOFT) \
- extCb(alSource3dSOFT, OpenALDetail::LPALSOURCE3DSOFT) \
- extCb(alSource3i64SOFT, OpenALDetail::LPALSOURCE3I64SOFT) \
- extCb(alSourcedSOFT, OpenALDetail::LPALSOURCEDSOFT) \
- extCb(alSourcedvSOFT, OpenALDetail::LPALSOURCEDVSOFT) \
- extCb(alSourcei64SOFT, OpenALDetail::LPALSOURCEI64SOFT) \
- extCb(alSourcei64vSOFT, OpenALDetail::LPALSOURCEI64VSOFT) \
-
-#define NAZARA_AUDIO_FOREACH_ALC_FUNC(cb, extCb) \
- cb(alcCaptureCloseDevice, OpenALDetail::LPALCCAPTURECLOSEDEVICE) \
- cb(alcCaptureOpenDevice, OpenALDetail::LPALCCAPTUREOPENDEVICE) \
- cb(alcCaptureSamples, OpenALDetail::LPALCCAPTURESAMPLES) \
- cb(alcCaptureStart, OpenALDetail::LPALCCAPTURESTART) \
- cb(alcCaptureStop, OpenALDetail::LPALCCAPTURESTOP) \
- cb(alcCloseDevice, OpenALDetail::LPALCCLOSEDEVICE) \
- cb(alcCreateContext, OpenALDetail::LPALCCREATECONTEXT) \
- cb(alcDestroyContext, OpenALDetail::LPALCDESTROYCONTEXT) \
- cb(alcGetContextsDevice, OpenALDetail::LPALCGETCONTEXTSDEVICE) \
- cb(alcGetCurrentContext, OpenALDetail::LPALCGETCURRENTCONTEXT) \
- cb(alcGetEnumValue, OpenALDetail::LPALCGETENUMVALUE) \
- cb(alcGetError, OpenALDetail::LPALCGETERROR) \
- cb(alcGetIntegerv, OpenALDetail::LPALCGETINTEGERV) \
- cb(alcGetProcAddress, OpenALDetail::LPALCGETPROCADDRESS) \
- cb(alcGetString, OpenALDetail::LPALCGETSTRING) \
- cb(alcIsExtensionPresent, OpenALDetail::LPALCISEXTENSIONPRESENT) \
- cb(alcMakeContextCurrent, OpenALDetail::LPALCMAKECONTEXTCURRENT) \
- cb(alcOpenDevice, OpenALDetail::LPALCOPENDEVICE) \
- cb(alcProcessContext, OpenALDetail::LPALCPROCESSCONTEXT) \
- cb(alcSuspendContext, OpenALDetail::LPALCSUSPENDCONTEXT) \
-
-#endif // NAZARA_AUDIO_OPENAL
-
-#endif // NAZARA_AUDIO_OPENAL_HPP
+#undef NAZARA_AUDIO_AL_FUNCTION
+#undef NAZARA_AUDIO_AL_ALC_FUNCTION
+#undef NAZARA_AUDIO_AL_EXT_FUNCTION
+#undef NAZARA_AUDIO_ALC_FUNCTION
+#undef NAZARA_AUDIO_AL_EXT_BEGIN
+#undef NAZARA_AUDIO_AL_EXT_END
diff --git a/include/Nazara/Audio/OpenALBuffer.hpp b/include/Nazara/Audio/OpenALBuffer.hpp
index 132b2be4b..24e974e4f 100644
--- a/include/Nazara/Audio/OpenALBuffer.hpp
+++ b/include/Nazara/Audio/OpenALBuffer.hpp
@@ -12,12 +12,11 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Audio/AudioBuffer.hpp>
#include <Nazara/Audio/Config.hpp>
-#include <Nazara/Audio/OpenAL.hpp>
+#include <Nazara/Audio/OpenALLibrary.hpp>
namespace Nz
{
class OpenALDevice;
- class OpenALLibrary;
class NAZARA_AUDIO_API OpenALBuffer final : public AudioBuffer
{
diff --git a/include/Nazara/Audio/OpenALDevice.hpp b/include/Nazara/Audio/OpenALDevice.hpp
index 84572e4d7..30fe1fc94 100644
--- a/include/Nazara/Audio/OpenALDevice.hpp
+++ b/include/Nazara/Audio/OpenALDevice.hpp
@@ -13,7 +13,7 @@
#include <Nazara/Audio/AudioDevice.hpp>
#include <Nazara/Audio/Config.hpp>
#include <Nazara/Audio/Enums.hpp>
-#include <Nazara/Audio/OpenAL.hpp>
+#include <Nazara/Audio/OpenALLibrary.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Utils/MovablePtr.hpp>
#include <array>
@@ -21,8 +21,6 @@
namespace Nz
{
- class OpenALLibrary;
-
enum class OpenALExtension
{
SourceLatency,
diff --git a/include/Nazara/Audio/OpenALLibrary.hpp b/include/Nazara/Audio/OpenALLibrary.hpp
index c9a1d1c66..07c990067 100644
--- a/include/Nazara/Audio/OpenALLibrary.hpp
+++ b/include/Nazara/Audio/OpenALLibrary.hpp
@@ -7,23 +7,29 @@
#ifndef NAZARA_AUDIO_OPENALLIBRARY_HPP
#define NAZARA_AUDIO_OPENALLIBRARY_HPP
-#if defined(NAZARA_AUDIO_OPENAL) || defined(NAZARA_AUDIO_BUILD)
-
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Audio/Config.hpp>
#include <Nazara/Audio/Enums.hpp>
-#include <Nazara/Audio/OpenAL.hpp>
-#include <Nazara/Audio/OpenALDevice.hpp>
#include <Nazara/Core/DynLib.hpp>
#include <string>
#include <vector>
+// Inclusion of OpenAL headers
+#include <AL/al.h>
+#include <AL/alc.h>
+
+#ifndef NAZARA_PLATFORM_WEB
+#include <AL/alext.h>
+#endif
+
namespace Nz
{
+ class OpenALDevice;
+
class NAZARA_AUDIO_API OpenALLibrary
{
public:
- OpenALLibrary() = default;
+ inline OpenALLibrary();
OpenALLibrary(const OpenALLibrary&) = delete;
OpenALLibrary(OpenALLibrary&&) = delete;
inline ~OpenALLibrary();
@@ -42,21 +48,18 @@ namespace Nz
OpenALLibrary& operator=(const OpenALLibrary&) = delete;
OpenALLibrary& operator=(OpenALLibrary&&) = delete;
-#define NAZARA_AUDIO_FUNC(name, sig) sig name;
- NAZARA_AUDIO_FOREACH_AL_FUNC(NAZARA_AUDIO_FUNC, NAZARA_AUDIO_FUNC)
- NAZARA_AUDIO_FOREACH_ALC_FUNC(NAZARA_AUDIO_FUNC, NAZARA_AUDIO_FUNC)
-#undef NAZARA_AUDIO_FUNC
+#define NAZARA_AUDIO_AL_ALC_FUNCTION(name) decltype(&::name) name;
+#include <Nazara/Audio/OpenAL.hpp>
private:
std::vector<std::string> ParseDevices(const char* deviceString);
DynLib m_library;
+ bool m_isLoaded;
bool m_hasCaptureSupport;
};
}
#include <Nazara/Audio/OpenALLibrary.inl>
-#endif // NAZARA_AUDIO_OPENAL
-
#endif // NAZARA_AUDIO_OPENALLIBRARY_HPP
diff --git a/include/Nazara/Audio/OpenALLibrary.inl b/include/Nazara/Audio/OpenALLibrary.inl
index 05e08e4e0..856fd9a2d 100644
--- a/include/Nazara/Audio/OpenALLibrary.inl
+++ b/include/Nazara/Audio/OpenALLibrary.inl
@@ -7,6 +7,12 @@
namespace Nz
{
+ inline OpenALLibrary::OpenALLibrary() :
+ m_hasCaptureSupport(false),
+ m_isLoaded(false)
+ {
+ }
+
inline OpenALLibrary::~OpenALLibrary()
{
Unload();
@@ -14,7 +20,7 @@ namespace Nz
inline bool OpenALLibrary::IsLoaded() const
{
- return m_library.IsLoaded();
+ return m_isLoaded;
}
}
diff --git a/include/Nazara/Audio/OpenALSource.hpp b/include/Nazara/Audio/OpenALSource.hpp
index 73afff99d..3473abdcb 100644
--- a/include/Nazara/Audio/OpenALSource.hpp
+++ b/include/Nazara/Audio/OpenALSource.hpp
@@ -12,13 +12,12 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Audio/AudioSource.hpp>
#include <Nazara/Audio/Config.hpp>
-#include <Nazara/Audio/OpenAL.hpp>
+#include <Nazara/Audio/OpenALLibrary.hpp>
namespace Nz
{
class OpenALBuffer;
class OpenALDevice;
- class OpenALLibrary;
class NAZARA_AUDIO_API OpenALSource final : public AudioSource
{
diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp
index d2cc4248f..e674abd1c 100644
--- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp
+++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp
@@ -164,6 +164,7 @@ namespace Nz::GL
inline void NotifyVertexArrayDestruction(GLuint vao) const;
bool ProcessErrorStack() const;
+ template<typename... Args> bool ProcessErrorStack(std::size_t funcIndex, Args... args) const;
inline void ResetColorWriteMasks() const;
inline void ResetDepthWriteMasks() const;
diff --git a/include/Nazara/Utility/BasicMainloop.hpp b/include/Nazara/Utility/BasicMainloop.hpp
index 359b5c978..c419651a9 100644
--- a/include/Nazara/Utility/BasicMainloop.hpp
+++ b/include/Nazara/Utility/BasicMainloop.hpp
@@ -7,7 +7,7 @@
#ifndef NAZARA_BASIC_MAINLOOP_HPP
#define NAZARA_BASIC_MAINLOOP_HPP
-#include <Nazara/Renderer.hpp>
+#include <Nazara/Platform/Window.hpp>
#ifdef NAZARA_PLATFORM_WEB
#include <emscripten/html5.h>
@@ -16,7 +16,7 @@
namespace Nz
{
template <typename CallbackT>
- void BasicMainloop(RenderWindow& window, CallbackT&& callback)
+ void BasicMainloop(Window& window, CallbackT&& callback)
{
#ifndef NAZARA_PLATFORM_WEB
while (window.IsOpen())
diff --git a/src/Nazara/Audio/Audio.cpp b/src/Nazara/Audio/Audio.cpp
index 153c9f585..02f8a6c86 100644
--- a/src/Nazara/Audio/Audio.cpp
+++ b/src/Nazara/Audio/Audio.cpp
@@ -8,7 +8,7 @@
#include <Nazara/Audio/Config.hpp>
#include <Nazara/Audio/DummyAudioDevice.hpp>
#include <Nazara/Audio/Enums.hpp>
-#include <Nazara/Audio/OpenALLibrary.hpp>
+#include <Nazara/Audio/OpenALDevice.hpp>
#include <Nazara/Audio/Formats/drwavLoader.hpp>
#include <Nazara/Audio/Formats/libflacLoader.hpp>
#include <Nazara/Audio/Formats/libvorbisLoader.hpp>
diff --git a/src/Nazara/Audio/OpenALLibrary.cpp b/src/Nazara/Audio/OpenALLibrary.cpp
index e9380a68e..4fcfe990f 100644
--- a/src/Nazara/Audio/OpenALLibrary.cpp
+++ b/src/Nazara/Audio/OpenALLibrary.cpp
@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Audio/OpenALLibrary.hpp>
+#include <Nazara/Audio/OpenALDevice.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
@@ -23,6 +24,16 @@ namespace Nz
CallOnExit unloadOnFailure([this] { Unload(); });
+ auto PostLoad = [&]
+ {
+ m_hasCaptureSupport = alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE");
+ m_isLoaded = true;
+
+ unloadOnFailure.Reset();
+ };
+
+#ifndef NAZARA_AUDIO_OPENAL_LINK
+ // Dynamically load OpenAL
#if defined(NAZARA_PLATFORM_WINDOWS)
std::array libs{
"soft_oal.dll",
@@ -74,15 +85,32 @@ namespace Nz
continue;
}
- m_hasCaptureSupport = alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE");
-
- unloadOnFailure.Reset();
+ PostLoad();
return true;
}
NazaraError("failed to load OpenAL library");
return false;
- }
+
+#else
+ // OpenAL is linked to the executable
+
+ // Load core
+#define NAZARA_AUDIO_AL_ALC_FUNCTION(name) name = &::name;
+#define NAZARA_AUDIO_AL_EXT_FUNCTION(name)
+#include <Nazara/Audio/OpenAL.hpp>
+
+ // Load ext
+#define NAZARA_AUDIO_AL_ALC_FUNCTION(name)
+#define NAZARA_AUDIO_AL_EXT_BEGIN(ext) if (alIsExtensionPresent(#ext)) {
+#define NAZARA_AUDIO_AL_EXT_END() }
+#define NAZARA_AUDIO_AL_FUNCTION_EXT(name) name = reinterpret_cast<decltype(name)>(alGetProcAddress(#name));
+#include <Nazara/Audio/OpenAL.hpp>
+
+ PostLoad();
+ return true;
+#endif
+ }
std::vector<std::string> OpenALLibrary::QueryInputDevices()
{
@@ -111,10 +139,8 @@ namespace Nz
if (!m_library.IsLoaded())
return;
-#define NAZARA_AUDIO_FUNC(name, sig) name = nullptr;
- NAZARA_AUDIO_FOREACH_AL_FUNC(NAZARA_AUDIO_FUNC, NAZARA_AUDIO_FUNC)
- NAZARA_AUDIO_FOREACH_ALC_FUNC(NAZARA_AUDIO_FUNC, NAZARA_AUDIO_FUNC)
-#undef NAZARA_AUDIO_FUNC
+#define NAZARA_AUDIO_AL_ALC_FUNCTION(name) name = nullptr;
+#include <Nazara/Audio/OpenAL.hpp>
m_library.Unload();
}
diff --git a/src/Nazara/Audio/OpenALSource.cpp b/src/Nazara/Audio/OpenALSource.cpp
index d4bf7a808..98d163b79 100644
--- a/src/Nazara/Audio/OpenALSource.cpp
+++ b/src/Nazara/Audio/OpenALSource.cpp
@@ -4,6 +4,7 @@
#include <Nazara/Audio/OpenALSource.hpp>
#include <Nazara/Audio/OpenALBuffer.hpp>
+#include <Nazara/Audio/OpenALDevice.hpp>
#include <Nazara/Audio/OpenALLibrary.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/Error.hpp>
@@ -84,18 +85,20 @@ namespace Nz
auto OpenALSource::GetSampleOffsetAndLatency() const -> OffsetWithLatency
{
OffsetWithLatency offsetWithLatency;
- if (GetDevice().IsExtensionSupported(OpenALExtension::SourceLatency))
+#ifndef NAZARA_PLATFORM_WEB
+ /*if (GetDevice().IsExtensionSupported(OpenALExtension::SourceLatency))
{
GetDevice().MakeContextCurrent();
- std::array<ALint64SOFT, 2> values;
+ std::array<Int64, 2> values;
m_library.alGetSourcei64vSOFT(m_sourceId, AL_SAMPLE_OFFSET_LATENCY_SOFT, values.data());
offsetWithLatency.sampleOffset = ((values[0] & 0xFFFFFFFF00000000) >> 32) * 1'000;
offsetWithLatency.sourceLatency = values[1] / 1'000;
}
- else
+ else*/
+#endif
{
offsetWithLatency.sampleOffset = GetSampleOffset() * 1'000;
offsetWithLatency.sourceLatency = 0;
diff --git a/src/Nazara/Graphics/DebugDrawPipelinePass.cpp b/src/Nazara/Graphics/DebugDrawPipelinePass.cpp
index 2eb17dddf..a0876d3e3 100644
--- a/src/Nazara/Graphics/DebugDrawPipelinePass.cpp
+++ b/src/Nazara/Graphics/DebugDrawPipelinePass.cpp
@@ -44,8 +44,8 @@ namespace Nz
builder.SetScissor(viewport);
builder.SetViewport(viewport);
- DebugDrawer& debugDrawer = m_pipeline.GetDebugDrawer();
- debugDrawer.Draw(builder);
+ //DebugDrawer& debugDrawer = m_pipeline.GetDebugDrawer();
+ //debugDrawer.Draw(builder);
});
}
}
diff --git a/src/Nazara/Graphics/ForwardFramePipeline.cpp b/src/Nazara/Graphics/ForwardFramePipeline.cpp
index 2f5ffda80..2e4e1337e 100644
--- a/src/Nazara/Graphics/ForwardFramePipeline.cpp
+++ b/src/Nazara/Graphics/ForwardFramePipeline.cpp
@@ -161,7 +161,7 @@ namespace Nz
auto& viewerData = *m_viewerPool.Allocate(viewerIndex);
viewerData.renderOrder = renderOrder;
viewerData.debugDrawPass = std::make_unique<DebugDrawPipelinePass>(*this, viewerInstance);
- viewerData.depthPrepass = std::make_unique<DepthPipelinePass>(*this, m_elementRegistry, viewerInstance);
+ //viewerData.depthPrepass = std::make_unique<DepthPipelinePass>(*this, m_elementRegistry, viewerInstance);
viewerData.forwardPass = std::make_unique<ForwardPipelinePass>(*this, m_elementRegistry, viewerInstance);
viewerData.viewer = viewerInstance;
viewerData.onTransferRequired.Connect(viewerInstance->GetViewerInstance().OnTransferRequired, [this](TransferInterface* transferInterface)
diff --git a/src/Nazara/Graphics/ForwardPipelinePass.cpp b/src/Nazara/Graphics/ForwardPipelinePass.cpp
index a860a6ddc..bd4f17cb8 100644
--- a/src/Nazara/Graphics/ForwardPipelinePass.cpp
+++ b/src/Nazara/Graphics/ForwardPipelinePass.cpp
@@ -297,6 +297,11 @@ namespace Nz
elementRenderer.Render(viewerInstance, *m_elementRendererData[elementType], builder, elementCount, elements);
});
+ DebugDrawer& debugDrawer = m_pipeline.GetDebugDrawer();
+ debugDrawer.Draw(builder);
+
+ NazaraWarning("----");
+
m_rebuildCommandBuffer = false;
});
}
diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp
index 25d9b384e..a656d74d2 100644
--- a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp
+++ b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp
@@ -175,7 +175,14 @@ namespace Nz
{
const OpenGLFboFramebuffer& fboFramebuffer = static_cast<const OpenGLFboFramebuffer&>(*command.framebuffer);
- context->glDrawBuffers(GLsizei(colorBufferCount), fboDrawBuffers.data());
+ // TODO: glDrawBuffers should be called only at FBO setup
+ if (colorBufferCount > 0)
+ context->glDrawBuffers(GLsizei(colorBufferCount), fboDrawBuffers.data());
+ else
+ {
+ GLenum buffer = GL_NONE;
+ context->glDrawBuffers(1, &buffer);
+ }
invalidateAttachments = NazaraStackVector(GLenum, colorBufferCount + 1);
@@ -246,13 +253,13 @@ namespace Nz
assert(command.framebuffer->GetType() == FramebufferType::Window);
// glDrawBuffers doesn't accept GL_BACK on OpenGL non-ES, and glDrawBuffer must be used instead
- if (context->glDrawBuffer)
+ /*if (context->GetParams().type != GL::ContextType::OpenGL_ES && context->glDrawBuffer)
context->glDrawBuffer(GL_BACK);
else
{
GLenum buffer = GL_BACK;
context->glDrawBuffers(1, &buffer);
- }
+ }*/
invalidateAttachments = NazaraStackVector(GLenum, 3); //< color + depth + stencil
diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp
index 478a904a1..355cf46ac 100644
--- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp
+++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp
@@ -22,6 +22,12 @@ namespace Nz::GL
namespace
{
+ constexpr std::array s_functionNames = {
+#define NAZARA_OPENGLRENDERER_FUNC(name, sig) #name,
+ NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_FUNC)
+#undef NAZARA_OPENGLRENDERER_FUNC
+ };
+
template<typename FuncType, std::size_t FuncIndex, typename>
struct GLWrapper;
@@ -41,13 +47,13 @@ namespace Nz::GL
{
funcPtr(std::forward<Args>(args)...);
- context->ProcessErrorStack();
+ context->ProcessErrorStack(FuncIndex, std::forward<Args>(args)...);
}
else
{
Ret r = funcPtr(std::forward<Args>(args)...);
- context->ProcessErrorStack();
+ context->ProcessErrorStack(FuncIndex, std::forward<Args>(args)...);
return r;
}
@@ -139,9 +145,14 @@ namespace Nz::GL
GLenum Context::BindFramebuffer(GLuint fbo) const
{
- if (m_state.boundDrawFBO == fbo)
+#ifdef NAZARA_PLATFORM_WEB
+ constexpr bool isWeb = true;
+#else
+ constexpr bool isWeb = false;
+#endif
+ if (m_state.boundDrawFBO == fbo && !isWeb)
return GL_DRAW_FRAMEBUFFER;
- else if (m_state.boundReadFBO == fbo)
+ else if (m_state.boundReadFBO == fbo && !isWeb)
return GL_READ_FRAMEBUFFER;
else
{
@@ -163,7 +174,7 @@ namespace Nz::GL
#else
constexpr bool isWeb = false;
#endif
- if (currentFbo != fbo || isWeb);
+ if (currentFbo != fbo || isWeb)
{
if (!SetCurrentContext(this))
throw std::runtime_error("failed to activate context");
@@ -271,6 +282,9 @@ namespace Nz::GL
void Context::BindVertexArray(GLuint vertexArray, bool force) const
{
+#ifdef NAZARA_PLATFORM_WEB
+ force = true;
+#endif
if (m_state.boundVertexArray != vertexArray || force)
{
if (!SetCurrentContext(this))
@@ -355,7 +369,7 @@ namespace Nz::GL
}
SymbolLoader loader(*this);
- loader.wrapErrorHandling = params.wrapErrorHandling;
+ //loader.wrapErrorHandling = params.wrapErrorHandling;
try
{
@@ -594,6 +608,34 @@ namespace Nz::GL
return hasAnyError;
}
+ template<typename... Args>
+ bool Context::ProcessErrorStack(std::size_t funcIndex, Args... args) const
+ {
+ if (!ProcessErrorStack())
+ return false;
+
+ std::stringstream ss;
+ ss << s_functionNames[funcIndex] << "(";
+ if constexpr (sizeof...(args) > 0)
+ {
+ bool first = true;
+ auto PrintParam = [&](auto value)
+ {
+ if (!first)
+ ss << ", ";
+
+ ss << +value;
+ first = false;
+ };
+
+ (PrintParam(args), ...);
+ }
+ ss << ")";
+ NazaraDebug(ss.str());
+
+ return true;
+ }
+
void Context::SetCurrentTextureUnit(UInt32 textureUnit) const
{
if (m_state.currentTextureUnit != textureUnit)
@@ -616,7 +658,7 @@ namespace Nz::GL
if (!SetCurrentContext(this))
throw std::runtime_error("failed to activate context");
- glScissor(x, y, width, height);
+ //glScissor(x, y, width, height);
m_state.scissorBox.x = x;
m_state.scissorBox.y = y;
diff --git a/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.cpp b/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.cpp
index eb0137a4d..d80bdd0a0 100644
--- a/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.cpp
+++ b/src/Nazara/OpenGLRenderer/Wrapper/WGL/WGLLoader.cpp
@@ -52,11 +52,11 @@ namespace Nz::GL
ContextParams params;
// Favor OpenGL on desktop and OpenGL ES on mobile
std::array<GL::ContextType, 2> contextTypes = {
-#if defined(NAZARA_PLATFORM_DESKTOP)
+/*#if defined(NAZARA_PLATFORM_DESKTOP)
GL::ContextType::OpenGL, GL::ContextType::OpenGL_ES
-#else
+#else*/
GL::ContextType::OpenGL_ES, GL::ContextType::OpenGL
-#endif
+//#endif
};
bool created = false;
diff --git a/xmake.lua b/xmake.lua
index ff6b6b31c..8b72ebaf1 100644
--- a/xmake.lua
+++ b/xmake.lua
@@ -54,7 +54,17 @@ local modules = {
Deps = {"NazaraCore"},
Packages = {"dr_wav", "frozen", "libflac", "libvorbis", "minimp3"},
Custom = function ()
- add_packages("openal-soft", { links = {} }) -- Don't link OpenAL (it will be loaded dynamically)
+ if is_plat("wasm") or has_config("link_openal") then
+ add_defines("NAZARA_AUDIO_OPENAL_LINK")
+ add_defines("AL_ALEXT_PROTOTYPES")
+ if is_plat("wasm") then
+ add_syslinks("openal")
+ else
+ add_packages("openal-soft")
+ end
+ else
+ add_packages("openal-soft", { links = {} })
+ end
end
},
Core = {
@@ -157,8 +167,8 @@ if not has_config("embed_rendererbackends") then
end
end
-add_ldflags("-g -s NO_DISABLE_EXCEPTION_CATCHING -s ALLOW_MEMORY_GROWTH=1")
-add_cxflags("-g -s NO_DISABLE_EXCEPTION_CATCHING")
+add_ldflags("-g", "-sNO_DISABLE_EXCEPTION_CATCHING", "-sALLOW_MEMORY_GROWTH", "-sWASM_BIGINT")
+add_cxflags("-g", "-sNO_DISABLE_EXCEPTION_CATCHING", "-sERROR_ON_WASM_CHANGES_AFTER_LINK")
NazaraModules = modules
@@ -167,6 +177,7 @@ includes("xmake/**.lua")
option("compile_shaders", { description = "Compile nzsl shaders into an includable binary version", default = true })
option("embed_rendererbackends", { description = "Embed renderer backend code into NazaraRenderer instead of loading them dynamically", default = false })
option("embed_resources", { description = "Turn builtin resources into includable headers", default = true })
+option("link_openal", { description = "Link OpenAL in the executable instead of dynamically loading it", default = false })
option("override_runtime", { description = "Override vs runtime to MD in release and MDd in debug", default = true })
option("usepch", { description = "Use precompiled headers to speedup compilation", default = false })
option("unitybuild", { description = "Build the engine using unity build", default = false })
@@ -174,15 +185,17 @@ option("unitybuild", { description = "Build the engine using unity build", defau
set_project("NazaraEngine")
set_xmakever("2.7.3")
-add_requires("dr_wav", "entt 3.10.1", "fmt", "frozen", "kiwisolver", "minimp3", "ordered_map", "stb")
+add_requires("dr_wav", "entt 3.10.1", "fmt", "frozen", "libflac", "kiwisolver", "minimp3", "ordered_map", "stb")
+add_requires("libvorbis", { configs = { with_vorbisenc = false } })
if not is_plat("wasm") then
- add_requires("chipmunk2d", "libsdl", "libflac", "efsw")
+ add_requires("chipmunk2d", "libsdl", "efsw")
add_requires("freetype", { configs = { bzip2 = true, png = true, woff2 = true, zlib = true, debug = is_mode("debug") } })
- add_requires("libvorbis", { configs = { with_vorbisenc = false } })
add_requires("openal-soft", { configs = { shared = true }})
add_requires("newtondynamics3", { debug = is_plat("windows") and is_mode("debug") }) -- Newton doesn't like compiling in Debug on Linux
end
+add_repositories("local-repo xmake-repo")
+
add_repositories("nazara-engine-repo https://github.com/NazaraEngine/xmake-repo")
add_requires("nazarautils")
add_requires("nzsl", { debug = is_mode("debug"), configs = { with_symbols = not is_mode("release"), shared = not is_plat("wasm") } })