MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / Compile

Method Compile

Plugins/NativeEngine/Source/ShaderCompilerOpenGL.cpp:170–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168 }
169
170 void ShaderCompiler::Compile(std::string_view vertexSource, std::string_view fragmentSource, std::function<void(ShaderInfo, ShaderInfo)> onCompiled)
171 {
172 glslang::TProgram program;
173
174 glslang::TShader vertexShader{EShLangVertex};
175 AddShader(program, vertexShader, vertexSource);
176
177 glslang::TShader fragmentShader{EShLangFragment};
178 AddShader(program, fragmentShader, fragmentSource);
179
180 if (!program.link(EShMsgDefault))
181 {
182 throw std::exception();
183 }
184
185 std::string vertexGLSL(vertexSource.data(), vertexSource.size());
186 auto vertexCompiler = CompileShader(program, EShLangVertex, vertexGLSL);
187
188 std::string fragmentGLSL(fragmentSource.data(), fragmentSource.size());
189 auto fragmentCompiler = CompileShader(program, EShLangFragment, fragmentGLSL);
190
191 uint8_t* strVertex = (uint8_t*)vertexGLSL.data();
192 uint8_t* strFragment = (uint8_t*)fragmentGLSL.data();
193 onCompiled(
194 {std::move(vertexCompiler), gsl::make_span(strVertex, vertexGLSL.size())},
195 {std::move(fragmentCompiler), gsl::make_span(strFragment, fragmentGLSL.size())});
196 }
197}

Callers

nothing calls this directly

Calls 2

AddShaderFunction · 0.70
CompileShaderFunction · 0.70

Tested by

no test coverage detected