-
-
Save voidproc/9769389be475222adadd373214c094bc to your computer and use it in GitHub Desktop.
Load all textures in specified directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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