Various fixes

GL names have to be prepended by "gl" to obtain function pointers. Also,
the index checks were wrong. Compiles and runs now.