diff --git a/.gitignore b/.gitignore index adc3e018f..5a148113f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,13 @@ Makefile vs*/* vsxmake*/* +# Ignore assets (except shaders) +assets/* +!assets/examples_version.txt +!assets/readme.md +!assets/tests_version.txt +!assets/shaders + # Coverage coverage.out diff --git a/assets/examples_version.txt b/assets/examples_version.txt new file mode 100644 index 000000000..56a6051ca --- /dev/null +++ b/assets/examples_version.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/assets/readme.md b/assets/readme.md new file mode 100644 index 000000000..c8839afa7 --- /dev/null +++ b/assets/readme.md @@ -0,0 +1,7 @@ +# Assets + +Assets for examples and unit tests are not part of the repository. When building using xmake, you will be asked if you want to download/update them if required. + +You can also download them manually at : +- https://nazara.digitalpulse.software/assets_examples.zip +- https://nazara.digitalpulse.software/assets_tests.zip diff --git a/bin/resources/bloom_bright.nzsl b/assets/shaders/bloom_bright.nzsl similarity index 100% rename from bin/resources/bloom_bright.nzsl rename to assets/shaders/bloom_bright.nzsl diff --git a/bin/resources/bloom_final.nzsl b/assets/shaders/bloom_final.nzsl similarity index 100% rename from bin/resources/bloom_final.nzsl rename to assets/shaders/bloom_final.nzsl diff --git a/bin/resources/deferred_frag.nzsl b/assets/shaders/deferred_frag.nzsl similarity index 100% rename from bin/resources/deferred_frag.nzsl rename to assets/shaders/deferred_frag.nzsl diff --git a/bin/resources/deferred_vert.nzsl b/assets/shaders/deferred_vert.nzsl similarity index 100% rename from bin/resources/deferred_vert.nzsl rename to assets/shaders/deferred_vert.nzsl diff --git a/bin/resources/gamma.nzsl b/assets/shaders/gamma.nzsl similarity index 100% rename from bin/resources/gamma.nzsl rename to assets/shaders/gamma.nzsl diff --git a/bin/resources/gaussian_blur.nzsl b/assets/shaders/gaussian_blur.nzsl similarity index 100% rename from bin/resources/gaussian_blur.nzsl rename to assets/shaders/gaussian_blur.nzsl diff --git a/bin/resources/god_rays.nzsl b/assets/shaders/god_rays.nzsl similarity index 100% rename from bin/resources/god_rays.nzsl rename to assets/shaders/god_rays.nzsl diff --git a/bin/resources/lighting.nzsl b/assets/shaders/lighting.nzsl similarity index 100% rename from bin/resources/lighting.nzsl rename to assets/shaders/lighting.nzsl diff --git a/bin/resources/skybox.nzsl b/assets/shaders/skybox.nzsl similarity index 100% rename from bin/resources/skybox.nzsl rename to assets/shaders/skybox.nzsl diff --git a/bin/resources/tone_mapping.nzsl b/assets/shaders/tone_mapping.nzsl similarity index 100% rename from bin/resources/tone_mapping.nzsl rename to assets/shaders/tone_mapping.nzsl diff --git a/assets/tests_version.txt b/assets/tests_version.txt new file mode 100644 index 000000000..56a6051ca --- /dev/null +++ b/assets/tests_version.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/bin/resources/Engine/Audio/Cat.flac.REMOVED.git-id b/bin/resources/Engine/Audio/Cat.flac.REMOVED.git-id deleted file mode 100644 index a686bc57d..000000000 --- a/bin/resources/Engine/Audio/Cat.flac.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -6993cbcca9ac596667135cb0f30bea4841178d3b \ No newline at end of file diff --git a/bin/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id b/bin/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id deleted file mode 100644 index bfd8dbd70..000000000 --- a/bin/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -94b2c47c9143adbac0fb7e81df5cc87f969f7150 \ No newline at end of file diff --git a/bin/resources/Engine/Audio/copyrights.txt b/bin/resources/Engine/Audio/copyrights.txt deleted file mode 100644 index 7b01b7090..000000000 --- a/bin/resources/Engine/Audio/copyrights.txt +++ /dev/null @@ -1,54 +0,0 @@ -The_Brabanconne.ogg - -https://en.wikipedia.org/wiki/File:The_Brabanconne.ogg - -Original file: -The_Brabanconne.ogg ‎(Ogg Vorbis sound file, length 1 min 3 s, 378 kbps) - -Summary: - -Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3. -Date: 19 October 2004 -Source: http://www.navyband.navy.mil/anthems/national_anthems.htm -Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald - -Licencing: - -This file is a work of a sailor or employee of the U.S. Navy, taken or made as part of that person's official duties. As a work of the U.S. federal government, the image is in the public domain. -This file has been identified as being free of known restrictions under copyright law, including all related and neighboring rights. - -------------------------------------------------------------------------------------------------- - -Cat.flac: - -http://www.freesound.org/people/EARR/sounds/148013/ - -Original file: -148013__earr__angry-cat.flac (Flac sound file, length 8 s, 96000 Hz, 24 bit depth) - -Author: - -EARR - -Description: - -Slightly angry cat. She is a beautiful Siamese cat called Agostina. She is angry for the recording because i pressed his tail. - -Information about the recording and equipment: - --Location: Living room. --Type of acoustic environment: Small, diffuse, moderately reflective. --Distance from sound source to microphones: Approx a few centimeters. --Miking technique: Jecklin disk. - --Microphones: 2 Brüel & Kjaer type 4190 capsules with type 2669L head amplifier. --Microphone preamps: Modified Brüel & Kjaer type 5935L. --ADC: Echo Audiofire 4. (line inputs 3 & 4). --Recorder: Echo Audiofire 4 and Dell D630C running Samplitude 10. - -Eq: Compensation only for the response of the microphones (In this case for flat response at 60º. See Brüel & Kjaer type 4190 datasheet). -No reverb, no compression, no fx. - -Licencing: - -Creative commons diff --git a/bin/resources/Engine/Core/FileTest.txt b/bin/resources/Engine/Core/FileTest.txt deleted file mode 100644 index 345e6aef7..000000000 --- a/bin/resources/Engine/Core/FileTest.txt +++ /dev/null @@ -1 +0,0 @@ -Test diff --git a/bin/resources/Engine/Graphics/Bob lamp/Readme.txt b/bin/resources/Engine/Graphics/Bob lamp/Readme.txt deleted file mode 100644 index bd605ec7d..000000000 --- a/bin/resources/Engine/Graphics/Bob lamp/Readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -############################# -MD5 sample mesh and animation -############################# - -INFORMATION & USAGE -=================== -File includes *.blend source files and TGA format textures for MD5 animated mesh testing. -For extensive information and usage instructions visit http://www.katsbits.com/smforum/index.php?topic=178.0 - - - bob_lamp_update.blend contain mesh and armature as would be prior to preparation for export. - - bob_lamp_update_export contains triangulated mesh ready for export. - -NOTES -===== -Included files are for use in **Blender 2.69** or above; opening files in older versions may result in errors dues to internal differences between Blender versions. -Files and media are provided "as is" without any warranties of functionality. - -COPYRIGHT & DISTRIBUTION -======================== -Copyright © 2014 KatsBits. All Rights Reserved. -For more information visit http://www.katsbits.com/ or email info@katsbits.com - -For NON-COMMERCIAL USE ONLY. This file and/or its contents and/or associated materials may not be reproduced, duplicated, distributed or otherwise 'monetised' without prior consent. -Contact info@katsbits.com or visit http://copyright.katsbits.com/ for further details regarding this material and/or distribution/copyright. diff --git a/bin/resources/Engine/Graphics/copyrights.txt b/bin/resources/Engine/Graphics/copyrights.txt deleted file mode 100644 index 7cd13413c..000000000 --- a/bin/resources/Engine/Graphics/copyrights.txt +++ /dev/null @@ -1,82 +0,0 @@ -skybox.png - -https://commons.wikimedia.org/wiki/File:Skybox_example.png - -Original file: -Skybox example.ogg ‎(Ogg Vorbis sound file, length 1 min 3 s, 378 kbps) - -Summary: - -Description: English: An example of a skybox and how the faces can be aligned -Date: 8 June 2011 -Source: Own work -Author: Creator:Arieee - -Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3. -Date: 19 October 2004 -Source: http://www.navyband.navy.mil/anthems/national_anthems.htm -Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald - -Licencing: - -This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. - - You are free: - - to share – to copy, distribute and transmit the work - to remix – to adapt the work - - Under the following conditions: - - attribution – You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). - share alike – If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. - -------------------------------------------------------------------------------------------------- - -Bob lamp - -http://www.katsbits.com/download/models/md5-example.php - -Original file: -bob_lamp_update.zip (Animated MD5 sample file) - -Summary: - -Description: Updated version of "Bob", a low-poly character mesh for general export and testing of MD5 mesh and animation - "*.md5mesh" and "*.md5anim". File and it's contents should be opened in Blender 2.69 or above to avoid compatibility issues with older versions of Blender and/or resulting MD5 exports (md5mesh & md5anim). - -File includes two versions of the source file, one 'working' - mesh is intact with surfaces in 'quad' form; and one 'prepped' (exported) - mesh has been tessilated (triangulated) for export. -Date: Januari 2014 -Source: http://www.katsbits.com/download/models/md5-example.php -Author: KatsBits - -Licencing: - -Please, refer to "Bob lamp/Readme.txt" file. - -------------------------------------------------------------------------------------------------- - -Standford dragon - -http://graphics.stanford.edu/data/3Dscanrep/ - -Original file: -dragon_recon.tar.gz (PLY files) - -Summary: - -Dragon -Source: Stanford University Computer Graphics Laboratory -Scanner: Cyberware 3030 MS + spacetime analysis -Number of scans: ~70 -Total size of scans: 2,748,318 points (about 5,500,000 triangles) -Reconstruction: vrip (conservatively decimated) -Size of reconstruction: 566,098 vertices, 1,132,830 triangles -Comments: contains numerous small holes -Date: 1996 -Source: http://graphics.stanford.edu/data/3Dscanrep/ -Author: Stanford University Computer Graphics Laboratory - -Licencing: - -Please be sure to acknowledge the source of the data and models you take from this repository. In each of the listings below, we have cited the source of the range data and reconstructed models. You are welcome to use the data and models for research purposes. You are also welcome to mirror or redistribute them for free. Finally, you may publish images made using these models, or the images on this web site, in a scholarly article or book - as long as credit is given to the Stanford Computer Graphics Laboratory. However, such models or images are not to be used for commercial purposes, nor should they appear in a product for sale (with the exception of scholarly journals or books), without our permission. -Please, refer to "dragon_recon/README" file. diff --git a/bin/resources/Engine/Graphics/dragon_recon/README b/bin/resources/Engine/Graphics/dragon_recon/README deleted file mode 100644 index af64a50fe..000000000 --- a/bin/resources/Engine/Graphics/dragon_recon/README +++ /dev/null @@ -1,27 +0,0 @@ - Surface Reconstructions - - Stanford Range Repository - Computer Graphics Laboratory - Stanford University - - August 4, 1996 - - -These files are the result of reconstructing a set of range images -using the "vrip" program. The first file is the high resolution -result, while the "_res*" files are decimated versions. Note that -these decimations were performed using a crude algorithm that does not -necessarily preserve mesh topology. While they are not beautiful, -they are suitable for interactive rendering. - -Note that this model is a decimated version of the original which was -constructed at the voxel resolution of 0.35 mm. The original model -has no holes in it, however, the decimated model has some holes that -we detected with software, but not by inspection. Apparently, the -decimation software introduced these holes. - -For more information, consult the web pages of the Stanford Graphics -Laboratory: - - http://www-graphics.stanford.edu - diff --git a/bin/resources/Spaceship/readme.txt b/bin/resources/Spaceship/readme.txt deleted file mode 100644 index 6fb633ac9..000000000 --- a/bin/resources/Spaceship/readme.txt +++ /dev/null @@ -1 +0,0 @@ -http://thefree3dmodels.com/stuff/aircraft/spaceship/15-1-0-1415 \ No newline at end of file diff --git a/bin/resources/Tests/GIF/canvas_bgnd.gif b/bin/resources/Tests/GIF/canvas_bgnd.gif deleted file mode 100644 index d68504010..000000000 Binary files a/bin/resources/Tests/GIF/canvas_bgnd.gif and /dev/null differ diff --git a/bin/resources/Tests/GIF/canvas_prev.gif b/bin/resources/Tests/GIF/canvas_prev.gif deleted file mode 100644 index 0de7760e9..000000000 Binary files a/bin/resources/Tests/GIF/canvas_prev.gif and /dev/null differ diff --git a/bin/resources/file_example_MP3_700KB.txt b/bin/resources/file_example_MP3_700KB.txt deleted file mode 100644 index fca4d8ad8..000000000 --- a/bin/resources/file_example_MP3_700KB.txt +++ /dev/null @@ -1 +0,0 @@ -https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/ \ No newline at end of file diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index 971696adb..4f6ed1b1e 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -65,9 +65,13 @@ struct SpotLight int main() { - std::filesystem::path resourceDir = "resources"; - if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir)) - resourceDir = ".." / resourceDir; + std::filesystem::path resourceDir = "assets/examples"; + if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir)) + resourceDir = "../.." / resourceDir; + + std::filesystem::path shaderDir = "assets/shaders"; + if (!std::filesystem::is_directory(shaderDir) && std::filesystem::is_directory("../.." / shaderDir)) + shaderDir = "../.." / shaderDir; Nz::Renderer::Config rendererConfig; std::cout << "Run using Vulkan? (y/n)" << std::endl; @@ -154,7 +158,7 @@ int main() skyboxPipelineInfo.faceCulling = true; skyboxPipelineInfo.cullingSide = Nz::FaceSide::Front; skyboxPipelineInfo.pipelineLayout = skyboxPipelineLayout; - skyboxPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "skybox.nzsl", states)); + skyboxPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "skybox.nzsl", states)); skyboxPipelineInfo.vertexBuffers.push_back({ 0, meshPrimitiveParams.vertexDeclaration @@ -187,8 +191,8 @@ int main() auto customSettings = Nz::BasicMaterial::GetSettings()->GetBuilderData(); customSettings.shaders.clear(); - customSettings.shaders.emplace_back(std::make_shared(nzsl::ShaderStageType::Fragment, nzsl::ParseFromFile(resourceDir / "deferred_frag.nzsl"))); - customSettings.shaders.emplace_back(std::make_shared(nzsl::ShaderStageType::Vertex, nzsl::ParseFromFile(resourceDir / "deferred_vert.nzsl"))); + customSettings.shaders.emplace_back(std::make_shared(nzsl::ShaderStageType::Fragment, nzsl::ParseFromFile(shaderDir / "deferred_frag.nzsl"))); + customSettings.shaders.emplace_back(std::make_shared(nzsl::ShaderStageType::Vertex, nzsl::ParseFromFile(shaderDir / "deferred_vert.nzsl"))); auto customMatSettings = std::make_shared(std::move(customSettings)); @@ -385,7 +389,7 @@ int main() fullscreenVertexDeclaration }); - fullscreenPipelineInfoViewer.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "bloom_bright.nzsl", states)); + fullscreenPipelineInfoViewer.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "bloom_bright.nzsl", states)); std::shared_ptr bloomBrightShaderBinding; @@ -409,7 +413,7 @@ int main() std::size_t gaussianBlurDataSize = gaussianBlurDataOffsets.AddField(nzsl::StructFieldType::Float1); gaussianBlurPipelineInfo.shaderModules.clear(); - gaussianBlurPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "gaussian_blur.nzsl", states)); + gaussianBlurPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "gaussian_blur.nzsl", states)); std::shared_ptr gaussianBlurPipeline = device->InstantiateRenderPipeline(gaussianBlurPipelineInfo); std::vector> gaussianBlurShaderBinding(BloomSubdivisionCount * 2); @@ -439,7 +443,7 @@ int main() std::shared_ptr toneMappingShaderBinding; fullscreenPipelineInfoViewer.shaderModules.clear(); - fullscreenPipelineInfoViewer.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "tone_mapping.nzsl", states)); + fullscreenPipelineInfoViewer.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "tone_mapping.nzsl", states)); std::shared_ptr toneMappingPipeline = device->InstantiateRenderPipeline(fullscreenPipelineInfoViewer); @@ -478,7 +482,7 @@ int main() fullscreenVertexDeclaration }); - bloomBlendPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "bloom_final.nzsl", states)); + bloomBlendPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "bloom_final.nzsl", states)); std::shared_ptr bloomBlendPipeline = device->InstantiateRenderPipeline(bloomBlendPipelineInfo); @@ -502,7 +506,7 @@ int main() fullscreenVertexDeclaration }); - fullscreenPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "gamma.nzsl", states)); + fullscreenPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "gamma.nzsl", states)); // God rays @@ -536,7 +540,7 @@ int main() fullscreenVertexDeclaration }); - godraysPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "god_rays.nzsl", states)); + godraysPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "god_rays.nzsl", states)); std::shared_ptr godraysPipeline = device->InstantiateRenderPipeline(godraysPipelineInfo); @@ -591,7 +595,7 @@ int main() lightingPipelineInfo.stencilBack.depthFail = Nz::StencilOperation::Zero; lightingPipelineInfo.stencilBack.pass = Nz::StencilOperation::Zero; - lightingPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "lighting.nzsl", states)); + lightingPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Fragment | nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "lighting.nzsl", states)); std::shared_ptr lightingPipeline = device->InstantiateRenderPipeline(lightingPipelineInfo); @@ -613,7 +617,7 @@ int main() stencilPipelineInfo.stencilBack.compare = Nz::RendererComparison::Always; stencilPipelineInfo.stencilBack.depthFail = Nz::StencilOperation::Invert; - stencilPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, resourceDir / "lighting.nzsl", states)); + stencilPipelineInfo.shaderModules.push_back(device->InstantiateShaderModule(nzsl::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraShader, shaderDir / "lighting.nzsl", states)); std::shared_ptr stencilPipeline = device->InstantiateRenderPipeline(stencilPipelineInfo); diff --git a/examples/DopplerEffect/main.cpp b/examples/DopplerEffect/main.cpp index b051b6f09..0498da58a 100644 --- a/examples/DopplerEffect/main.cpp +++ b/examples/DopplerEffect/main.cpp @@ -20,14 +20,14 @@ int main() { - std::filesystem::path resourceDir = "resources"; - if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir)) - resourceDir = ".." / resourceDir; + std::filesystem::path resourceDir = "assets/examples"; + if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir)) + resourceDir = "../.." / resourceDir; Nz::Modules audio; Nz::Sound sound; - if (!sound.LoadFromFile(resourceDir / "siren.wav")) + if (!sound.LoadFromFile(resourceDir / "Audio/siren.wav")) { std::cout << "Failed to load sound" << std::endl; std::getchar(); diff --git a/examples/GraphicsTest/main.cpp b/examples/GraphicsTest/main.cpp index 590d876b8..e6bd76849 100644 --- a/examples/GraphicsTest/main.cpp +++ b/examples/GraphicsTest/main.cpp @@ -10,9 +10,9 @@ int main() { - std::filesystem::path resourceDir = "resources"; - if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir)) - resourceDir = ".." / resourceDir; + std::filesystem::path resourceDir = "assets/examples"; + if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir)) + resourceDir = "../.." / resourceDir; Nz::Renderer::Config rendererConfig; std::cout << "Run using Vulkan? (y/n)" << std::endl; diff --git a/examples/Physics2DDemo/main.cpp b/examples/Physics2DDemo/main.cpp index 498490574..b0964e63f 100644 --- a/examples/Physics2DDemo/main.cpp +++ b/examples/Physics2DDemo/main.cpp @@ -23,9 +23,9 @@ NAZARA_REQUEST_DEDICATED_GPU() int main() { - std::filesystem::path resourceDir = "resources"; - if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir)) - resourceDir = ".." / resourceDir; + std::filesystem::path resourceDir = "assets/examples"; + if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir)) + resourceDir = "../.." / resourceDir; Nz::Renderer::Config rendererConfig; std::cout << "Run using Vulkan? (y/n)" << std::endl; diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index f4eb67459..cf85bcf05 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -22,9 +22,9 @@ NAZARA_REQUEST_DEDICATED_GPU() int main() { - std::filesystem::path resourceDir = "resources"; - if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir)) - resourceDir = ".." / resourceDir; + std::filesystem::path resourceDir = "assets/examples"; + if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir)) + resourceDir = "../.." / resourceDir; Nz::Renderer::Config rendererConfig; std::cout << "Run using Vulkan? (y/n)" << std::endl; diff --git a/examples/PlayMusic/main.cpp b/examples/PlayMusic/main.cpp index 97c1048a7..e52b10440 100644 --- a/examples/PlayMusic/main.cpp +++ b/examples/PlayMusic/main.cpp @@ -14,9 +14,9 @@ int main() { - std::filesystem::path resourceDir = "resources"; - if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir)) - resourceDir = ".." / resourceDir; + std::filesystem::path resourceDir = "assets/examples"; + if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir)) + resourceDir = "../.." / resourceDir; Nz::Modules audio; @@ -24,7 +24,7 @@ int main() streamParams.forceMono = false; Nz::Music music; - if (!music.OpenFromFile(resourceDir / "file_example_MP3_700KB.mp3", streamParams)) + if (!music.OpenFromFile(resourceDir / "Audio/file_example_MP3_700KB.mp3", streamParams)) { std::cout << "Failed to load sound" << std::endl; std::getchar(); diff --git a/examples/WidgetDemo/main.cpp b/examples/WidgetDemo/main.cpp index 0dd15f1fd..d6ef47501 100644 --- a/examples/WidgetDemo/main.cpp +++ b/examples/WidgetDemo/main.cpp @@ -23,9 +23,9 @@ NAZARA_REQUEST_DEDICATED_GPU() int main() { - std::filesystem::path resourceDir = "resources"; - if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory(".." / resourceDir)) - resourceDir = ".." / resourceDir; + std::filesystem::path resourceDir = "assets/examples"; + if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir)) + resourceDir = "../.." / resourceDir; Nz::Renderer::Config rendererConfig; std::cout << "Run using Vulkan? (y/n)" << std::endl; diff --git a/tests/Engine/Audio/MusicTest.cpp b/tests/Engine/Audio/MusicTest.cpp index 48bbadede..af48805f7 100644 --- a/tests/Engine/Audio/MusicTest.cpp +++ b/tests/Engine/Audio/MusicTest.cpp @@ -4,7 +4,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("Music", "[AUDIO][MUSIC]") { @@ -14,7 +14,7 @@ SCENARIO("Music", "[AUDIO][MUSIC]") WHEN("We load our music") { - REQUIRE(music.OpenFromFile(GetResourceDir() / "Engine/Audio/The_Brabanconne.ogg")); + REQUIRE(music.OpenFromFile(GetAssetDir() / "Audio/The_Brabanconne.ogg")); THEN("We can ask the informations of the file") { diff --git a/tests/Engine/Audio/SoundBufferTest.cpp b/tests/Engine/Audio/SoundBufferTest.cpp index a8c0865bf..40d92ec53 100644 --- a/tests/Engine/Audio/SoundBufferTest.cpp +++ b/tests/Engine/Audio/SoundBufferTest.cpp @@ -1,7 +1,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]") { @@ -9,7 +9,7 @@ SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]") { WHEN("We load a .flac file") { - std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetResourceDir() / "Engine/Audio/Cat.flac"); + std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetAssetDir() / "Audio/Cat.flac"); REQUIRE(soundBuffer); THEN("We can ask the informations of the file") @@ -22,7 +22,7 @@ SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]") WHEN("We load a .mp3 file") { - std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetResourceDir() / "file_example_MP3_700KB.mp3"); + std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetAssetDir() / "Audio/file_example_MP3_700KB.mp3"); REQUIRE(soundBuffer); THEN("We can ask the informations of the file") @@ -35,7 +35,7 @@ SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]") WHEN("We load a .ogg file") { - std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetResourceDir() / "Engine/Audio/The_Brabanconne.ogg"); + std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetAssetDir() / "Audio/The_Brabanconne.ogg"); REQUIRE(soundBuffer); THEN("We can ask the informations of the file") @@ -48,14 +48,14 @@ SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]") WHEN("We load a .wav file") { - std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetResourceDir() / "explosion.wav"); + std::shared_ptr soundBuffer = Nz::SoundBuffer::LoadFromFile(GetAssetDir() / "Audio/explosion1.wav"); REQUIRE(soundBuffer); THEN("We can ask the informations of the file") { - CHECK(soundBuffer->GetDuration() == 2064); - CHECK(soundBuffer->GetFormat() == Nz::AudioFormat::I16_Stereo); - CHECK(soundBuffer->GetSampleRate() == 48000); + CHECK(soundBuffer->GetDuration() == 2490); + CHECK(soundBuffer->GetFormat() == Nz::AudioFormat::I16_Mono); + CHECK(soundBuffer->GetSampleRate() == 44100); } } } diff --git a/tests/Engine/Audio/SoundEmitterTest.cpp b/tests/Engine/Audio/SoundEmitterTest.cpp index 9cad3f3a6..4061c1263 100644 --- a/tests/Engine/Audio/SoundEmitterTest.cpp +++ b/tests/Engine/Audio/SoundEmitterTest.cpp @@ -1,7 +1,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]") { @@ -11,7 +11,7 @@ SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]") WHEN("We load our sound") { - REQUIRE(sound.LoadFromFile(GetResourceDir() / "Engine/Audio/Cat.flac")); + REQUIRE(sound.LoadFromFile(GetAssetDir() / "Audio/Cat.flac")); THEN("We can ask information about position and velocity") { diff --git a/tests/Engine/Audio/SoundStreamTest.cpp b/tests/Engine/Audio/SoundStreamTest.cpp index bce87229e..58b7719d0 100644 --- a/tests/Engine/Audio/SoundStreamTest.cpp +++ b/tests/Engine/Audio/SoundStreamTest.cpp @@ -1,7 +1,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("SoundStream", "[AUDIO][SoundStream]") { @@ -9,7 +9,7 @@ SCENARIO("SoundStream", "[AUDIO][SoundStream]") { WHEN("We load a .flac file") { - std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetResourceDir() / "Engine/Audio/Cat.flac"); + std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetAssetDir() / "Audio/Cat.flac"); REQUIRE(soundStream); THEN("We can ask the informations of the file") @@ -22,7 +22,7 @@ SCENARIO("SoundStream", "[AUDIO][SoundStream]") WHEN("We load a .mp3 file") { - std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetResourceDir() / "file_example_MP3_700KB.mp3"); + std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetAssetDir() / "Audio/file_example_MP3_700KB.mp3"); REQUIRE(soundStream); THEN("We can ask the informations of the file") @@ -35,7 +35,7 @@ SCENARIO("SoundStream", "[AUDIO][SoundStream]") WHEN("We load a .ogg file") { - std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetResourceDir() / "Engine/Audio/The_Brabanconne.ogg"); + std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetAssetDir() / "Audio/The_Brabanconne.ogg"); REQUIRE(soundStream); THEN("We can ask the informations of the file") @@ -48,14 +48,14 @@ SCENARIO("SoundStream", "[AUDIO][SoundStream]") WHEN("We load a .wav file") { - std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetResourceDir() / "explosion.wav"); + std::shared_ptr soundStream = Nz::SoundStream::OpenFromFile(GetAssetDir() / "Audio/explosion1.wav"); REQUIRE(soundStream); THEN("We can ask the informations of the file") { - CHECK(soundStream->GetDuration() == 2064); - CHECK(soundStream->GetFormat() == Nz::AudioFormat::I16_Stereo); - CHECK(soundStream->GetSampleRate() == 48000); + CHECK(soundStream->GetDuration() == 2490); + CHECK(soundStream->GetFormat() == Nz::AudioFormat::I16_Mono); + CHECK(soundStream->GetSampleRate() == 44100); } } } diff --git a/tests/Engine/Audio/SoundTest.cpp b/tests/Engine/Audio/SoundTest.cpp index 99e29a93d..cb71dd737 100644 --- a/tests/Engine/Audio/SoundTest.cpp +++ b/tests/Engine/Audio/SoundTest.cpp @@ -4,7 +4,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("Sound", "[AUDIO][SOUND]") { @@ -14,7 +14,7 @@ SCENARIO("Sound", "[AUDIO][SOUND]") WHEN("We load our sound") { - REQUIRE(sound.LoadFromFile(GetResourceDir() / "Engine/Audio/Cat.flac")); + REQUIRE(sound.LoadFromFile(GetAssetDir() / "Audio/Cat.flac")); THEN("We can ask the informations of the file") { diff --git a/tests/Engine/Core/AlgorithmCoreTest.cpp b/tests/Engine/Core/AlgorithmCoreTest.cpp index 5f517c87d..ebccb0b46 100644 --- a/tests/Engine/Core/AlgorithmCoreTest.cpp +++ b/tests/Engine/Core/AlgorithmCoreTest.cpp @@ -7,11 +7,11 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); TEST_CASE("ComputeHash", "[CORE][ALGORITHM]") { - std::filesystem::path testFilePath = GetResourceDir() / "Logo.png"; + std::filesystem::path testFilePath = GetAssetDir() / "Logo.png"; struct Test { diff --git a/tests/Engine/Core/FileTest.cpp b/tests/Engine/Core/FileTest.cpp index fb915b768..33d0833d0 100644 --- a/tests/Engine/Core/FileTest.cpp +++ b/tests/Engine/Core/FileTest.cpp @@ -1,7 +1,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("File", "[CORE][FILE]") { @@ -65,9 +65,9 @@ SCENARIO("File", "[CORE][FILE]") GIVEN("The test file") { - REQUIRE(std::filesystem::exists(GetResourceDir() / "Engine/Core/FileTest.txt")); + REQUIRE(std::filesystem::exists(GetAssetDir() / "Core/FileTest.txt")); - Nz::File fileTest(GetResourceDir() / "Engine/Core/FileTest.txt", Nz::OpenMode::ReadOnly | Nz::OpenMode::Text); + Nz::File fileTest(GetAssetDir() / "Core/FileTest.txt", Nz::OpenMode::ReadOnly | Nz::OpenMode::Text); WHEN("We read the first line of the file") { diff --git a/tests/Engine/Core/VirtualDirectoryTest.cpp b/tests/Engine/Core/VirtualDirectoryTest.cpp index e9613ea95..f46d239d2 100644 --- a/tests/Engine/Core/VirtualDirectoryTest.cpp +++ b/tests/Engine/Core/VirtualDirectoryTest.cpp @@ -6,7 +6,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); TEST_CASE("VirtualDirectory", "[Core][VirtualDirectory]") { @@ -187,7 +187,7 @@ TEST_CASE("VirtualDirectory", "[Core][VirtualDirectory]") SECTION("Accessing filesystem using a VirtualDirectory") { - std::shared_ptr resourceDir = std::make_shared(GetResourceDir()); + std::shared_ptr resourceDir = std::make_shared(GetAssetDir()); WHEN("Iterating, it's not empty") { @@ -242,18 +242,18 @@ TEST_CASE("VirtualDirectory", "[Core][VirtualDirectory]") { CHECK(CheckFileHash(resourceDir, "Logo.png", "5C4B9387327C039A6CE9ED51983D6C2ADA9F9DD01D024C2D5D588237ADFC7423")); CHECK(CheckFileHash(resourceDir, "./Logo.png", "5C4B9387327C039A6CE9ED51983D6C2ADA9F9DD01D024C2D5D588237ADFC7423")); - CHECK(CheckFileHash(resourceDir, "Engine/Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); - CHECK(CheckFileHash(resourceDir, "Engine/Audio/./The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK(CheckFileHash(resourceDir, "Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK(CheckFileHash(resourceDir, "Audio/./The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); CHECK_FALSE(CheckFileHash(resourceDir, "The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); - CHECK_FALSE(CheckFileHash(resourceDir, "Engine/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); - CHECK_FALSE(CheckFileHash(resourceDir, "Engine/Audio/../The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK_FALSE(CheckFileHash(resourceDir, "The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK_FALSE(CheckFileHash(resourceDir, "Audio/../The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); // We can't escape the virtual directory CHECK(CheckFileHash(resourceDir, "../Logo.png", "5C4B9387327C039A6CE9ED51983D6C2ADA9F9DD01D024C2D5D588237ADFC7423")); CHECK(CheckFileHash(resourceDir, "../../Logo.png", "5C4B9387327C039A6CE9ED51983D6C2ADA9F9DD01D024C2D5D588237ADFC7423")); - CHECK(CheckFileHash(resourceDir, "Engine/../Engine/Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); - CHECK(CheckFileHash(resourceDir, "../Engine/./Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); - CHECK_FALSE(CheckFileHash(resourceDir, "../Engine/Engine/Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK(CheckFileHash(resourceDir, "../../Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK(CheckFileHash(resourceDir, ".././Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK_FALSE(CheckFileHash(resourceDir, "../Tests/Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); auto CheckOurselves = [&](const auto& entry) { @@ -266,37 +266,38 @@ TEST_CASE("VirtualDirectory", "[Core][VirtualDirectory]") CHECK(resourceDir->GetEntry("../..", CheckOurselves)); CHECK(resourceDir->GetEntry("./..", CheckOurselves)); CHECK(resourceDir->GetEntry("./..", CheckOurselves)); - CHECK(resourceDir->GetEntry("Engine/../..", CheckOurselves)); - CHECK(resourceDir->GetEntry("Engine/../Engine/Audio/../../..", CheckOurselves)); + CHECK(resourceDir->GetEntry("Audio/../..", CheckOurselves)); + CHECK(resourceDir->GetEntry("Core/../Audio/../../..", CheckOurselves)); } AND_THEN("Overriding the physical file with another one") { - resourceDir->StoreFile("Logo.png", GetResourceDir() / "ambience.ogg"); - CHECK(CheckFileHash(resourceDir, "ambience.ogg", "49C486F44E43F023D54C9F375D902C21375DDB2748D3FA1863C9581D30E17F94")); + resourceDir->StoreFile("Logo.png", GetAssetDir() / "Audio/ambience.ogg"); + + CHECK(CheckFileHash(resourceDir, "Audio/ambience.ogg", "49C486F44E43F023D54C9F375D902C21375DDB2748D3FA1863C9581D30E17F94")); CHECK(CheckFileHash(resourceDir, "Logo.png", "49C486F44E43F023D54C9F375D902C21375DDB2748D3FA1863C9581D30E17F94")); - CHECK(CheckFileContentHash(resourceDir, "ambience.ogg", "49C486F44E43F023D54C9F375D902C21375DDB2748D3FA1863C9581D30E17F94")); + CHECK(CheckFileContentHash(resourceDir, "Audio/ambience.ogg", "49C486F44E43F023D54C9F375D902C21375DDB2748D3FA1863C9581D30E17F94")); CHECK(CheckFileContentHash(resourceDir, "Logo.png", "49C486F44E43F023D54C9F375D902C21375DDB2748D3FA1863C9581D30E17F94")); } WHEN("Testing uproot escape") { - std::shared_ptr engineDir = std::make_shared(GetResourceDir() / "Engine"); + std::shared_ptr engineDir = std::make_shared(GetAssetDir() / "Audio"); CHECK_FALSE(engineDir->IsUprootAllowed()); // We can't escape the virtual directory CHECK_FALSE(engineDir->Exists("../Logo.png")); CHECK_FALSE(engineDir->Exists("../../Logo.png")); - CHECK_FALSE(engineDir->Exists("../Engine/Audio/Audio/The_Brabanconne.ogg")); - CHECK(CheckFileHash(engineDir, "Audio/../../Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); - CHECK(CheckFileHash(engineDir, "../Audio/./The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK_FALSE(engineDir->Exists("../Tests/Audio/Audio/The_Brabanconne.ogg")); + CHECK(CheckFileHash(engineDir, "../../The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK(CheckFileHash(engineDir, ".././The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); engineDir->AllowUproot(true); CHECK(engineDir->IsUprootAllowed()); - // Now we're able to access the resource folder beneath + // Now we're able to access the asset folder beneath CHECK(CheckFileHash(engineDir, "../Logo.png", "5C4B9387327C039A6CE9ED51983D6C2ADA9F9DD01D024C2D5D588237ADFC7423")); - CHECK(CheckFileHash(engineDir, "../Engine/Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); + CHECK(CheckFileHash(engineDir, "../Audio/The_Brabanconne.ogg", "E07706E0BEEC7770CDE36008826743AF9EEE5C80CA0BD83C37771CBC8B52E738")); } } } diff --git a/tests/Engine/Utility/FontLoading.cpp b/tests/Engine/Utility/FontLoading.cpp index bec12dac5..81e83cb68 100644 --- a/tests/Engine/Utility/FontLoading.cpp +++ b/tests/Engine/Utility/FontLoading.cpp @@ -5,7 +5,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("Fonts", "[Utility][Font]") { diff --git a/tests/Engine/Utility/ImageLoading.cpp b/tests/Engine/Utility/ImageLoading.cpp index 259b70e45..2ce9e5263 100644 --- a/tests/Engine/Utility/ImageLoading.cpp +++ b/tests/Engine/Utility/ImageLoading.cpp @@ -2,7 +2,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("Images", "[Utility][Image]") { @@ -10,7 +10,7 @@ SCENARIO("Images", "[Utility][Image]") { GIVEN("Logo.png") { - std::shared_ptr logo = Nz::Image::LoadFromFile(GetResourceDir() / "Logo.png"); + std::shared_ptr logo = Nz::Image::LoadFromFile(GetAssetDir() / "Logo.png"); REQUIRE(logo); CHECK(logo->GetWidth() == 765); @@ -26,7 +26,7 @@ SCENARIO("Images", "[Utility][Image]") { GIVEN("stars-background.jpg") { - std::shared_ptr background = Nz::Image::LoadFromFile(GetResourceDir() / "stars-background.jpg"); + std::shared_ptr background = Nz::Image::LoadFromFile(GetAssetDir() / "Utility/stars-background.jpg"); REQUIRE(background); CHECK(background->GetWidth() == 1920); diff --git a/tests/Engine/Utility/ImageStreamLoading.cpp b/tests/Engine/Utility/ImageStreamLoading.cpp index e3ab88ba3..7d973072c 100644 --- a/tests/Engine/Utility/ImageStreamLoading.cpp +++ b/tests/Engine/Utility/ImageStreamLoading.cpp @@ -4,7 +4,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); void CompareFrames(const Nz::ImageStream& gif, std::vector& frameData, const Nz::Image& referenceImage) { @@ -26,7 +26,7 @@ SCENARIO("Streamed images", "[Utility][ImageStream]") Nz::UInt64 time; }; - std::filesystem::path resourcePath = GetResourceDir(); + std::filesystem::path resourcePath = GetAssetDir(); WHEN("Loading GIF files") { @@ -34,28 +34,28 @@ SCENARIO("Streamed images", "[Utility][ImageStream]") { std::array expectedFrames = { ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_bgnd/0.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_bgnd/0.png"), 0 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_bgnd/1.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_bgnd/1.png"), 1000 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_bgnd/2.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_bgnd/2.png"), 2000 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_bgnd/3.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_bgnd/3.png"), 3000 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_bgnd/4.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_bgnd/4.png"), 4000 } }; - std::shared_ptr gif = Nz::ImageStream::OpenFromFile(resourcePath / "Tests/GIF/canvas_bgnd.gif"); + std::shared_ptr gif = Nz::ImageStream::OpenFromFile(resourcePath / "Utility/GIF/canvas_bgnd.gif"); REQUIRE(gif); Nz::Vector2ui size = gif->GetSize(); @@ -100,28 +100,28 @@ SCENARIO("Streamed images", "[Utility][ImageStream]") { std::array expectedFrames = { ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_prev/0.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_prev/0.png"), 0 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_prev/1.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_prev/1.png"), 100 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_prev/2.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_prev/2.png"), 1100 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_prev/3.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_prev/3.png"), 2100 }, ExpectedFrame{ - Nz::Image::LoadFromFile(resourcePath / "Tests/GIF/canvas_prev/4.png"), + Nz::Image::LoadFromFile(resourcePath / "Utility/GIF/canvas_prev/4.png"), 3100 } }; - std::shared_ptr gif = Nz::ImageStream::OpenFromFile(resourcePath / "Tests/GIF/canvas_prev.gif"); + std::shared_ptr gif = Nz::ImageStream::OpenFromFile(resourcePath / "Utility/GIF/canvas_prev.gif"); REQUIRE(gif); Nz::Vector2ui size = gif->GetSize(); diff --git a/tests/Engine/Utility/MeshLoading.cpp b/tests/Engine/Utility/MeshLoading.cpp index 1238b9d85..9556f9fb5 100644 --- a/tests/Engine/Utility/MeshLoading.cpp +++ b/tests/Engine/Utility/MeshLoading.cpp @@ -2,7 +2,7 @@ #include #include -std::filesystem::path GetResourceDir(); +std::filesystem::path GetAssetDir(); SCENARIO("Meshes", "[Utility][Mesh]") { @@ -10,7 +10,7 @@ SCENARIO("Meshes", "[Utility][Mesh]") { GIVEN("Spaceship/spaceship.obj") { - std::shared_ptr spaceship = Nz::Mesh::LoadFromFile(GetResourceDir() / "Spaceship/spaceship.obj"); + std::shared_ptr spaceship = Nz::Mesh::LoadFromFile(GetAssetDir() / "Utility/Spaceship/spaceship.obj"); REQUIRE(spaceship); CHECK(!spaceship->IsAnimable()); @@ -22,7 +22,7 @@ SCENARIO("Meshes", "[Utility][Mesh]") GIVEN("SpaceStation/space_station.obj") { - std::shared_ptr spacestation = Nz::Mesh::LoadFromFile(GetResourceDir() / "SpaceStation/space_station.obj"); + std::shared_ptr spacestation = Nz::Mesh::LoadFromFile(GetAssetDir() / "Utility/SpaceStation/space_station.obj"); REQUIRE(spacestation); CHECK(!spacestation->IsAnimable()); @@ -37,7 +37,7 @@ SCENARIO("Meshes", "[Utility][Mesh]") { GIVEN("drfreak.md2") { - std::shared_ptr drfreak = Nz::Mesh::LoadFromFile(GetResourceDir() / "drfreak.md2"); + std::shared_ptr drfreak = Nz::Mesh::LoadFromFile(GetAssetDir() / "Utility/drfreak/drfreak.md2"); CHECK(drfreak); CHECK(!drfreak->IsAnimable()); //< non-skeletal animations are not supported diff --git a/tests/resources.cpp b/tests/resources.cpp index 01ddc41ab..9ea1fd50e 100644 --- a/tests/resources.cpp +++ b/tests/resources.cpp @@ -1,15 +1,15 @@ #include -std::filesystem::path GetResourceDir() +std::filesystem::path GetAssetDir() { static std::filesystem::path resourceDir = [] { - std::filesystem::path dir = "resources"; - if (!std::filesystem::is_directory(dir) && std::filesystem::is_directory(".." / dir)) - return ".." / dir; - else - return dir; + std::filesystem::path dir = "assets"; + if (!std::filesystem::is_directory(dir) && std::filesystem::is_directory("../.." / dir)) + dir = "../.." / dir; + return dir / "tests"; }(); + return resourceDir; } diff --git a/xmake.lua b/xmake.lua index 399185d1c..8a9eb7d6c 100644 --- a/xmake.lua +++ b/xmake.lua @@ -154,7 +154,12 @@ end add_rules("mode.asan", "mode.coverage", "mode.debug", "mode.releasedbg") add_rules("plugin.vsxmake.autoupdate") -add_rules("build_rendererplugins") +add_rules("build.rendererplugins") +add_rules("download.assets.examples") + +if has_config("tests") then + add_rules("download.assets.tests") +end set_allowedplats("windows", "mingw", "linux", "macosx") set_allowedarchs("windows|x64", "mingw|x86_64", "linux|x86_64", "macosx|x86_64") @@ -162,7 +167,7 @@ set_allowedmodes("debug", "releasedbg", "asan", "coverage") set_defaultmode("debug") if is_mode("debug") then - add_rules("debug_suffix") + add_rules("debug.suffix") elseif is_mode("asan") then set_optimize("none") -- by default xmake will optimize asan builds elseif is_mode("coverage") then @@ -258,11 +263,11 @@ for name, module in pairs(modules) do local embedResourceRule = false for _, filepath in pairs(os.files("src/Nazara/" .. name .. "/Resources/**|**.h|**.nzsl|**.nzslb")) do if not embedResourceRule then - add_rules("embed_resources") + add_rules("embed.resources") embedResourceRule = true end - add_files(filepath, {rule = "embed_resources"}) + add_files(filepath, {rule = "embed.resources"}) end end @@ -270,11 +275,11 @@ for name, module in pairs(modules) do local compileShaderRule = false for _, filepath in pairs(os.files("src/Nazara/" .. name .. "/Resources/**.nzsl")) do if not compileShaderRule then - add_rules("compile_shaders") + add_rules("nzsl.compile.shaders") compileShaderRule = true end - add_files(filepath, {rule = "compile_shaders"}) + add_files(filepath, {rule = "nzsl.compile.shaders"}) end end diff --git a/xmake/rules/compile_shaders.lua b/xmake/rules/compile_shaders.lua index 3230c6e62..f7568c42b 100644 --- a/xmake/rules/compile_shaders.lua +++ b/xmake/rules/compile_shaders.lua @@ -1,5 +1,5 @@ -- Compile shaders to includables headers -rule("compile_shaders") +rule("nzsl.compile.shaders") on_load(function (target) target:add("packages", "nzsl") end) diff --git a/xmake/rules/debug_suffix.lua b/xmake/rules/debug_suffix.lua index f1fd4d2f5..85b60b7b7 100644 --- a/xmake/rules/debug_suffix.lua +++ b/xmake/rules/debug_suffix.lua @@ -1,7 +1,7 @@ -- Adds -d as a debug suffix -rule("debug_suffix") +rule("debug.suffix") on_load(function (target) if target:kind() ~= "binary" then - target:set("basename", target:basename() .. "-d") + target:set("suffixname", "-d") end end) diff --git a/xmake/rules/download_assets.lua b/xmake/rules/download_assets.lua new file mode 100644 index 000000000..ba3efc743 --- /dev/null +++ b/xmake/rules/download_assets.lua @@ -0,0 +1,42 @@ +local baseDownloadURL = "https://nazara.digitalpulse.software" + +local function downloadAssetsRule(name) + rule("download.assets." .. name) + set_kind("project") + before_build(function (opt) + import("net.http") + import("utils.archive") + + local referenceVersion = io.readfile("assets/" .. name .. "_version.txt") + local currentVersion = os.exists("assets/" .. name .. "/version.txt") and io.readfile("assets/" .. name .. "/version.txt") + if referenceVersion == currentVersion then + utils.vprintf(name .. " assets are up-to-date, ignoring\n") + return + end + + local text = {} + table.insert(text, currentVersion and "update " or "download ") + table.insert(text, name) + table.insert(text, " assets?") + if currentVersion then + table.insert(text, " current version is " .. currentVersion .. " and remote version is " .. referenceVersion) + end + table.insert(text, "\nthis is required to run them") + + local confirm = utils.confirm({description = table.concat(text), default = true}) + if not confirm then + utils.vprintf("aborting " .. name .. " assets downloading\n") + return + end + + os.rm("assets/" .. name) + http.download(baseDownloadURL .. "/assets_" .. name .. ".zip", "assets_" .. name .. ".zip") + archive.extract("assets_" .. name .. ".zip", "assets") + os.rm("assets_" .. name .. ".zip") + + print(name .. " assets downloaded!") + end) +end + +downloadAssetsRule("examples") +downloadAssetsRule("tests") \ No newline at end of file diff --git a/xmake/rules/embed_resources.lua b/xmake/rules/embed_resources.lua index d1b12268d..58a91e620 100644 --- a/xmake/rules/embed_resources.lua +++ b/xmake/rules/embed_resources.lua @@ -1,5 +1,5 @@ -- Turns resources into includables headers -rule("embed_resources") +rule("embed.resources") before_build(function (target, opt) import("core.base.option") if xmake.version():ge("2.5.9") then @@ -42,7 +42,7 @@ rule("embed_resources") end for _, sourcebatch in pairs(target:sourcebatches()) do - if sourcebatch.rulename == "embed_resources" then + if sourcebatch.rulename == "embed.resources" then for _, sourcefile in ipairs(sourcebatch.sourcefiles) do local targetpath = sourcefile .. ".h" if option.get("rebuild") or os.mtime(sourcefile) >= os.mtime(targetpath) then diff --git a/xmake/rules/renderer_plugins.lua b/xmake/rules/renderer_plugins.lua index aa0e56a23..d7634c01f 100644 --- a/xmake/rules/renderer_plugins.lua +++ b/xmake/rules/renderer_plugins.lua @@ -1,7 +1,7 @@ local modules = NazaraModules -- Builds renderer plugins if linked to NazaraRenderer -rule("build_rendererplugins") +rule("build.rendererplugins") on_load(function (target) local deps = table.wrap(target:get("deps"))