Q:

Grouping vs separate glVertex in immediate mode

I know they are deprecated, but are these 2 equivalent?
1.
glBegin(GL_LINES);
glVertex2f(x1, y1);
glVertex2f(x1, y2);
glVertex2f(x1, y2);
glVertex2f(x2, y2);
glVertex2f(x1, y1);
glVertex2f(x2, y1);
glVertex2f(x2, y1);
glVertex2f(x2, y2);
glEnd();

2.
glBegin(GL_LINES);
glVertex2f(x1, y1);
glVertex2f(x1, y2);
glEnd();

glBegin(GL_LINES);
glVertex2f(x1, y2);
glVertex2f(x2, y2);
glEnd();

glBegin(GL_LINES);
glVertex2f(x1, y1);
glVertex2f(x2, y1);
glEnd();

glBegin(GL_LINES);
glVertex2f(x2, y1);
glVertex2f(x2, y2);
glEnd();

A:

Equivalent in behavior? Yes.
Equivalent in performance? No. Sure, you're dealing with immediate mode, so it's going to be slow. But even for immediate mode, there's slow and there's slow. The fewer glBegin calls you need to make, the better.

