refactor gl emulation code