Fix some issues with shared textures
Move texture units into the OpenGLState class as they are part of the state. This commit fixes a few issues when textures were being shared between RenderWindows as they could end up using one render window for recording the texture unit and another for looking it up resulting in incorrect texture usage.
Also fix a couple minor issues encountered as part of testing.