Rework the way server-side OpenGL texture state is stored.

This change is needed for a future fix regarding when a texture state is
deleted while it is attached to a shader as a uniform.
Initial commit for fixing a bug where a shader will try binding a deleted texture.

There is still a bug around somewhere causing a crash on shutdown. The next commit(s) will be fixing this.
Some improvements to the way material parameters are handled.

The main changes here is that things are a little bit more readable because the #define macros are now removed.
Cleanup some dead and unused code.