Fixed wrong use of WaitForSingleObject and updated OpenGL wrapper.