Look at how QMB does it, should port easy to ezQuake in gl_rmain.c