MCPcopy Create free account
hub / github.com/ImageEngine/cortex / bindIDShader

Method bindIDShader

src/IECoreGL/Selector.cpp:405–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403 }
404
405 void bindIDShader( const IECoreGL::Shader *shader )
406 {
407 if( shader == m_currentIDShader )
408 {
409 // early out to avoid the relatively expensive operations
410 // below if we've already loaded the shader.
411 return;
412 }
413
414 const IECoreGL::Shader::Parameter *nameParameter = shader->uniformParameter( "ieCoreGLNameIn" );
415 if( !nameParameter )
416 {
417 throw IECore::Exception( "ID shader does not have an ieCoreGLNameIn parameter" );
418 }
419
420 GLint fragDataLocation = glGetFragDataLocation( shader->program(), "ieCoreGLNameOut" );
421 if( fragDataLocation < 0 )
422 {
423 throw IECore::Exception( "ID shader does not have an ieCoreGLNameOut output" );
424 }
425
426 GLint depthDataLocation = 0;
427 if( m_useCameraDepth )
428 {
429 depthDataLocation = glGetFragDataLocation( shader->program(), "ieCoreGLCameraDepth" );
430 if( depthDataLocation < 0 )
431 {
432 throw IECore::Exception( "ID shader does not have ieCoreGLCameraDepth output" );
433 }
434 }
435
436 m_nameUniformLocation = nameParameter->location;
437
438 m_currentIDShader = shader;
439 glUseProgram( m_currentIDShader->program() );
440
441 std::vector<GLenum> buffers;
442 buffers.resize( std::max( fragDataLocation, depthDataLocation ) + 1, GL_NONE );
443 buffers[fragDataLocation] = GL_COLOR_ATTACHMENT0;
444 if( m_useCameraDepth )
445 {
446 buffers[depthDataLocation] = GL_COLOR_ATTACHMENT1;
447 }
448 glDrawBuffers( buffers.size(), &buffers[0] );
449
450 loadNameIDRender( m_currentName );
451 }
452
453 //////////////////////////////////////////////////////////////////////////
454 // OcclusionQuery

Callers

nothing calls this directly

Calls 4

uniformParameterMethod · 0.45
programMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected