| 866 | } |
| 867 | |
| 868 | void 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 | |
| 916 | bool Shader::Setup::hasCsValue() const |
| 917 | { |
nothing calls this directly
no test coverage detected