Refactor the way resources are loaded (#191)
* WIP * WIP * Font works * WIP: Only Music remains * Looks like it's working * Fix oopsie * Core/ObjectRef: Add cast functions * Update ChangeLog.md * Audio/SoundStream: Make sound stream thread-safe
This commit is contained in:
@@ -16,22 +16,22 @@ SCENARIO("Music", "[AUDIO][MUSIC]")
|
||||
|
||||
THEN("We can ask the informations of the file")
|
||||
{
|
||||
REQUIRE(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms
|
||||
REQUIRE(music.GetDuration() >= 63000);
|
||||
REQUIRE(music.GetFormat() == Nz::AudioFormat_Stereo);
|
||||
REQUIRE(music.GetPlayingOffset() == 0);
|
||||
REQUIRE(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo)
|
||||
REQUIRE(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo)
|
||||
REQUIRE(music.GetSampleRate() == 44100 /* Hz */);
|
||||
REQUIRE(music.GetStatus() == Nz::SoundStatus_Stopped);
|
||||
REQUIRE(music.IsLooping() == false);
|
||||
CHECK(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms
|
||||
CHECK(music.GetDuration() >= 63000);
|
||||
CHECK(music.GetFormat() == Nz::AudioFormat_Stereo);
|
||||
CHECK(music.GetPlayingOffset() == 0);
|
||||
CHECK(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo)
|
||||
CHECK(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo)
|
||||
CHECK(music.GetSampleRate() == 44100 /* Hz */);
|
||||
CHECK(music.GetStatus() == Nz::SoundStatus_Stopped);
|
||||
CHECK(music.IsLooping() == false);
|
||||
}
|
||||
|
||||
THEN("We can play it and get the time offset")
|
||||
{
|
||||
Nz::Audio::SetGlobalVolume(0.f);
|
||||
|
||||
music.Play();
|
||||
music.Play();
|
||||
Nz::Thread::Sleep(1000);
|
||||
REQUIRE(music.GetPlayingOffset() >= 950);
|
||||
Nz::Thread::Sleep(200);
|
||||
|
||||
@@ -5,16 +5,15 @@ SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]")
|
||||
{
|
||||
GIVEN("A sound buffer")
|
||||
{
|
||||
Nz::SoundBuffer soundBuffer;
|
||||
|
||||
WHEN("We load our sound")
|
||||
{
|
||||
REQUIRE(soundBuffer.LoadFromFile("resources/Engine/Audio/Cat.flac"));
|
||||
Nz::SoundBufferRef soundBuffer = Nz::SoundBuffer::LoadFromFile("resources/Engine/Audio/Cat.flac");
|
||||
REQUIRE(soundBuffer.IsValid());
|
||||
|
||||
THEN("We can ask the informations of the file")
|
||||
{
|
||||
REQUIRE(soundBuffer.GetDuration() <= 8500); // 8s = 8000ms
|
||||
REQUIRE(soundBuffer.GetDuration() >= 8000);
|
||||
REQUIRE(soundBuffer->GetDuration() <= 8500); // 8s = 8000ms
|
||||
REQUIRE(soundBuffer->GetDuration() >= 8000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ SCENARIO("Billboard", "[GRAPHICS][BILLBOARD]")
|
||||
|
||||
WHEN("We assign it to another")
|
||||
{
|
||||
Nz::MaterialRef materialRef = Nz::Material::New();
|
||||
materialRef->LoadFromFile("resources/Engine/Graphics/Nazara.png");
|
||||
Nz::MaterialRef materialRef = Nz::Material::LoadFromFile("resources/Engine/Graphics/Nazara.png");
|
||||
Nz::Color materialColor = materialRef->GetDiffuseColor();
|
||||
Nz::BillboardRef otherBillboard = Nz::Billboard::New(materialRef);
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ SCENARIO("Model", "[GRAPHICS][MODEL]")
|
||||
Nz::ModelParameters params;
|
||||
params.mesh.optimizeIndexBuffers = false;
|
||||
|
||||
Nz::ModelRef model = Nz::Model::New();
|
||||
REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj", params));
|
||||
Nz::ModelRef model = Nz::Model::LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj", params);
|
||||
REQUIRE(model);
|
||||
|
||||
REQUIRE(model->GetMaterialCount() == 1);
|
||||
REQUIRE(model->GetSkin() == 0);
|
||||
|
||||
@@ -5,21 +5,20 @@ SCENARIO("SkeletalModel", "[GRAPHICS][SKELETALMODEL]")
|
||||
{
|
||||
GIVEN("A default skeletal model")
|
||||
{
|
||||
Nz::SkeletalModel skeletalModel;
|
||||
Nz::AnimationRef animation = Nz::Animation::New();
|
||||
|
||||
WHEN("We can load the bob lamp")
|
||||
{
|
||||
REQUIRE(skeletalModel.LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5mesh"));
|
||||
REQUIRE(animation->LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5anim"));
|
||||
skeletalModel.SetAnimation(animation);
|
||||
Nz::AnimationRef animation = Nz::Animation::LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5anim");
|
||||
Nz::SkeletalModelRef skeletalModel = Nz::StaticRefCast<Nz::SkeletalModel>(Nz::SkeletalModel::LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5mesh"));
|
||||
REQUIRE(skeletalModel);
|
||||
REQUIRE(animation);
|
||||
skeletalModel->SetAnimation(animation);
|
||||
|
||||
THEN("We can enable its animation")
|
||||
{
|
||||
REQUIRE(skeletalModel.HasAnimation());
|
||||
skeletalModel.EnableAnimation(true);
|
||||
skeletalModel.AdvanceAnimation(0.10f);
|
||||
REQUIRE(skeletalModel.IsAnimationEnabled());
|
||||
REQUIRE(skeletalModel->HasAnimation());
|
||||
skeletalModel->EnableAnimation(true);
|
||||
skeletalModel->AdvanceAnimation(0.10f);
|
||||
REQUIRE(skeletalModel->IsAnimationEnabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ SCENARIO("SkyboxBackground", "[GRAPHICS][SKYBOXBACKGROUND]")
|
||||
{
|
||||
GIVEN("A skybox background with a loaded image")
|
||||
{
|
||||
Nz::TextureRef textureRef = Nz::Texture::New();
|
||||
textureRef->LoadCubemapFromFile("resources/Engine/Graphics/skybox.png");
|
||||
Nz::TextureRef textureRef = Nz::Texture::LoadCubemapFromFile("resources/Engine/Graphics/skybox.png");
|
||||
Nz::SkyboxBackgroundRef skyboxBackgroundRef = Nz::SkyboxBackground::New(textureRef);
|
||||
|
||||
WHEN("We assign it parameters")
|
||||
|
||||
@@ -5,8 +5,7 @@ SCENARIO("TextureBackground", "[GRAPHICS][TEXTUREBACKGROUND]")
|
||||
{
|
||||
GIVEN("A default texture background")
|
||||
{
|
||||
Nz::TextureRef textureRef = Nz::Texture::New();
|
||||
textureRef->LoadFromFile("resources/Engine/Graphics/skybox.png");
|
||||
Nz::TextureRef textureRef = Nz::Texture::LoadFromFile("resources/Engine/Graphics/skybox.png");
|
||||
Nz::TextureBackgroundRef textureBackgroundRef = Nz::TextureBackground::New(textureRef);
|
||||
|
||||
WHEN("We assign it parameters")
|
||||
@@ -17,4 +16,4 @@ SCENARIO("TextureBackground", "[GRAPHICS][TEXTUREBACKGROUND]")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user