Q:

Drawing a circle in c++ using openGL

I've been trying to draw a circle in c++ using openGL. So far i have a compresses circle and it just has a random line going across the screen.
This is the function I'm using to get this shape.
void Sprite::init(int x, int y, int width, int height, Type mode, float scale) {
    _x = x;
    _y = y;
    _width = width;
    _height = height;
    //generate buffer if it hasn't been generated
    if (_vboID == 0) {
        glGenBuffers(1, &_vboID);
    }
    Vertex vertexData[360];
    if (mode == Type::CIRCLE) {
        float rad = 3.14159;
        for (int i = 0; i < 359; i++) {
            vertexData[i].setPosition((rad * scale) * cos(i), (rad * scale) * sin(i));
        }
    }

    //Tell opengl to bind our vertex buffer object
    glBindBuffer(GL_ARRAY_BUFFER, _vboID);
    //Upload the data to the GPU
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);

    //Unbind the buffer
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}

What is causing the line? Why is my circle being compressed?
Sorry if this is a dumb question or if this question doesn't belong on this website I'm very new to both c++ as well as this website.

A:

It is difficult to be sure without testing the code myself, but I'll guess anyway.
Your weird line is probably caused by the buffer not being fully initialized. This is wrong:
Vertex vertexData[360];
for (int i = 0; i < 359; i++) {

It should be:
for (int i = 0; i < 360; i++) {

or else the position at vertexData[359] is left uninitialized and contains some far away point.
About the ellipse instead of a circle, that is probably caused by your viewport not having the same scale horizontally and vertically. If you configure the viewport plus transformation matrices to have a viewing frustum of X=-10..10, Y=-10..10, but the actual viewport is X=0..800 and the Y=0..600, for example, then the scale would be different and you'll get your image distorted.
The solution would be one of:

Create a square viewport instead of rectangular. Check your arguments to glViewport().
Define a view matrix to consider the same ratio your viewport has. You don't show how you set the view/world matrix,  maybe you are not even using matrices... If that is the case, you should probably use one.

