MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / fromComputeSource

Method fromComputeSource

pj_scene3D/widgets/src/gl/program.cpp:166–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166Program::Result Program::fromComputeSource(std::string_view comp_src) {
167 return withGlFunctions([comp_src](auto& functions) -> Program::Result {
168 std::string error;
169 const GLuint comp_shader = compileShader(functions, GL_COMPUTE_SHADER, comp_src, "Compute", error);
170 if (comp_shader == 0U) {
171 return error;
172 }
173
174 const GLuint program = functions.glCreateProgram();
175 if (program == 0U) {
176 functions.glDeleteShader(comp_shader);
177 return std::string{"Failed to create compute program"};
178 }
179
180 functions.glAttachShader(program, comp_shader);
181 functions.glLinkProgram(program);
182
183 GLint link_status = GL_FALSE;
184 functions.glGetProgramiv(program, GL_LINK_STATUS, &link_status);
185
186 functions.glDetachShader(program, comp_shader);
187 functions.glDeleteShader(comp_shader);
188
189 if (link_status == GL_TRUE) {
190 return Program{program};
191 }
192
193 const std::string log = programInfoLog(functions, program);
194 functions.glDeleteProgram(program);
195 if (log.empty()) {
196 return std::string{"Compute program link failed"};
197 }
198 return fmt::format("Compute program link failed:\n{}", log);
199 });
200}
201
202void Program::use() {
203 withGlFunctions([this](auto& functions) { functions.glUseProgram(id_); });

Callers

nothing calls this directly

Calls 4

withGlFunctionsFunction · 0.85
compileShaderFunction · 0.85
programInfoLogFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected