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

Method addVertexAttribute

src/IECoreGL/Shader.cpp:868–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866}
867
868void Shader::Setup::addVertexAttribute( const std::string &name, IECore::ConstDataPtr value, GLuint divisor )
869{
870 const Parameter *p = m_memberData->shader->vertexAttribute( name );
871 if( !p )
872 {
873 return;
874 }
875
876 if( p->size > 1 )
877 {
878 IECore::msg( IECore::Msg::Warning, "Shader::Setup::addVertexAttribute", format( "Array attribute \"%s\" is currently unsupported." ) % name );
879 }
880
881 GLenum dataGLType = glType( value.get() );
882 if( !dataGLType )
883 {
884 IECore::msg( IECore::Msg::Warning, "Shader::Setup::addVertexAttribute", format( "Vertex attribute \"%s\" has unsuitable data type \"%s\"" ) % name % value->typeName() );
885 }
886
887 GLint size = 0;
888 switch( p->type )
889 {
890 case GL_INT :
891 case GL_FLOAT :
892 size = 1;
893 break;
894 case GL_INT_VEC2 :
895 case GL_FLOAT_VEC2 :
896 size = 2;
897 break;
898 case GL_INT_VEC3 :
899 case GL_FLOAT_VEC3 :
900 size = 3;
901 break;
902 case GL_FLOAT_VEC4 :
903 size = 4;
904 break;
905 default :
906 IECore::msg( IECore::Msg::Warning, "Shader::Setup::addVertexAttribute", format( "Vertex attribute \"%s\" has unsupported OpenGL type \"%d\"" ) % name % p->type );
907 return;
908 }
909
910 CachedConverterPtr converter = CachedConverter::defaultCachedConverter();
911 ConstBufferPtr buffer = IECore::runTimeCast<const Buffer>( converter->convert( value.get() ) );
912
913 m_memberData->vertexValues[ p->location ] = new MemberData::VertexValue( p->location, dataGLType, size, buffer, divisor );
914}
915
916bool Shader::Setup::hasCsValue() const
917{

Callers

nothing calls this directly

Calls 4

typeNameMethod · 0.80
vertexAttributeMethod · 0.45
getMethod · 0.45
convertMethod · 0.45

Tested by

no test coverage detected