You said it draws the function fine..... where does it draw the function?

If it's in the top left, then simply add half the screen coordinates to your drawing function:


glVertex2f(x+(1/2...