private static void checkError(String source) {
        if(checkForErrors) {
            int errorcode = GL11.glGetError();
            String errorstring = null;
            switch(errorcode) {
                case GL11.GL_NO_ERROR: return;
                case GL11.GL_INVALID_ENUM: errorstring = "GL_INVALID_ENUM"; break;
                case GL11.GL_INVALID_OPERATION: errorstring = "GL_INVALID_OPERATION"; break;
                case GL11.GL_INVALID_VALUE: errorstring = "GL_INVALID_VALUE"; break;
                case GL30.GL_INVALID_FRAMEBUFFER_OPERATION: errorstring = "GL_INVALID_FRAMEBUFFER_OPERATION"; break;
                case GL11.GL_OUT_OF_MEMORY: errorstring = "GL_OUT_OF_MEMORY"; break;
            }
            throw new RuntimeException(source + ": " + errorstring);
        }
    }