File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ macro(daemon_embed_files BASENAME SLUG FORMAT TARGETNAME)
100100 "const std::unordered_map<std::string, std::string> FileMap\n {\n "
101101 "${EMBED_MAP_TEXT} "
102102 "};\n "
103+ "\n "
104+ "const char* ReadFile(Str::StringRef filename)\n "
105+ "{\n "
106+ " auto it = FileMap.find(filename);\n "
107+ " return it != FileMap.end() ? it->second.c_str() : nullptr;\n "
108+ "}\n "
103109 "}"
104110 )
105111
@@ -108,6 +114,7 @@ macro(daemon_embed_files BASENAME SLUG FORMAT TARGETNAME)
108114 "\n "
109115 "namespace ${BASENAME} {\n "
110116 "extern const std::unordered_map<std::string, std::string> FileMap;\n "
117+ "const char* ReadFile(Str::StringRef filename);\n "
111118 "};\n "
112119 )
113120
Original file line number Diff line number Diff line change @@ -90,14 +90,6 @@ namespace // Implementation details
9090 throw ShaderException (msg.c_str ());
9191 }
9292
93- const char * GetInternalShader (Str::StringRef filename)
94- {
95- auto it = EngineShaders::FileMap.find (filename);
96- if (it != EngineShaders::FileMap.end ())
97- return it->second .c_str ();
98- return nullptr ;
99- }
100-
10193 void CRLFToLF (std::string& source)
10294 {
10395 size_t sourcePos = 0 ;
@@ -160,7 +152,7 @@ namespace // Implementation details
160152 {
161153 // Look for the shader internally. If not found, look for it externally.
162154 // If found neither internally or externally of if empty, then Error.
163- auto text_ptr = GetInternalShader (filename);
155+ const char * text_ptr = EngineShaders::ReadFile (filename);
164156 if (text_ptr == nullptr )
165157 ThrowShaderError (Str::Format (" No shader found for shader: %s" , filename));
166158 return text_ptr;
@@ -182,7 +174,7 @@ namespace // Implementation details
182174 if (err)
183175 ThrowShaderError (Str::Format (" Failed to read shader from file %s: %s" , shaderFilename, err.message ()));
184176
185- auto textPtr = GetInternalShader (filename);
177+ const char * textPtr = EngineShaders::ReadFile (filename);
186178 std::string internalShaderText;
187179 if (textPtr != nullptr )
188180 internalShaderText = textPtr;
You can’t perform that action at this time.
0 commit comments