Skip to content

Instantly share code, notes, and snippets.

@voidproc
Created January 8, 2017 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidproc/9769389be475222adadd373214c094bc to your computer and use it in GitHub Desktop.
Save voidproc/9769389be475222adadd373214c094bc to your computer and use it in GitHub Desktop.
Load all textures in specified directory
#include <Siv3D.hpp>
void loadTextures(const FilePath directory)
{
Array<FilePath> contents = FileSystem::DirectoryContents(directory);
for (auto path : contents)
{
if (FileSystem::IsFile(path) && FileSystem::Extension(path) == L"png")
{
TextureAsset::Register(FileSystem::BaseName(path), path);
}
}
}
void Main()
{
// Load "Assets/image1.png", "Assets/image2.png", "Assets/image3.png"
loadTextures(L"Assets");
while (System::Update())
{
TextureAsset(L"image1").draw(0, 0);
TextureAsset(L"image2").draw(100, 0);
TextureAsset(L"image3").draw(200, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment