Exemple #1
0
void process_vertex_attribute( 
    OpenGLContext&          openGLContext, 
    OpenGLShaderProgram&    shader, 
    std::string             name, 
    size_t                  stride_bytes, 
    size_t                  offset_bytes
    )
{
    // e.g. float[3] -> float and 3
    using Type = typename remove_extent<Tn>::type;
    static constexpr size_t  dim = extent<Tn>::value;

    GLint location = openGLContext.extensions.glGetAttribLocation(shader.getProgramID(), attributeName);
    if( location == -1 )
        return nullptr; // not found in shader
    
    OpenGLShaderProgram::Attribute gl_attribute =  new OpenGLShaderProgram::Attribute (shader, attributeName);
    
    if( gl_attribute == nullptr )
        return nullptr;
    
    generic_glVertexAttribPointer<Type>(
        attribNumber->attributeID,
        dim,
        vec_bytes,
        (const GLvoid *)offset_bytes
        );

    glEnableVertexAttribArray( attribNumber->attributeID );
}
OpenGLShaderProgram::Attribute::Attribute (const OpenGLShaderProgram& program, const char* name)
    : attributeID (program.context.extensions.glGetAttribLocation (program.getProgramID(), name))
{
    jassert (attributeID >= 0);
}
OpenGLShaderProgram::Uniform::Uniform (const OpenGLShaderProgram& program, const char* const name)
    : uniformID (program.context.extensions.glGetUniformLocation (program.getProgramID(), name)), context (program.context)
{
    jassert (uniformID >= 0);
}