2. The the attributes don't bind

Here's the output of my program:

The shaders did not link correctly.
Could not bind attribute: v_coord3d
Could not bind attribute: v_color
Could not bind uniform: mvp


And here's the relevant code and header file...

void ShaderManager::create_program(std::string name)  {

}

}

program_values.emplace_back(glCreateProgram());
program_keys.emplace_back(name);

}
}

if (attribute != -1)  {
attribute_values.emplace_back(attribute);
attribute_keys.emplace_back(attribute_name);

return true;
}

std::cout << "Could not bind attribute: " << attribute_name << "\n";

return false;
}

// bind uniform function is much the same as the above

public:

static int get_index_of_program_key(std::string program_name);

static void create_program(std::string name);
static bool bind_attribute(std::string shader_name, std::string attribute_name);
static bool bind_uniform(std::string shader_name, std::string uniform_name);

protected:
private:
static std::vector<GLuint> program_values;
static std::vector<std::string> program_keys;

static std::vector<GLuint> attribute_values;
static std::vector<std::string> attribute_keys;

static std::vector<GLuint> uniform_values;
static std::vector<std::string> uniform_keys;

static GLuint create_shader(std::string filename, GLenum type);
};


Here's the code which actually calls the functions:

ShaderManager::create_program("shader");


Another issue I have is that I can't access a string in a vector list with program_names[0], anyone know why?

Are you sure, this is correct?

glAttachShader(program_values[program_values.back()], vertexshader);



I am not OpenGL expert, but you probably mean this:

glAttachShader(program_values.back(), vertexshader);


• +1 Thanks! I thought the std::vector.back() function got the index of the last element, not the actual element itself. I now know otherwise. Thanks! - Fixed all my problems :) (I'm still really new to c++) Aug 10, 2012 at 22:09

Use glGetProgramInfoLog to get a log from the linker and understand what is wrong.

char errbuf[4096];
GLsizei len;

glGetProgramInfoLog(program_values[program_values.back()], sizeof(errbuf), &len, errbuf);
std::cout << errbuf << std::endl;
}


I assume you are not using glGetShaderInfoLog in the compilation stage either, so I suggest you do that, too.

• I've added the suggested code you listed above, it doesn't add anything new to the output. I am indeed using the glGetShaderLogInfo() in the compilation stage. Aug 10, 2012 at 7:03
• @Darestium there is nothing inherently wrong with the code you showed so far. If the program does not link and nothing is printed, it might be a bug in your drivers. The problem might also lie in create_shader(), or in the actual shaders. Can you maybe post these? Aug 10, 2012 at 14:15
• +1 The problem did lay in my code where I used std::vector[std::vector.back()], I thought the .back() function returned the last element in the list - not the actual element itself. Thanks for the help. Aug 10, 2012 at 22:12