I am drawing some points in an array using glVertex2f(), and I need to flip it upside-down. I am drawing it in a glViewport(), so I can resize it and move it around. But I don’t know how to flip it.
Do I have to use gluOrth2d()? I don’t fully understand what the difference is between gluOrth2d() and glViewport() and when to use which.
glViewport() sets the viewport. That is it sets what part of the window your whole geometry will be drawn in. Notice that it accepts integers(!!) and not floating point numbers just because we need to be exact to the part of the screen where the rendering will occur.
gluOrtho, like gluPerspective, glFrustrum e.t.c. is used to set the Projection Matrix.
Please note that even though you may not be using gluOrtho2D() in your program you should be using since you always need to have a perspective projection set by yourself.
EDIT: (corrected to comply with the pointers given in the comments)
In order to flip the whole scene, assuming it is 2D you could do this
which will multiply the current modelview matrix with a scaling matrix, effectively flipping the scene upside down.
Since you seem to need help with understanding the use of openGL matrices I want to provide these two links that I hope might help:
Explains without lots of math
Explains with a bit more math