1) What is the best way to apply different shaders to different objects?
Switching shaders per object drawn could incur extra overhead. Say you have 4 objects, 2 shaders. Object 0 and Object 2 use shader 1, Object 1 and Object 3 use shader 2. If you draw object 0 - 4 in order, then you would have to bind a different shader every draw call which is enefficient (any kind of OpenGL state changes should be minimized). I would batch your object renderings so that you bind shader 0, then draw all objects that use shader 0, bind shader 1, draw all objects that use shader 1.
This can be accomplished in multiple ways. Probably the simplest (assuming you are in C++) is to use std::map with a key of shader, and value of std::vector of your objects. Then iterate over the map, and for each shader 1) bind shader, 2) loop through vector value and draw objects.
[source lang="cpp"]//Say this is your shader wrapper classclass shaderClass { Bind(); //...};//Some wrapper display class for one thing to displayclass DisplayObject { void Draw(); //Draw the object //...};//...typedef std::map < shaderClass *, std::vector < DisplayObject * > > shaderMap_T;shaderMap_T shaderMap;//...void Display () { //Say our shaders have been linked, added to shaderMap with objects, etc. //Loop through shader map for (shaderMap_T::iterator it = shaderMap.begin(); it != shaderMap.end(); ++it) { shaderClass * sc; std::vector < DisplayObject * > * dispList; sc = it->first; dispList = &(it->second); sc->Bind(); for (int i = 0; i < dispList->size(); ++i) { (*dispList)[ i ]->Draw(); } }}[/source]
This is a simple way to do it, there are many more complex ways but usually something to this extent is sufficient. I would be interested to get other's opinions on how they do this.