// Intel/Mesa seems to have a broken glGenerateMipmap() for non-FBO textures, so do it here
// instead of calling glGenerateMipmap().
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, needs_mipmaps);
check_error();
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, NULL);
check_error();
// Intel/Mesa seems to have a broken glGenerateMipmap() for non-FBO textures, so do it here
// instead of calling glGenerateMipmap().
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, needs_mipmaps);
check_error();
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, NULL);
check_error();