MCPcopy Create free account
hub / github.com/Kitware/VTK / DetachShader

Method DetachShader

Rendering/OpenGL2/vtkShaderProgram.cxx:306–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306bool vtkShaderProgram::DetachShader(const vtkShader* shader)
307{
308 if (shader->GetHandle() == 0)
309 {
310 this->Error = "Shader object was not initialized, cannot attach it.";
311 return false;
312 }
313 if (shader->GetType() == vtkShader::Unknown)
314 {
315 this->Error = "Shader object is of type Unknown and cannot be used.";
316 return false;
317 }
318 if (this->Handle == 0)
319 {
320 this->Error = "This shader prorgram has not been initialized yet.";
321 }
322
323 switch (shader->GetType())
324 {
325 case vtkShader::Vertex:
326 if (this->VertexShaderHandle != shader->GetHandle())
327 {
328 Error = "The supplied shader was not attached to this program.";
329 return false;
330 }
331 else
332 {
333 glDetachShader(static_cast<GLuint>(this->Handle), static_cast<GLuint>(shader->GetHandle()));
334 this->VertexShaderHandle = 0;
335 this->Linked = false;
336 return true;
337 }
338 case vtkShader::Fragment:
339 if (this->FragmentShaderHandle != shader->GetHandle())
340 {
341 this->Error = "The supplied shader was not attached to this program.";
342 return false;
343 }
344 else
345 {
346 glDetachShader(static_cast<GLuint>(this->Handle), static_cast<GLuint>(shader->GetHandle()));
347 this->FragmentShaderHandle = 0;
348 this->Linked = false;
349 return true;
350 }
351 case vtkShader::Geometry:
352#ifdef GL_GEOMETRY_SHADER
353 if (this->GeometryShaderHandle != shader->GetHandle())
354 {
355 this->Error = "The supplied shader was not attached to this program.";
356 return false;
357 }
358 else
359 {
360 glDetachShader(static_cast<GLuint>(this->Handle), static_cast<GLuint>(shader->GetHandle()));
361 this->GeometryShaderHandle = 0;
362 this->Linked = false;
363 return true;

Callers 1

Calls 2

GetHandleMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected