1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
---|---|
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #include "Importer/BsShaderIncludeImporter.h" |
4 | #include "Material/BsShaderInclude.h" |
5 | #include "FileSystem/BsDataStream.h" |
6 | #include "FileSystem/BsFileSystem.h" |
7 | |
8 | namespace bs |
9 | { |
10 | bool ShaderIncludeImporter::isExtensionSupported(const String& ext) const |
11 | { |
12 | String lowerCaseExt = ext; |
13 | StringUtil::toLowerCase(lowerCaseExt); |
14 | |
15 | return lowerCaseExt == u8"bslinc"; |
16 | } |
17 | |
18 | bool ShaderIncludeImporter::isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const |
19 | { |
20 | return true; // Plain-text so I don't even check for magic number |
21 | } |
22 | |
23 | SPtr<Resource> ShaderIncludeImporter::import(const Path& filePath, SPtr<const ImportOptions> importOptions) |
24 | { |
25 | String includeString; |
26 | { |
27 | Lock fileLock = FileScheduler::getLock(filePath); |
28 | |
29 | SPtr<DataStream> stream = FileSystem::openFile(filePath); |
30 | includeString = stream->getAsString(); |
31 | } |
32 | |
33 | SPtr<ShaderInclude> gpuInclude = ShaderInclude::_createPtr(includeString); |
34 | |
35 | const String fileName = filePath.getFilename(false); |
36 | gpuInclude->setName(fileName); |
37 | |
38 | return gpuInclude; |
39 | } |
40 | } |